tcpdump Wireshark ,抓报分析脚本

来源:互联网 发布:2016年上证指数数据 编辑:程序博客网 时间:2024/04/27 12:07
import dpkt,os,sysos.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:passf.close()

原创粉丝点击