blob: dc0e5a69b0e5778283311ce6446e6e3098c32031 (
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("Ce script nécessite les droits root")
|