在scapy上嗅探(wireshark)使用/不使用python打印ping两次

2024-05-14 03:14:19 发布

您现在位置:Python中文网/ 问答频道 /正文

基本上我有两台机器,一台是Ubuntu,我运行“嗅探”,另一台是Kali,运行“ping”

我无法理解为什么代码会打印两次,如果假定只发送一个包

我只希望打印“Hello World\x00\x00\x00\x00\x00\x00\x00\x00”

为什么会这样?我怎样才能修好它

提前谢谢

Ubuntu

from scapy.all import *

def xyz(pkt):
    #hexdump(pkt)
    if pkt['Raw']:
        print(pkt['Raw'])
sniff(count=10, prn=xyz, filter="icmp")

卡利

import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *

ping = Ether()/IP(dst="10.0.2.4")/ICMP()/Raw()
ping['Raw'].load = 'Hello World'
srp1(ping, timeout=2)

enter image description here


Tags: fromimport机器helloworldrawubuntulogging