python:how to use DPKT remove duplicate data from pcap files -


i want stitch http persistent connection body pcap files,but contains some
duplicates body data,how remove these data?

my codes part1part2

the following codes:

from mydpkt import request mydpkt import reader, ethernet  rh_log = open('e:\\rh.pcap','rb') rh_file = reader(rh_log) # p.setfilter('tcp port 80') expect_request_switch = false expect_respone_switch = false body_lenth = 0 keep_alive_index = 0 body_persistent = '' body_all = [] index = 0 index, (ptime, pdata) in enumerate(rh_file).__iter__():     p = ethernet(pdata)     ip = p.data     if ip.__class__.__name__ == 'ip':         dst_ip = '%d.%d.%d.%d' % tuple(map(ord, list(ip.dst)))         src_ip = '%d.%d.%d.%d' % tuple(map(ord, list(ip.src)))         tcp = ip.data         # dport = tcp.dport         if tcp.__class__.__name__ == 'tcp' , len(tcp.data) > 1:             dport = tcp.dport             sport = tcp.sport             received_string = str(tcp.data)             if expect_request_switch , expect_respone_switch , 'http/1.1 200 ok' in received_string:        expect_request_switch = expect_respone_switch = false             if expect_request_switch:                 if 'http/1.1 100 continue' in tcp.data:                     keep_alive_index = index                     expect_respone_switch = true                 if (index >= (keep_alive_index + 1)) , expect_respone_switch , dport == 80:                     body_persistent += received_string                     body_persistent_lenth = len(body_persistent)                     body_all.append(body_persistent)                     expect_request_switch = false                     expect_respone_switch = false 

body_persistent = ''

            if dport == 80 , expect_respone_switch false: 


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -