I am writing a program that involves scapy and I am trying to sniff all the packets and search a specific keyword in each packet (like "TCP")
Here is the code that sniffs all the packets:
def pkt_callback(pkt):
pkt.show()
sniff(iface = 'eth0', prn = lambda x : x.show())
And here's the code trying to present only tcp packets
from scapy.all import *
global my_raw
my_raw = "tcp"
def pkt_callback(pkt):
global my_raw
if my_raw in pkt:
pkt.show()
sniff(iface='eth0', filter="", prn=lambda x: x.show())
print sniff
prn=pkt_callback
? – Yoel