无法在python脚本中使用scapy和pyshark捕获发送的数据包

时间:2020-03-09 08:39:18

标签: python scapy pyshark

我正在尝试使用python脚本中的scapy发送数据包,并尝试使用pyshark嗅探另一个python脚本中的数据包。数据包发送正常,但使用pyshark中的capture表示捕获了0个数据包。另外,当我在scapy中使用tshark()并发送数据包时,它在接收端给出了“目标未到达协议-未到达/ IP错误”消息。似乎不明白问题所在。

发送代码:


def sendPacket():
    x=scapy.IP(ttl=64)
    x.src="192.168.0.21"
    x.dst="192.168.0.22"
    scapy.send(x)

def sendNumPackets(num):
    for x in range(num-1):
        x=scapy.IP(ttl=64)
        x.src="192.168.0.21"
        x.dst="192.168.0.22"
        scapy.send(x)       

Pyshark代码:

capture = pyshark.LiveCapture(interface='eth0')
capture.sniff(timeout=50)
capture

0 个答案:

没有答案