From 34b5518fa596845b557639fea86a3b59cdff5d2d Mon Sep 17 00:00:00 2001 From: jerome Date: Fri, 20 Jun 2025 14:17:15 +0200 Subject: scapy --- scapy/capture.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scapy/capture.py') diff --git a/scapy/capture.py b/scapy/capture.py index 64393fc..c36b0c0 100644 --- a/scapy/capture.py +++ b/scapy/capture.py @@ -2,6 +2,14 @@ from scapy.all import * # fonction callback def packet_capture(pkt): - print(pkt[IP].src, "->",pkt[IP].dst) + if pkt.haslayer(TCP): + print(pkt[IP].src, "-> TCP",pkt[IP].dst,":",pkt[TCP].dport, pkt[TCP].flags) + elif pkt.haslayer(UDP): + print(pkt[IP].src, "-> UDP",pkt[IP].dst,":",pkt[UDP].dport) + elif pkt.haslayer(ICMP): + print(pkt[IP].src, "-> ICMP",pkt[IP].dst) -sniff(prn=packet_capture, filter="ip", count=10) +try: + sniff(prn=packet_capture, filter="ip", count=50) +except PermissionError: + print(f"{sys.argv[0]} nécessite les droits root") -- cgit v1.2.3