Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix issue of dpkt not being able to decode .pcap file

I am having issues running this code on my machine, but it works fine on my schools linux machines.

The error i am getting is:

Traceback (most recent call last):  
File "wireshark_02.py", line 74, in <module>   
    main()  
  File "wireshark_02.py", line 43, in main  
 input_data = dpkt.pcap.Reader(open(file_name,'r'))  
  File "C:\Users\Slava\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dpkt\pcap.py", line 244, in __init__    
    buf = self.__f.read(FileHdr.__hdr_len__)  
  File "C:\Users\Slava\AppData\Local\Programs\Python\Python36- 
 32\lib\encodings\cp1252.py", line 23, in decode    
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]   
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position
125: character maps to <undefined>    

I've installed dpkt running pip install dpkt.

Is there anything i can do to make this work on my machine or do i need to use my schools computers?

like image 304
Slava A. Avatar asked Nov 07 '22 08:11

Slava A.


1 Answers

open(file_name, 'rb')

worked for me!

like image 61
karthik kulkarni Avatar answered Nov 16 '22 19:11

karthik kulkarni