月度归档:2016年07月

cuckoo折腾

Published / by whosb / cuckoo折腾有2条评论

开章明义,这个教程不确定能带着你建立出一套合适的cuckoo系统,只是自我对整个过程的一个记录,没有坚强的意志以及钻研的精神,可以就此打住了
顺便说一下,我自认为bug体质,cuckoo建过至少6套,linux完全没有正常跑起来过,win只有一次正常跑,后来其他都有残次,绝对不好弄

——–

cuckoo 记录

说是支持linux版本,建议安装安装长期支持版,开始选择了14.04ok,win版本的虚拟机跑起来了,但是经过了半年,升级的时候出现了问题,索性换到16.04 出了一些问题,结果后来又出了新的问题,觉得还是14.04稳妥一些,重新安装
建议不要用中文版的,因为后面会需要新建虚拟机,如果中文版的,虚拟机名字也是中文,可能会出现配置文件不认识的情况,减少可能犯错的地方。后来又14.04和16.04来回倒腾n次
建议先看英文版的说明,文末有链接。

安装各种环境,python和几个基础库

sudo apt-get install python python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev(后面两个是后面 lxml2需要用到的)

如果需要安装Django的web还需要安装mongoldb
sudo apt-get install mongodb
如果你纯命令行提交submit,这个可以不需要

下载源代码
git clone https://github.com/cuckoosandbox/cuckoo.git

下来事情是安装各种依存,很复杂,使用的是
sudo pip install -r requirements.txt
但是安装中出现过问题,安装了新版本,但是requirement里面要求的老版本会把新的卸载了,然后安装了旧的。(peepdf这个比较有问题,经过了多种尝试,我决定把它暂时去掉了)
尝试了一个方法,把配置文件里面所有==改成>=但是还不知道效果如何
还有一个问题是,这个文件中比如说有10个,第四个因为网络原因没有下完,安装失败,再开始的时候会从第一个开始下载,崩溃的节奏啊
sed -n 3,1p 1.txt
可以第三行取1行,如果报错太多,我准备每10行一个文件,然后分批下载安装,挂了ss,速度好多了,暂时不用切文件了
中间有一个提示libxml2没有安装,安装就是了
还有一个是peepdf的报错,安装其他的时候会自动安装Pillow 3.3 但是peepdf是要安装3.2,然后就会卡,手动安装特定的版本也报错
sudo pip install -v Pillow==3.2.0
sudo apt-get install python-imaging

这个时候很慢,可以建议把virtualbox安装了先

然后说,需要yara 和 pydeep 这个你自己安装去吧,哈哈哈哈

yara git
git clone https://github.com/VirusTotal/yara.git
./bootstrap.sh
./configure –enable-cuckoo
sudo make install

也可以直接
sudo pip install yara-python(我不是故意放到后面,是后面才发现的)

pydeep pip
安装yara的时候提示autoreconf没找到和缺少jansson
sudo apt-get install dh-autoreconf libjansson-dev

然后 sudo apt-get install libjansson-dev
./configure –enable-cuckoo

pip install pydeep的时候提示 fuzzy.h不见了,
sudo apt-get install libfuzzy-dev

还需要volatility分析内存用d
git clone https://github.com/volatilityfoundation/volatility.git
sudo python setup.py install

然后就是添加用户用户组之类的
sudo adduser cuckoo
sudo usermod -a -G vboxusers cuckoo

再然后记得进虚拟机,设置网络,不然后面没法开

设置配置文件这也是大坑

准备虚拟机
关闭 防火墙,更新,uac
如果是winxpsp3vl
MRX3F-47B9T-2487J-KWKMF-RPWBY

win主机上需要准备的软件
https://www.python.org/ftp/python/2.7/python-2.7.msi
python 需要老版本,新版本xp不允许安装
http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe
PIL

ubuntu 虚拟机配置文件
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.56.102
netmask 255.255.255.0
gateway 192.168.56.1
dns-nameservers 114.114.114.114

cuckoo主机上执行,做流量转发的作用
iptables -A FORWARD -o eth0 -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

sysctl -w net.ipv4.ip_forward=1

—-
最后我们在配置一下cuckoo的web界面。需要开启reporting.conf中的mongodb。然后开启mongodb服务:systemctl enable mongodb;systemctl start mongodb。现在可以启动web服务web/manage.py runserver。服务运行于127.0.0.1:8000。
中间还有过cuckoo主程序提示让我装个数据库啥的,这都后话了

屏幕快照 2016-07-15 02.03.40
屏幕快照 2016-07-15 02.03.40 (2)
一个是开了两个t,一个是主程序,一个是web,方便提交,另一个截图是虚拟机里虚拟机里虚拟机正在跑的记录(这句不是为了强调,是真的就是第三层的虚拟机)
————
参考
http://docs.cuckoosandbox.org/en/latest/
http://www.freebuf.com/sectool/108533.html

modsecurity体验

Published / by whosb / Leave a Comment

准备把内网的一个网站放出去,为了b格以及安全性,决定使用代理proxy ssl modsecurity (后面我决定简写为modsec)

ssl 免费证书不难,这里做个广告 https://www.startssl.com/ 免费用一年,可以有一个域名的5个子域名,这部分不难,自己网上看看,稍微麻烦一点的是需要域名的邮箱认证,提供了三个可选邮箱webmaster、postmaster、还有三个什么忘了

下一个做反向代理,开始打算nginx+modsec,结果不开modsec没问题,一开会发现.js文件会被莫名其妙的置空,看到有人在官网反馈问题了,但是官方说那个人提出的问题不是问题,这条路偃旗息鼓 我使用更多是nginx 1.11 modsec也是官网下的最新,如果你也有此次打算,建议换路子走吧。

然后开始尝试apache +modsec,网上也有不少配置
https://www.digitalocean.com/community/tutorials/how-to-set-up-modsecurity-with-apache-on-ubuntu-14-04-and-debian-8
这个说的比较好,其他的自己搜吧。
然后我的bug体质又爆发了,都配置ok,但是死活不过滤危险的请求比如单引号啊,select啊之类的,在apache的vhost配置文件里面加了modsec的配置文件,提醒我已经有了,去掉,不过滤,再加再去,来来回回几个回合,某次是在无奈,一遍开日志,一遍测试,竟然过滤了,这都什么鬼。。。。。

nginx的配置文件
(代码高亮没弄将就看吧)
—–
server {

listen 443 ssl;
server_name www.aaa.xyz;

#Enable ModSecurity
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;

ssl on;
ssl_certificate /root/csr/1_www.aaa.xyz_bundle.crt;
ssl_certificate_key /root/csr/aaa-nopass.key;
location /{
proxy_pass http://1.1.1.1;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect http://www.aaa.xyz https://www.aaa.xyz;
proxy_force_ranges on;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
}

几乎没有什么需要讲解的,其中1_www.aaa.xyz.bundle.crt是在前面startssl上生成的,下面的key是本机生成的,记得nopass啊,不然启动每次都需要输入密码,至于如何nopass。。。搜吧,忘了记录了

以上配置仅供参考,因为我自己都没用,碰上nginx+modsec的bug了

下来apache + modsec



# General setup for the virtual host
ServerName www.aaa.xyz:443


SSLProxyEngine on
ProxyRequests Off

ProxyPass / http://1.1.1.1/
ProxyPassReverse / http://1.1.1.1/
SSLCertificateFile “/root/csr/1_www.aaa.xyz_bundle.crt”
SSLCertificateKeyFile “/root/csr/aaa-nopass.key”


感觉也基本没啥说的了

———-

ps.apache有时候需要
a2enmod proxy_http
a2enmod ssl
才能启用对用的模块

ubuntu 16.04 aliyuan

Published / by whosb / Leave a Comment

/etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

这个是官方源 暂时的(2016年7月7日10:43:08)但是并不全面,开始折腾了好久,丢了一些包,后来用sohu的好了,其实就是把上面的aliyun换成sohu即可