Don't get answer to ICMP packet from scapy

23 Views Asked by At

I'm trying multiple things to send the ICMP packet and get the answer on Fedora with Scapy:

this is my testing code:

import sys, os
from scapy.all import *

id = os.getpid() & 0xFFFF

packet = IP(src="192.168.0.106", dst="192.168.0.106")/ICMP(type="echo-request", id=id)
print("ID: %s" % id)
print(packet)
show_interfaces()

ans, unans = srp(packet, timeout=2, verbose=2, iface="wlp3s0")
for sent in unans:
    print(sent)

This code contains an attempt to fix the issue using ChatGPT and other answers on SO answers.

This is the output of the code:

ID: 48794
IP / ICMP 192.168.0.106 > 192.168.0.106 echo-request 0
Source  Index  Name     MAC                IPv4           IPv6                    
sys     1      lo       00:00:00:00:00:00  127.0.0.1      ::1                     
sys     2      enp2s0   Dell:1e:d8:e8                                             
sys     3      wlp3s0   HonHaiPr:a4:92:85  192.168.0.106  fe80::ac07:d2c:d086:f4d3
sys     4      docker0  02:42:24:eb:24:a6  172.17.0.1                             
Begin emission:
Finished sending 1 packets.
..............................................................................................................................................................................................................................................................
Received 254 packets, got 0 answers, remaining 1 packets
IP / ICMP 192.168.0.106 > 192.168.0.106 echo-request 0

The code runs with sudo.

I think that I don't even get the packet send to the right Interface.

ChatGPT suggested to run tcpdump:

sudo tcpdump -i wlp3s0 icmp

But I don't see my packet.

Note that normal ping works. And I don't think that I have any firewall, at least I'm not aware of any, unless it's installed by defalt.

0

There are 0 best solutions below