diff options
Diffstat (limited to 'scapy/capture.py')
| -rw-r--r-- | scapy/capture.py | 12 |
1 files changed, 10 insertions, 2 deletions
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") |
