diff options
| author | jerome <jerome@xlinfo.fr> | 2024-09-17 15:32:53 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2024-09-17 15:32:53 +0200 |
| commit | 550497e907868ac0249a18eef2a0fb7f5bcd9ed8 (patch) | |
| tree | 5690fce051444c9897a2bcf610d174b20dfe6718 /scapy | |
| parent | cdb4e2f17863038e28ab063415f59cc4d94491d6 (diff) | |
| download | python-550497e907868ac0249a18eef2a0fb7f5bcd9ed8.tar.gz python-550497e907868ac0249a18eef2a0fb7f5bcd9ed8.zip | |
scapy
Diffstat (limited to 'scapy')
| -rw-r--r-- | scapy/arping.py | 11 | ||||
| -rw-r--r-- | scapy/capture.py | 7 | ||||
| -rw-r--r-- | scapy/ping.py | 12 |
3 files changed, 30 insertions, 0 deletions
diff --git a/scapy/arping.py b/scapy/arping.py new file mode 100644 index 0000000..7b25eb2 --- /dev/null +++ b/scapy/arping.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +from scapy.all import * + +# Le réseau à scanner +network = "192.168.2.0/24" + +# Scanne le réseau et affiche le résultat +ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=network), timeout=5, verbose=0) +for snd, rcv in ans: + print(rcv.sprintf(r"%Ether.src% - %ARP.psrc%")) diff --git a/scapy/capture.py b/scapy/capture.py new file mode 100644 index 0000000..64393fc --- /dev/null +++ b/scapy/capture.py @@ -0,0 +1,7 @@ +from scapy.all import * + +# fonction callback +def packet_capture(pkt): + print(pkt[IP].src, "->",pkt[IP].dst) + +sniff(prn=packet_capture, filter="ip", count=10) diff --git a/scapy/ping.py b/scapy/ping.py new file mode 100644 index 0000000..4d1aa66 --- /dev/null +++ b/scapy/ping.py @@ -0,0 +1,12 @@ +#!/usr/bin/python +from scapy.all import * + +conf.verb = 0 +for ip in range(100, 255): + #packet = IP(dst="192.168.2." + str(ip), ttl=20)/ICMP() + #on peut aussi en profiter pour envoyer un flag (ctf) + MESSAGE = "code=01234" + packet = IP(dst="192.168.2." + str(ip), ttl=20)/ICMP()/MESSAGE + reply = sr1(packet, timeout=1) + if not (reply is None): + print(reply.src, "is online") |
