Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "--------------------------------------------------"
- echo " Wireless Tool - by Davidson Francis "
- echo "--------------------------------------------------"
- echo ""
- echo "Configurar ou conectar (1:configurar/2:conectar):"
- read OPT
- function listar_redes()
- {
- ERR=$(iwlist wlan0 scan 2>&1)
- if [ "$ERR" == "wlan0 Interface doesn't support scanning." ]; then
- echo "ERRO: Nao foi possivel listar as redes"
- else
- echo "Como geralmente e grande, gravei no arquivo redes.txt"
- echo $ERR
- fi
- }
- function configurar()
- {
- echo "Deseja verificar as redes disponiveis (S:N)?"
- read RESP
- if test $RESP == "S"
- then
- listar_redes
- fi
- ERR=$(ifconfig wlan0 up 2>&1)
- if test ${#ERR} -gt 0
- then
- echo "ERRO, verifique se seu adaptador wireless e reconhecido pelo sistema"
- else
- echo "---------------------"
- echo "Nome da rede (SSID):"
- read SSID
- echo "Senha rede:"
- read PASSWD
- while test ${#PASSWD} -lt 8
- do
- echo "Senha pequena, digite pelo menos 8 caracteres:"
- read PASSWD
- done
- echo ""
- echo "Configurando..."
- wpa_passphrase $SSID $PASSWD >> /etc/wpa_supplicant.conf
- echo "Deseja se conectar de uma vez? (S/N):"
- read RESP
- if test $RESP == "S"
- then
- wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B -D wext >> /dev/null
- ERR=$(tail <(dhclient wlan0 2>&1) -n 1)
- if [ "$ERR" == "wlan0: ERROR while getting interface flags: No such device" ]; then
- echo "ERRO: A conexao nao pode ser estabelecida, tente novamente mais tarde,kkkk"
- fi
- fi
- fi
- }
- function conectar()
- {
- wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B -D wext >> /dev/null
- ERR=$(tail <(dhclient wlan0 2>&1) -n 1)
- if [ "$ERR" == "wlan0: ERROR while getting interface flags: No such device" ]; then
- echo "ERRO: A conexao nao pode ser estabelecida, tente novamente mais tarde,kkkk"
- fi
- }
- if test `whoami` == "root"
- then
- if test $OPT -eq 1
- then
- echo ""
- configurar
- else if test $OPT -eq 2
- then
- conectar
- fi
- fi
- else
- echo "Preciso dos super poderes do pinguim pra funcionar, :D"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement