blob: c36b0c0b972f6d235cbbd087303954ea98056ef4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from scapy.all import *
# fonction callback
def packet_capture(pkt):
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)
try:
sniff(prn=packet_capture, filter="ip", count=50)
except PermissionError:
print(f"{sys.argv[0]} nécessite les droits root")
|