Wireshark 프로그램에서 덤프 된 wireshark.bin 데이터 파일을 읽고 패킷 시간을 선택합니다. 머리글을 건너 뛰고 처음으로 어떻게 찾을 수 있는지 잘 모릅니다.패킷 시간에 대한 Wireshark 덤프 파일 읽기
"""
reads the wireshark.bin data file dumped from the wireshark program
"""
from datetime import datetime
import struct
import datetime
#file = r"V:\workspace\Python3_Homework08\src\wireshark.bin"
file = open("wireshark.bin", "rb")
idList = [ ]
with open("wireshark.bin", "rb") as f:
while True:
bytes_read = file.read(struct.calcsize("=l"))
if not bytes_read:
break
else:
if len(bytes_read) > 3:
idList.append(struct.unpack("=l", bytes_read)[0])
o = struct.unpack("=l111", bytes_read)[0]
print(datetime.date.fromtimestamp(o))
전체 파일을 한 번에 읽으려고하면 오류가 발생합니다. 역 추적 (가장 최근의 호출 마지막) : 파일 "V : \ 작업 \ Python3_Homework08 \ SRC \ wiretimes.py" 데이터 라인 8 = 공개 ("wireshark.bin")) (읽기 파일 "C. : \ 0 \UnicodeDecodeError : 'charmap'코덱이 28 위치의 바이트 0x8d를 디코딩 할 수 없습니다. (예 : \ Python \ lib \ encodings \ cp1252.py), 디코드시 return codecs.charmap_decode (input, self.errors, decoding_table) [0] : 문자가 –
@Python_Maybe : woops, 'rb'- 편집 답변을 잊어 버렸습니다. –
감사합니다. 이제 전체 파일을 읽을 수 있습니다. 패킷 길이를 어떻게 알 수 있습니까? 모든 패킷이 동일한 크기는 아닙니다. –