pynetwork / pypcap

pypcap - python libpcap module, forked from code.google.com/p/pypcap
Other
299 stars 75 forks source link

How can fix this error? Process finished with exit code -1073741819 (0xC0000005) #101

Open tory0820 opened 3 years ago

tory0820 commented 3 years ago

Win10 64bit with python3.7.6 pcap version 1.2.2 Python is ended after getting the first IP address, How to fix this problem?

import dpkt
import pcap
import socket

p = pcap.pcap(name=r'\Device\NPF_{37DD15C3-E221-4D5E-91F6-0CE0A0E548EB}',immediate=True)
print(p.name)
print('start')
for ts,pkt in p:
        print('Timestamp: ', ts)
        if len(pkt)==0:continue
        eth = dpkt.ethernet.Ethernet(pkt)
        print('Ethernet Frame: ', eth, 'Ethernet Type', eth.type)
        if hasattr(eth.data,'src'):
            print(eth.data)
            print(eth.data.src)
            if len(eth.data.src) ==4:
                print(list(eth.data.src))
                print('%d.%d.%d.%d'%tuple(list(eth.data.src)))

while Running in Pycharm I got an error:

C:\Users\mrtro\Anaconda3\python.exe C:/Users/mrtro/Desktop/BeijingTel/pcap_test.py \Device\NPF_{37DD15C3-E221-4D5E-91F6-0CE0A0E548EB} start Timestamp: -1632674327.999501 Ethernet Frame: b'33\x00\x00\x00\x16\xcc-\xb7\xdb\xdf\x9f\x86\xdd\x00\x00\x00\x00$\x00\x01\xfe\x80\x00\x00\x00\x00\x00\x00\x00\xf6KPY{\xc4\x1e\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16:\x00\x01\x00\x05\x02\x00\x00\x8f\x00\x050\x00\x00\x00\x01\x04\x00\x00\x00\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb' Ethernet Type 34525 b'\x00\x00\x00\x00$\x00\x01\xfe\x80\x00\x00\x00\x00\x00\x00\x00\xf6KPY{\xc4\x1e\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16:\x00\x01\x00\x05\x02\x00\x00\x8f\x00\x050\x00\x00\x00\x01\x04\x00\x00\x00\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb' b'\xfe\x80\x00\x00\x00\x00\x00\x00\x00\xf6KPY{\xc4\x1e' Timestamp: -1632674327.999501 Ethernet Frame: b'33\x00\x00\x00\xfb(\x7f\xcf\xcdqR\x86\xdd\x00W!\x00$\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x00$4\xe7\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04wpad\x05local\x00\x00\x01\x00\x01' Ethernet Type 34525 b'\x00W!\x00$\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x00$4\xe7\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04wpad\x05local\x00\x00\x01\x00\x01' b'\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea' Timestamp: -1632674327.999501 Ethernet Frame: b'33\x00\x00\x00\xfb(\x7f\xcf\xcdqR\x86\xdd\x00W!\x00$\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x00$4\xe7\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04wpad\x05local\x00\x00\x01\x00\x01' Ethernet Type 34525 b'\x00W!\x00$\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x00$4\xe7\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04wpad\x05local\x00\x00\x01\x00\x01' b'\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea' Timestamp: -1632674327.999501 Ethernet Frame: b'33\x00\x00\x00\xfb(\x7f\xcf\xcdqR\x86\xdd\x00W!\x00$\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x00$4\xe7\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04wpad\x05local\x00\x00\x01\x00\x01' Ethernet Type 34525 b'\x00W!\x00$\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\x14\xe9\x14\xe9\x00$4\xe7\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04wpad\x05local\x00\x00\x01\x00\x01' b'\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea' Timestamp: -1632674327.999501 Ethernet Frame: b'33\x00\x00\x00\x0c(\x7f\xcf\xcdqR\x86\xdd\x01\xf3\xdd\x02\x94\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\xc2\x05\x0ev\x02\x94\x94\xb4<?xml version="1.0" encoding="utf-8"?><soap:' Ethernet Type 34525 b'\x01\xf3\xdd\x02\x94\x11\x01\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\xc2\x05\x0ev\x02\x94\x94\xb4<?xml version="1.0" encoding="utf-8"?><soap:' b'\xfe\x80\x00\x00\x00\x00\x00\x00\xe1\x8fpUs\xec\xc7\xea' Timestamp: -1632674327.999501 Ethernet Frame: b'33\xff8X\\<\xf0\x11\x02\xa6C\x86\xdd\x00\x00\x00\x00 :\xff\xfe\x80\x00\x00\x00\x00\x00\x00p\xb8\x19\x98)=x\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff8X\\x87\x00\x9d\xa3\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\xae\x16-\xff\xfe8X\\x01\x01<\xf0\x11\x02\xa6C' Ethernet Type 34525 b'`\x00\x00\x00\x00 :\xff\xfe\x80\x00\x00\x00\x00\x00\x00p\xb8\x19\x98)=x\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff8X\\x87\x00\x9d\xa3\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\xae\x16-\xff\xfe8X\\x01\x01<\xf0\x11\x02\xa6C' b'\xfe\x80\x00\x00\x00\x00\x00\x00p\xb8\x19*\x98)=x' Timestamp: -1632674327.999501 Ethernet Frame: b'P\xe0\x85\xdcs<\xe4h\xa3\x8b\x10\x8c\x08\x00E\x00\x00(\x00\x00@\x003\x06\x01\x9a\xdc\xb5&\x95\n\t8\xe3\x01\xbb\xee\xabg6\xe5\x8a\x00\x00\x00\x00P\x04\x00\x00,\x82\x00\x00' Ethernet Type 2048 b'E\x00\x00(\x00\x00@\x003\x06\x01\x9a\xdc\xb5&\x95\n\t8\xe3\x01\xbb\xee\xabg6\xe5\x8a\x00\x00\x00\x00P\x04\x00\x00,\x82\x00\x00' b'\xdc\xb5&\x95' [220, 181, 38, 149] 220.181.38.149

Process finished with exit code -1073741819 (0xC0000005)`

guyharris commented 3 years ago

The list of NT status values says that's STATUS_ACCESS_VIOLATION, which is "The instruction at 0xXXXXXXXX referenced memory at 0xXXXXXXXX. The memory could not be {read, written}."

That translates into UN*Xese as "segmentation violation".

Does that mean that the Python interpreter crashed?

tory0820 commented 3 years ago

The list of NT status values says that's STATUS_ACCESS_VIOLATION, which is "The instruction at 0xXXXXXXXX referenced memory at 0xXXXXXXXX. The memory could not be {read, written}."

That translates into UN*Xese as "segmentation violation".

Does that mean that the Python interpreter crashed?

I guess Python interpreter is crashed. However, when I change print('%d.%d.%d.%d'%tuple(list(eth.data.src))) to print(tuple(list(eth.data.src))), pyhton will not be crashed