ubuntu sever部署cuckoo

前言:

前段时间捣鼓cuckoo也有一段时间,在部署cuckoo时遇到各种坑,奈何网上资料零散且真假难辨,遂自己整理了一个部署文档,重要内容都记录,有些地方没那么细,但是思路都在。

本次部署在Ubuntu20服务器上

1、检查默认环境,作好准备工作:

vim

apt-get install vim

curl,用于安装python pip

apt-get install curl

2、关于Linux的python环境准备:

使用python虚拟化环境,可以直接使用系统自带的python3直接使用

pip2 install virtualenv
virtualenv --system-site-packages cuckoo
source cuckoo/bin/activate

先装python,版本为2.x最好

apt-get install python

python-pip2安装

apt install curl
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py 
pip --version 检测版本

其他环境的安装

python-dev libffi-dev 
python-virtualenv  
#Python支持工具
python-setuptools
#jpeg 和接口支持工具
libjpeg-dev zlib1g-dev swig

为了使用基于 Django 的 Web 界面,需要 MongoDB:

apt-get install mongodb

为了使用PostgreSQL作为数据库,PostgreSQL将 还必须安装:

apt-get install postgresql libpq-dev

数据库还可以选择MySQL,修改配置文件即可

安装Pydeep,libfuzzy-dev

wget http://sourceforge.net/projects/ssdeep/files/ssdeep-2.13/ssdeep-2.13.tar.gz/download -O ssdeep-2.13.tar.gz
tar -zxf ssdeep-2.13.tar.gz
cd ssdeep-2.13
./configure
make
sudo make install

3、安装虚拟化软件(virtualbox)

最好安装在独立文件夹,安装:
sudo apt update
sudo apt install virtualbox virtualbox-ext-pack
​
导入密钥:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
添加 VirtualBox APT 软件源 到你的系统:
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | \
     sudo tee -a /etc/apt/sources.list.d/virtualbox.list
更新源:
apt update
apt install virtualbox-7.0
​
扩展包安装:
官网下载再导入
https://www.virtualbox.org/wiki/Download_Old_Builds_7_0
VBoxManage extpack install 包名

4、安装tcpdunmp

apt-get install tcpdump apparmor-utils
aa-disable /usr/sbin/tcpdump
​
#Tcpdump需要根权限,但由于您不希望Cuckoo以根权限运行,因此必须将特定的Linux功能设置为二进制文件,提前创建cuckoo用户
groupadd pcap
usermod -a -G pcap cuckoo
chgrp pcap /usr/sbin/tcpdump
setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump

5、volatility

在指定文件夹下安装
apt-get install git
这里可能需要挂梯子:
git clone https://github.com/volatilityfoundation/volatility.git
#将构建它类型
python setup.py build
#安装
python setup.py install
​
可能缺失distorm3:
pip install distorm3

6、安装m2crypto

目前,该库仅在安装SWIG后才受支持。在Ubuntu/ debian之类的系统上,可以这样做:
apt-get install swig
如果系统上存在,可以按如下方式安装:
sudo pip install m2crypto==0.24.0
此方法应该不行,尝试下一种
​
​
要安装swig,gcc,libssl1.0-dev,直接apt-get
libpcre3,libpcre3-dev,gcc-multilib
​
环境需要libssl1.0-dev,添加源并更新:
deb http://security.ubuntu.com/ubuntu bionic-security main
apt-get install libssl1.0-dev
​
使用源码安装:
下载地址:https://github.com/mcepl/M2Crypto/releases/tag/0.24.0
构建:python setup.py build
安装:python setup.py install

7、安装guacd(可选)

8、安装yara

apt-get install libtool flex   #环境
apt-get install yara

现在可以安装cuckoo

pip install -U pip setuptools
pip install -U cuckoo
​
国内源(-i 一次性换源)
https://pypi.tuna.tsinghua.edu.cn/simple

关于客户机

设置网络:
客户机需要设置一个host only + nat 保证客户机和宿主机之间能够ping通
环境:
需要安装一个python2.7环境,并且运行agent.py 远控脚本,及时快照,记录快照名
关闭防火墙及自动更新
​
​
关于脚本、快照:
需要禁用UAC,并且在管理员权限运行脚本时快照
​
​
关于脚本的传输,使用共享文件夹,使用samba搭建
samba:
创建共享文件:mkdir yu
改权限:chmod 777 yu
​
配置samba配置文件:
如果 #security = user存在就修改,不存在就添加
[global]
    workgroup = WORKGROUP 
    display charset = UTF-8
    unix charset = UTF-8
    dos charset = cp936 
    
### 注:如果 #security 存在就直接修改,不存在就创建
#security = user 
    security = user 
    username map = /etc/Samba/smbusers 
​
[share]
    comment = Shared Folder with username and password 
    path = /home/share/
    public = yes
    writable = yes
    valid users = share    #配置的Samba访问账号
    create mask = 777 
    directory mask = 777 
    force user = nobody 
    force group = nogroup 
    available = yes 
    browseable = yes
    
文末添加:(中文记得删除)
[ubuntu-share]  # 在 windows 下将看到的 ubuntu 共享文件夹名称
path = /ubuntu-share  # ubuntu 共享文件夹路径
public = yes  # 是否允许匿名登录,要使之生效需删除valid users
writable = yes  # 可写
valid users = root  # 这里我使用 root 作为用户名,删除此行的话windows访问ubuntu的时候就不用输入账号密码
create mask = 0644
force create mode = 0644
directory mask = 0755
force directory mode = 0755
available = yes
​
smbpasswd -a root  # 设置root用户的密码
service smbd restart  #重启服务

vbox操作常用命令

安装:
sudo apt update
sudo apt install virtualbox virtualbox-ext-pack
关于扩展包的设置:
vboxmanage setproperty vrdeextpack "Oracle VM VirtualBox Extension Pack"
​
创建虚拟机:VBoxManage createvm --name win7 --register
设置操作系统win7:VBoxManage modifyvm win7 --ostype Windows7
查看支持的类型:VBoxManage list ostypes
设置内存:VBoxManage modifyvm win7 --memory 4096
​
建立虚拟磁盘(系统盘)100G:VBoxManage createmedium --filename win7_HDD_SYS_100G.vdi --size 100000
建立虚拟磁盘(home盘)100G:VBoxManage createmedium --filename win7_HDD_HOME_100G.vdi --size 100000
​
创建存储控制器IDE、SATA:
VBoxManage storagectl win7 --name IDE --add ide --controller PIIX4 --bootable on
VBoxManage storagectl win7 --name SATA --add sata --controller IntelAhci --bootable on
​
关联虚拟磁盘:
VBoxManage storageattach win7 --storagectl SATA --port 0 --device 0 --type hdd --medium win7_HDD_SYS_100G.vdi
VBoxManage storageattach win7 --storagectl SATA --port 1 --device 0 --type hdd --medium win7_HDD_HOME_100G.vdi
​
关联镜像文件:
VBoxManage storageattach win7 --storagectl IDE --port 0 --device 0 --type dvddrive --medium /opt/windows_7_ultimate_with_sp1_x64.iso
​
​
修改网络模式为nat:VBoxManage modifyvm win7 --nic1 nat
自动分配的IP是10的私有网段,修改网段:
VBoxManage modifyvm win7 --natnet1 "192.168.214.0/24"
​
(可以不改,两张网卡实现)改为hostonly:
VBoxManage modifyvm win7 --nic1 hostonly --hostonlyadapter1 ens33
​
​
新增一个网卡,默认vboxnet:
VBoxManage hostonlyif create
设置hostonly模式:
VBoxManage modifyvm win7 --nic2 hostonly
设置到网卡:
VBoxManage modifyvm win7 --hostonlyadapter2 vboxnet0
验证主机和客户机上能ping通
​
设置远程桌面连接:
VBoxManage modifyvm win7 --vrdeport 5540 --vrdeaddress ""
打开远程桌面:
VBoxManage modifyvm UbuntuRDHome --vrde on
关闭远程桌面:
VBoxManage modifyvm UbuntuRDHome --vrde off
​
​
开启虚拟机:VBoxHeadless -startvm "win7"
关闭虚拟机:VBoxManage controlvm win7 acpipowerbutton
格式化输出信息:VBoxManage showvminfo win7 -details -machinereadable
拍摄快照:VBoxManage snapshot win7(虚拟机名) take test1(快照名)
通过某一快照恢复:VBoxManage snapshot "vmname" restore "snapname" 
查看正在运行虚拟机列表:vboxmanage list runningvms

关于网络配置

因为Virtualbox启动之前,不会显示虚拟网络接口,所以设置的仅主机模式,新增的网卡没有显示,会导致网络配置的问题导致虚拟机启动不起来。
解决方法:在cuckoo启动之前,启动一次客户虚拟机。

设置IP转发规则(不配置的话会报错)

如果只设置了仅主机模式,就要设置路由转发,使
​
sysctl -w net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
​
永久开启:
vim /etc/sysctl.conf
net.ipv4.ip_forward=1 前的注释取消
sysctl -p /etc/sysctl.conf
​
​
通过设置IP转发,可以实现客户机通过主机的ens33网卡访问网络
#iptables -A FORWARD -o ens33 -i vboxnet0 -s 192.168.56.0/24 -m conntrack --ctstate NEW -j ACCEPT
#iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
#iptables -A POSTROUTING -t nat -j MASQUERADE

修改配置文件

cuckoo.conf

machinery = virtualbox
[resultserver]
ip = 192.168.56.1 #This is the IP address of the host
port = 2042 #leave default unless you have services running
[cuckoo]
//每次启动都要检查更新很费时间,可以选择关闭
version_check = no

auxiliary.conf:

[sniffer]
# Enable or disable the use of an external sniffer (tcpdump) [yes/no].
enabled = yes
​
# Specify the path to your local installation of tcpdump. Make sure this
# path is correct.
tcpdump = /usr/sbin/tcpdump

virtualbox.conf:

machines = 你的虚拟机名字
​
[你的虚拟机名字]
label = 你的虚拟机名字
platform = windows
ip = 192.168.56.101 # IP address of the guest
snapshot = 你创建的快照名字
interface = vboxnet0

下载Cuckoo Community,其中包含了300多个恶意软件行为签名,可用于简化我们对结果的分析

cuckoo community

关于virtualenv

创建虚拟环境  
virtualenv cuckoo
​
指定虚拟环境的python版本  
virtualenv --python 解释器 ccuckoo
​
默认情况下虚拟环境不会依赖系统环境的site-packages,如果想依赖系统环境的site-packages,可以使用--system-site-packages来设置。
virtualenv --system-site-packages cms
​
启动虚拟环境
source cms/bin/activate
​
退出
deactivate
​
下载拓展工具
pip install virtualenvwrapper

关于报错

1:
Unable to stop auxiliary module: Sniffer
Error running tcpdump to sniff the network traffic during the analysis; stdout = '' and stderr = "tcpdump: Couldn't change ownership of savefile\n". Did you enable the extra capabilities to allow running tcpdump as non-root user and disable AppArmor properly (the latter only applies to Ubuntu-based distributions with AppArmor, see also https://cuckoo.sh/docs/faq/index.html#permission-denied-for-tcpdump)?
解决:
执行sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
并重新启动,可以解决,此方法适用于python虚拟环境下的cuckoo
描述:Tcpdump需要root权限,但是因为你不希望Cuckoo以root身份运行,所以你必须将特定的Linux功能设置为二进制
解决:
$ sudo groupadd pcap
$ sudo usermod -a -G pcap cuckoo
$ sudo chgrp pcap /usr/sbin/tcpdump
$ sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
​
2:
Error checking for the latest Cuckoo version: HTTPSConnectionPool(host='cuckoosandbox.org', port=443): Max retries exceeded with url: /updates.json?version=2.0.7 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2ecfed28d0>: Failed to establish a new connection: [Errno -5] No address associated with hostname',))!
解决:配置里关掉自动更新即可
​
3:
Virtual machine /status failed. HTTPConnectionPool(host='192.168.56.101', port=8000): Read timed out. (read timeout=5)
Virtual Machine /status failed. This can indicate the guest losing network connectivity
解决:使用root设置路由转发
​
4:
Analysis results folder does not contain any behavior log files.
You do not have the m2crypto library installed preventing certificate extraction. Please read the Cuckoo documentation on installing m2crypto (you need SWIG installed and then `pip install m2crypto==0.24.0`)!
解决:源码安装,注意lissbl1.0版本
​
5:
error fetching configuration file!   this is a serious error.  if encountered,please notify the Cuckoo Developers as this error this error prevents analysis
解决:虚拟客户机关闭UAC,并且以administrator账户登录并快照
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值