我需要分析带有Snort和其他IDS/WAFs(Suricata、mod\u security和Shadow Daemon)的Apache日志。为此,我考虑用Python中Scapy的Apache日志中存储的GET和POST请求创建TCP包。像这样:
packet= IP(dst=dst_ip)/TCP(dport=9999)/Raw(load=payload) #payload contains the http request
我将这些TCP数据包存储到PCAP文件中,以便稍后使用Snort或我所说的其他IDS/WAFs进行分析。你知道吗
这种生成数据包的方法的问题是,通信中没有状态,Snort通过此警报检测到它:
[**] [129:2:1] Data on SYN packet [**]
[Classification: Generic Protocol Command Decode] [Priority: 3]
09/01-20:29:50.816860 127.0.0.1:20 -> 127.0.0.1:9999
TCP TTL:64 TOS:0x0 ID:1 IpLen:20 DgmLen:102
******S* Seq: 0x0 Ack: 0x0 Win: 0x2000 TcpLen: 20
[Xref => http://www.securityfocus.com/bid/34429][Xref => http://cve.mitre.org/cgi-bin/cvename.cgi?name=2009-1157]
然后,我修改了代码以添加序列号和确认号:
ip = IP(src=src_ip, dst=dst_ip)
packet = (ip / TCP(sport=src_port, dport=dest_port, flags='PA',
seq=seq_n, ack=ack_n) / Raw(load=fullrequest[0])
seq_n = seq_n + len(payload.encode('UTF8'))
这样,就有了一个序列,但是SYN数据包上的数据警报会为另一个数据包更改(尽管没有留下与相同数量的数据包一样多的警报,只有22%的数据包会抛出警报):
[**] [129:12:1] Consecutive TCP small segments exceeding threshold [**]
[Classification: Potentially Bad Traffic] [Priority: 2]
09/01-20:49:15.037299 127.0.0.1:60664 -> 127.0.0.1:80
TCP TTL:64 TOS:0x0 ID:1 IpLen:20 DgmLen:94
***AP*** Seq: 0x156E7 Ack: 0xB Win: 0x2000 TcpLen: 20
最后,我选择创建一个带有套接字的客户机-服务器结构(将负载从一个虚拟机发送到另一个虚拟机),使用WireShark分析流量,然后将包保存为PCAP。这里的问题是Snort没有检测到一次攻击。此外,我无法自动执行此分析操作。你知道吗
攻击示例:
"GET /shoutbox.php?conf=../../../../../../../../etc/passwd HTTP/1.1"
"GET /cgi-bin/apexec.pl?etype=odp&template=../../../../../../../../../../etc/hosts%00.html&passurl=/category/ HTTP/1.1"
我会做错什么?有什么提示吗?你知道吗
回答如下:
https://security.stackexchange.com/questions/193036/analyzing-apache-log-with-snort
基本上,与其自己设计包,不如使用
requests
库直接发送请求。你知道吗相关问题 更多 >
编程相关推荐