Last active
August 19, 2024 21:30
-
-
Save SoftPoison/76f7077e73dd1ec701753e97dac45bb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OUT_FILE="wifi_testing_$(date '+%Y-%m-%d_%H-%M-%S').pcap" | |
DWELL_TIME="1" | |
set -e | |
echo "[*] Enumerating devices" | |
readarray -t devices < <(iw dev | grep 'Interface' | awk '{print $2}' | sort) | |
num_devices=${#devices[@]} | |
if [ $num_devices -eq 0 ]; then | |
echo "[!] No devices detected" | |
exit 1 | |
elif [ $num_devices -eq 1 ]; then | |
device="${devices[0]}" | |
else | |
echo "[!] More than one device detected" | |
echo "[*] Select the device you want to use" | |
echo | |
echo "Devices:" | |
for (( i=0; i<$num_devices; i++)); do | |
echo "$((i+1)). ${devices[$i]}" | |
done | |
echo | |
while true; do | |
read -p "Device number: " dev_num | |
if [ $dev_num -gt 0 ] && [ $dev_num -le $num_devices ]; then | |
break | |
fi | |
echo "Invalid input" | |
done | |
device="${devices[$((dev_num-1))]}" | |
fi | |
echo "[*] Using $device. Getting config" | |
phy_num=$(iw dev wlan0 info | grep wiphy | awk '{print $2}') | |
phy="phy${phy_num}" | |
readarray -t channels < <(iw phy "$phy" channels | grep '*' | grep -v 'disabled' | awk -F'[' '{print $2}' | tr -d ']') | |
# This shouldn't actually be needed | |
echo "[!] Disabling system services. you won't have internet!" | |
sudo systemctl stop NetworkManager | |
sudo systemctl stop wpa_supplicant | |
echo "[*] Enabling monitor mode" | |
sudo ip link set "$device" down | |
sudo iw dev "$device" set type monitor | |
sudo ip link set "$device" up | |
echo "[*] Starting scanning" | |
tshark -w "$OUT_FILE" -i "$device" &>/dev/null & | |
for channel in ${channels[@]}; do | |
echo "[*] Scanning channel $channel" | |
sudo iw dev "$device" set channel "$channel" | |
sleep "$DWELL_TIME" | |
done | |
kill %1 | |
echo "[*] Done! Check $OUT_FILE" | |
sudo ip link set "$device" down | |
sudo iw dev "$device" set type managed | |
sudo ip link set "$device" up | |
sudo systemctl start NetworkManager | |
sudo systemctl start wpa_supplicant | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment