如何用 Pytbull 测试 suricata?
在你安装完 IDS/IPS 并且能运行的时候,你可能想知道它是否能正常的记录日志或者丢弃恶意的数据包。那么,我们就可以使用一个基于灵活得 IDS/IPS 测试框架的 python 脚本 --- Pytbull,它附带 300 多个测试,9个模块,涵盖了大范围的攻击(clientSideAttacks, testRules, badTraffic, fragmentedPackets, multipleFailedLogins, evasionTechniques, shellCodes, denialOfService, pcapReplay)。
使用 Pytbull 测试 IDS/IPS 将会节省你很多时间!
我们先假设我们有一台 IP 地址为 192.168.1.25 的 Ubuntu Linux 测试机 A 和一台 IP 地址为 192.168.1.1 的安装了 Smooth-Sec 的机器 B。
在测试机 A 192.168.1.25上安装所有需要的软件包和依赖包。
#apt-get install python python-scapy nmap hping3 nikto tcpreplay python-iniparse
下载 Pytbull:
#wget https://downloads.sourceforge.net/project/pytbull/pytbull-1.3.tar.bz2 #bzip2 -cd pytbull-1.3.tar.bz2 | tar xf - #cd pytbull
接下来就是修改配置文件了:
#vi config.cfg
#Pytbull config file [CLIENT] ipaddr = 192.168.1.1 #ip address of the IDS to test. iface = eth0 [PATHS] report = report.html sudo = /usr/bin/sudo nmap = /usr/bin/nmap nikto = /usr/bin/nikto niktoconf = /root/pytbull/nikto.conf hping3 = /usr/sbin/hping3 tcpreplay = /usr/bin/tcpreplay urlpdf = http://droid-protector.com/borrar_ya/md5 alertsfile = /var/log/suricata/fast.log [CREDENTIALS] ftpuser = pytbull ftppasswd = pytbull
然后创建一个 nikto 配置文件,并添加以下内容:
#start nikto configuration file SKIPPORTS=21 111 USERAGENT=Mozilla/4.75 (Nikto/@VERSION) (Evasions:@EVASIONS) (Test:@TESTID) RFIURL=http://cirt.net/rfiinc.txt? NIKTODTD=docs/nikto.dtd DEFAULTHTTPVER=1.0 UPDATES=yes MAX_WARN=20 CIRT=174.142.17.165 CHECKMETHODS=HEAD GET @@MUTATE=dictionary;subdomain @@DEFAULT=@@ALL;-@@MUTATE;tests(report:500) #end nikto configuration file
然后拷贝 Pytbull 服务端的脚本(reverse shel)用于客户端向 Smooth-Sec 机器 192.168.1.1 攻击:
#scp server/pytbull-server.py [email protected]:
定义你想要对 suricata 运行的测试种类,请参考 Pytbull 配置文件(config.cfg)尾部。
0 = 关闭
1 = 开启
[TESTS] clientSideAttacks = 1 testRules = 1 badTraffic = 1 fragmentedPackets = 1 multipleFailedLogins = 1 evasionTechniques = 1 shellCodes = 1 denialOfService = 1 pcapReplay = 1
在 Smooth-Sec 机器 192.68.1.1 上:
#apt-get install vsftpd apache2 #adduser –home /var/log/suricata –shell /bin/bash pytbull #usermod -G suricata pytbull
在 Smooth-sec 机器 192.168.1.1 上启动 reverse shell 脚本:
#python pytbull-server.py --port 34567 _ _ _ _ _ __ _ _| |_| |__ _ _| | | | '_ \| | | | __| '_ \| | | | | | | |_) | |_| | |_| |_) | |_| | | | | .__/ \__, |\__|_.__/ \__,_|_|_| |_| |___/ Sebastien Damaye, aldeid.com Checking root privileges......................................... [ OK ] Checking port to use............................................. [ OK ] Server started on port: 34567 Listening...
在 192.168.1.25 上运行测试脚本,指定目的 IP 为 192.168.1.1:
#python pytbull.py -t 192.168.1.1 _ __ _ _| |_| |__ _ _| | | | '_ \| | | | __| '_ \| | | | | | | |_) | |_| | |_| |_) | |_| | | | | .__/ \__, |\__|_.__/ \__,_|_|_| |_| |___/ Sebastien Damaye, aldeid.com BASIC CHECKS ------------ Checking root privileges......................................... [ OK ] Checking remote port 21/tcp (FTP)................................ [ OK ] Checking remote port 22/tcp (SSH)................................ [ OK ] Checking remote port 80/tcp (HTTP)............................... [ OK ] Checking path for sudo........................................... [ OK ] Checking path for nmap........................................... [ OK ] Checking path for nikto.......................................... [ OK ] Checking path for niktoconf...................................... [ OK ] Checking path for hping3......................................... [ OK ] Checking path for tcpreplay...................................... [ OK ] Removing temporary file.......................................... [ OK ] TESTS ------------ Client Side Attacks.............................................. [ yes ] Test Rules....................................................... [ yes ] Bad Traffic...................................................... [ yes ] Fragmented Packets............................................... [ yes ] Multiple Failed Logins........................................... [ yes ] Evasion Techniques............................................... [ yes ] ShellCodes....................................................... [ yes ] Denial of Service................................................ [ yes ] Pcap Replay...................................................... [ yes ] ----------------------- DONE. Check the report. -----------------------
报表视图:
在测试机器 192.168.1.25 上:
#cp report.html /var/www/
在浏览器中打开 http://192.168.1.25/report.html ,就可以看到具体的测试报告。
有不足之处,望大家提出来,共同交流。谢谢~
参考:
http://bailey.st/blog/2011/09/12/test-suricata-with-pytbull/