python Scapy的read_packet()报错,有大佬知道为啥么
Traceback (most recent call last):File "E:/work/pycharm/practice/pcap/refactor.py", line 7, in <module>
package = pr.read_packet()
File "E:\work\pycharm\practice\venv\lib\site-packages\scapy\utils.py", line 1349, in read_packet
rp = super(PcapReader, self)._read_packet(size=size)
File "E:\work\pycharm\practice\venv\lib\site-packages\scapy\utils.py", line 1255, in _read_packet
raise EOFError
EOFError
上面是错误信息
下面是源码第7行
from scapy.all import *
filename = "1490个包.pcap"
# 实例化对象
pr = PcapReader(filename)
# 逐包读取
while True:
package = pr.read_packet()
1255行
def _read_packet(self, size=MTU):
# type: (int) -> Tuple[bytes, RawPcapReader.PacketMetadata]
"""return a single packet read from the file as a tuple containing
(pkt_data, pkt_metadata)
raise EOFError when no more packets are available
"""
hdr = self.f.read(16)
if len(hdr) < 16:
raise EOFError
sec, usec, caplen, wirelen = struct.unpack(self.endian + "IIII", hdr)
return (self.f.read(caplen)[:size],
RawPcapReader.PacketMetadata(sec=sec, usec=usec,
wirelen=wirelen, caplen=caplen))