简体   繁体   English

在python 2.7中使用scapy

[英]Using scapy with python 2.7

I am trying to do a graphical representation of packets using scapy,python-2.7 and some graph module (which i haven't thought of yet). 我正在尝试使用scapy,python-2.7和一些图形模块(我还没有想到)对数据包进行图形化表示。 Basically, I want to read the types of data packets from a pcap file using scapy, parse it and in turn simulate a graph. 基本上,我想使用scapy从pcap文件中读取数据包的类型,对其进行解析,然后依次模拟图形。

I have written the following code to just check how rdpcap works: 我编写了以下代码,只是检查rdpcap的工作方式:

**from scapy.utils import rdpcap
packets = rdpcap("/Packet_Inspection/Sample_2.pcap000")
print packets**

And i keep getting the following error: 而且我不断收到以下错误:

**Traceback (most recent call last):
 >> File "test1.py", line 8, in <module>
    packets = rdpcap("/Packet_Inspection/Sample_2.pcap000")
 >>File "C:\python27\lib\site-packages\scapy\utils.py", line 559, in rdpcap
    return fdesc.read_all(count=count)
  >>File "C:\python27\lib\site-packages\scapy\utils.py", line 729, in read_all
    res = RawPcapReader.read_all(self, count)
  >>File "C:\python27\lib\site-packages\scapy\utils.py", line 680, in read_all
    p = self.read_packet()
  >>File "C:\python27\lib\site-packages\scapy\utils.py", line 725, in read_packet
    p = conf.raw_layer(s)
>>TypeError: 'NoneType' object is not callable**

Please help me here. 请在这里帮助我。

multiple things could be going wrong here. 这里可能有很多问题。

does /Packet_Inspection/Sample_2.pcap000 really exist at the root? /Packet_Inspection/Sample_2.pcap000真正存在于根目录吗?

are there packets in the pcap? pcap中有数据包吗?

also, rdpcap returns a python array of scapy Packet objects. 同样, rdpcap返回一个scapy Packet对象的python数组。 you could try printing a single instance with print packets[0] 您可以尝试使用print packets[0]打印单个实例print packets[0]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM