
Originally Posted by
DHCP-Tom
Error:
-bash: ./wpa.sh: /usr/bin/bash^M: bad interpreter: No such file or directory
I'm not sure where that's coming from. Try copying the script over again. Or, you can test out the new version for me.
Code:
#!/usr/bin/bash
#wpa_connect script for BT2 by Hobz of #remote-exploit
#April 2, 2007
#
#
#CHANGE LOG
#
#Modified April 22 by Hobz
#added pingcheck function using ping -f flag
###
INT=$1
ESSID=$2
if [ $1 = "P" ]; then
pingcheck
exit
fi
if [ -z "$2" ]; then
printf "Usage: $0 [interface] [ESSID] <P>\n"
printf "$0 will create a /etc/wpa_supplicant.conf file if none exists\n"
printf "Default driver: wext\n"
printf "Optional: use 'P' to check signal, one dot '.' = one dropped packet\n"
printf "More dots means worse signal."
exit
fi
function connect {
ifconfig $INT down
iwconfig $INT mode managed essid "$ESSID"
printf "* - Configured interface\n"
ifconfig $INT up
printf "* - Interface up\n"
wpa_supplicant -B -Dwext -i$INT -c/etc/wpa_supplicant.conf
printf "* - wpa_supplicant running, sleeping for 10...\n"
sleep 10
printf "* - Running dhcpcd\n"
dhcpcd $INT
ifconfig $INT | grep inet
}
function conf_create {
printf "What is your passphrase?\n"
read "PASSPHRASE"
printf "* - running wpa_passphrase\n"
wpa_passphrase "$ESSID" "$PASSPHRASE" > /etc/wpa_supplicant.conf
printf "* - done. Starting to connect...\n"
}
function pingcheck {
echo "Enter host to ping, or press Enter to use default gateway: "
read "HOST"
if [ -z "$HOST" ]; then
route | grep "default" | awk '{ system("ping -w 10 -f " $2) }'
else
ping -w 10 -f $HOST
fi
}
if [ -f /etc/wpa_supplicant.conf ]; then
connect
if [ "$3" = "P" ]; then
pingcheck
fi
else
conf_create
connect
if [ "$3" = "P" ]; then
pingcheck
fi
fi