class ListenHTTP(threading.Thread): def __init__(self): super(ListenHTTP, self).__init__() self.assembler = IPReassembler() def run(self): print("start of listen HTTP") s = BlockingSniffer("en0", read_timeout=5000, snapshot_length=65000) s.filter = "tcp and port 3128" #s.sniff_and_store(queue) s.sniff_callback(self.callbackHTTP) def callbackHTTP(self, sec, usec, caplen, length, mview): ethernet_pdu = self.assembler.feed(EthernetII.from_buffer(mview)) if ethernet_pdu is not None: ip = ethernet_pdu.rfind_pdu(IP) if ip is not None: #print(ip.src_addr, ip.dst_addr) raw = ip.rfind_pdu(RAW) if raw: #print ("total", raw.size) if raw.size < 10: #print('payload', type(ip.ref_inner_pdu()), raw.payload) pass
def __init__(self): super(ListenHTTP, self).__init__() self.assembler = IPReassembler()