现在的位置: 首页 > 综合 > 正文

tcpdump Wireshark ,抓报分析脚本

2013年08月01日 ⁄ 综合 ⁄ 共 353字 ⁄ 字号 评论关闭
import dpkt,os,sys
os.chdir(sys.path[0])

f = open('12.cap','rb')
pcap = dpkt.pcap.Reader(f)

for ts, buf in pcap:
    eth = dpkt.ethernet.Ethernet(buf)
    ip = eth.data
    tcp = ip.data
    try:
        if tcp.dport==80 and len(tcp.data)>0:
            http=dpkt.http.Request(tcp.data)
            if http.method=='POST':
                print http.headers['host']+http.uri+'\n'+http.body,#,http.headers['user-agent']
                print '\n\n'
    except:pass
f.close()

抱歉!评论已关闭.