How to run scapy python scripts in linux?

98 Views Asked by At

I am new to scapy and need help with this part. So I have already installed the package and I am trying to execute the code below but nothing gets printed to my terminal. I want help understanding what I may be doing wrong

#!/usr/bin/python
from scapy.all import *

def modify_packet_contents_ld(pkt_ld):
    if ICMP in pkt_ld and pkt_ld[IP].src=='10.10.10.10':
        pkt_ld[IP].src,pkt_ld[IP].dst=pkt_ld[IP].dst,pkt_ld[IP].src #REVERSING THE SOURCE AND DESTINATION IP ADDRESSES

        pkt_ld[ICMP].load="hello-world"
        send(pkt_ld)
def sniff_packet_ld():
    sniff(filter='icmp and src host 10.10.10.10', prn=modify_packet_contents_ld, iface='br-xxx')

sniff_packet_ld()
1

There are 1 best solutions below

0
Lardsonian On

You defined two Functions, and there isn't any print statements within those functions you created.

You then called one of them, being sniff_packet_ld(), which did not print anything because you did not put any print statements in those functions.

I'm also not sure how you got this to run in the first place, as ICMP and IP is undefined when I stick your code in my IDE. but maybe I'm just not importing Scapy correctly. Also can you explain what this program is meant to do?

Try adding this to your code:

sniffing = sniff_packet_ld()

print(sniffing)

Storing it in a varible should make it printable, or maybe I'm completely wrong.