Esempio n. 1
0
def dump():
    hpcap = pcap.pcap_open_dead(ptypes.LINKTYPE_ETHERNET, 65535)
    pdumper = pcap.pcap_dump_open(hpcap, './test.pcap')

    data = b'11111111111111111111111111111111111111111111'
    pkthdr = ptypes.pcap_pkthdr()
    pkthdr.caplen = len(data)
    pkthdr.len = len(data)
    now = time.time()
    pkthdr.ts.tv_sec = int(now)
    pkthdr.ts.tv_usec = int(now * 1000 * 1000) % (1000 * 1000)
    pcap.pcap_dump(pdumper, ptypes.pcap_pkthdr_p(pkthdr), data)

    pcap.pcap_dump_flush(pdumper)
    pcap.pcap_dump_close(pdumper)
    pcap.pcap_close(hpcap)
Esempio n. 2
0
def dump():
    hpcap = pcap.pcap_open_dead(ptypes.LINKTYPE_ETHERNET, 65535)
    pdumper = pcap.pcap_dump_open(hpcap, './test.pcap')
    
    data = b'11111111111111111111111111111111111111111111'
    pkthdr = ptypes.pcap_pkthdr()
    pkthdr.caplen = len(data)
    pkthdr.len = len(data)
    now = time.time()
    pkthdr.ts.tv_sec = int(now)
    pkthdr.ts.tv_usec = int(now * 1000 * 1000)%(1000*1000)
    pcap.pcap_dump(pdumper, ptypes.pcap_pkthdr_p(pkthdr), data)
    
    pcap.pcap_dump_flush(pdumper)
    pcap.pcap_dump_close(pdumper)
    pcap.pcap_close(hpcap)
Esempio n. 3
0
 def setUpClass(cls): 
     #cls.hpcap = pcap.pcap_open_live(device, 65535, True, 0)
     cls.hpcap = pcap.pcap_open_dead(ptypes.LINKTYPE_ETHERNET, 65535)
     cls.pdumper = pcap.pcap_dump_open(cls.hpcap, './test.pcap')
Esempio n. 4
0
 def setUpClass(cls):
     #cls.hpcap = pcap.pcap_open_live(device, 65535, True, 0)
     cls.hpcap = pcap.pcap_open_dead(ptypes.LINKTYPE_ETHERNET, 65535)
     cls.pdumper = pcap.pcap_dump_open(cls.hpcap, './test.pcap')