在阅读一些CTF写作时,我遇到了这个脚本
#!/usr/bin/env python
import struct
import Image
import dpkt
INIT_X,INIT_Y = 100,400
def print_map(pcap,device):
picture = Image.new("RGB",(1200,500),"white")
pixels = picture.load()
x,y = INIT_X,INIT_Y
for ts,buf in pcap:
device_id,= struct.unpack("b",buf[0x0B])
if device_id != device:
continue
data = struct.unpack("bbbb",buf[-4:])
status = data[0]
x = x + data[1]
y = y + data[2]
if (status == 1):
for i in range(-5,5):
for j in range(-5,5):
pixels[x + i,y + j] = (0,0)
else:
pixels[x,y] = (255,0)
picture.save("riverside-map.png","PNG")
if __name__ == "__main__":
f = open("usb.pcap","rb")
pcap = dpkt.pcap.Reader(f)
print_map(pcap,5)
f.close()
当我在我的usb.pcap上运行它时,我收到此错误:
Traceback (most recent call last):
File "test.py",line 39,in
为什么会这样?
最佳答案
原文链接:https://www.f2er.com/python/438555.html