Script de Conexion y otras opciones
De Seguridad Wireless
Contenido |
Script de Conexion y otras opciones
El link al archivo
| Link: |
Unas Imagenes
EL MENÚ
EL MENÚ AYUDA
LOS CRÉDITOS
Y el código entero (380 líneas)
#!/bin/sh
#SCRIPT CREADO POR hadrianweb Y tufonera.com
#Variables
interface=ath0 #Interfaz que vamos a utilizar para conectarnos
#DECLARANDO LAS FUNCIONES
inicio ()
{
clear
unset n
cat <<INICIO
**********hadrianweb***********
===============================
|| Análisis del modo cliente ||
===============================
- - - - - - - - - - - - - - - -
|Escoge una opción y pulsa enter|
- - - - - - - - - - - - - - - -
[1] Conectar (WEP)
[2] Comprobar conexión
[3] Reconectar (previo uso de [1])
[4] Escanear redes
[5] Ayuda
[6] Salir
INICIO
read n
if [ $n -eq 1 ]; then
conectar_wep
elif [ $n -eq 2 ]; then
comprobar_conexion
elif [ $n -eq 3 ]; then
reconectar
elif [ $n -eq 4 ]; then
escanear
elif [ $n -eq 5 ]; then
ayuda
elif [ $n -eq 6 ]; then
salir
fi
}
##FUNCIÓN AYUDA
ayuda ()
{
clear
unset volver_ayuda
cat <<AYUDA
======================
| Conectar WEP |
======================
Nos pedirá el ESSID si la red tiene clave o no, las ip´s y dns.
======================
| Comprobar Conexión |
======================
Hace ping a google, y si de cada 6 falla mas de 3 dice "No conectado.
======================
| Reconectar |
======================
Con esta función lo que hacemos es utilizar el modo cliente
con las opcions de configuración del método uno, es decir las
que introducimos con anterioridad.
======================
| Escanear Redes |
======================
Escanea las redes disponibles y la calidad de la señal
======================
| Ayuda |
======================
Muestra este menú.
- - - - - - - - - - - - - - - -
|Escoge una opción y pulsa enter|
- - - - - - - - - - - - - - - -
[1] Volver Atrás (al menú principal)
AYUDA
read volver_ayuda
if [ $volver_ayuda -eq 1 ]; then
inicio
fi
}
##FUNCIÓN CONECTAR (WEP)
conectar_wep ()
{
clear
cat <<CONECTAR_WEP
**********hadrianweb***********
===============================
|| Introducción de Datos ||
===============================
[-]Nombre del ESSID
CONECTAR_WEP
read essid
cat <<CONECTAR_WEP
[-]¿La red tiene clave? (1=Si/2=No)
CONECTAR_WEP
read opcion_clave
if [ $opcion_clave -eq 1 ]; then
cat <<CONECTAR_WEP
[-]Clave en Hexadecimal (Ej. 31:32:33:34:35)
CONECTAR_WEP
read clave
fi
cat <<CONECTAR_WEP
[-]Canal
CONECTAR_WEP
read canal
cat <<CONECTAR_WEP
[-]Puerta de enlace (Ej. 192.168.1.1)
CONECTAR_WEP
read puerta_enlace
cat <<CONECTAR_WEP
[-]Ip para el modo cliente (Ej. 192.168.1.35)
CONECTAR_WEP
read ip_cliente
cat <<CONECTAR_WEP
[-]DNS 1(Ej. 80.58.0.33)
CONECTAR_WEP
read dns1
cat <<CONECTAR_WEP
[-]DNS 2 (Ej. 80.58.0.97)
CONECTAR_WEP
read dns2
clear
cat <<CONECTAR_WEP
**********hadrianweb***********
===============================
|| Intentando Conectar ||
===============================
[-]Apagando firewall
CONECTAR_WEP
/etc/init.d/firewall stop
cat <<CONECTAR_WEP
[-]Creando interfaz ($interface)
CONECTAR_WEP
wlanconfig $interface destroy
wlanconfig $interface create wlandev wifi0 wlanmode managed
cat <<CONECTAR_WEP
[-]Asociandonos al Punto de acceso inalámbrico
CONECTAR_WEP
ifconfig $interface up
iwconfig $interface essid $essid channel $canal
if [ $opcion_clave -eq 1 ]; then
iwconfig $interface key $clave
fi
ifconfig $interface $ip_cliente
route add default gw $puerta_enlace $interface
cat <<CONECTAR_WEP
[-]Configurando DNS
CONECTAR_WEP
echo nameserver $dns1 > /etc/resolv.conf
echo nameserver $dns2 >> /etc/resolv.conf
cat <<CONECTAR_WEP
[-]Configurando iptables (dando acceso por cable)
CONECTAR_WEP
iptables -t nat -A POSTROUTING -o $interface -j MASQUERADE
iptables -A OUTPUT -o eth0 -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
cat <<CONECTAR_WEP
[-]Conexión completada
CONECTAR_WEP
sleep 2
inicio
}
##FUNCIÓN RECONECTAR
reconectar ()
{
cat <<RECONECTAR
**********hadrianweb***********
===============================
|| Intentando Conectar ||
===============================
[-]Apagando firewall
RECONECTAR
/etc/init.d/firewall stop
cat <<RECONECTAR
[-]Creando interfaz ($interface)
RECONECTAR
wlanconfig $interface destroy
wlanconfig $interface create wlandev wifi0 wlanmode managed
cat <<RECONECTAR
[-]Asociandonos al Punto de acceso inalámbrico
RECONECTAR
ifconfig $interface up
iwconfig $interface essid $essid channel $canal
if [ $opcion_clave -eq Si || $opcion_clave -eq si || $opcion_clave -eq y || $opcion_clave -eq yes]; then
iwconfig $interface key $clave
fi
ifconfig $interface $ip_cliente
route add default gw $puerta_enlace $interface
cat <<RECONECTAR
[-]Configurando DNS
RECONECTAR
echo nameserver $dns1 > /etc/resolv.conf
echo nameserver $dns2 >> /etc/resolv.conf
cat <<RECONECTAR
[-]Configurando iptables (dando acceso por cable)"
RECONECTAR
iptables -t nat -A POSTROUTING -o $interface -j MASQUERADE
iptables -A OUTPUT -o eth0 -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
cat <<RECONECTAR
[-]Conexión completada
RECONECTAR
inicio
}
##FUNCIÓN COMPROBAR CONEXIÓN
comprobar_conexion ()
{
cat <<COMPROBAR_CONEXION
**********hadrianweb***********
===============================
|| PING A GOOGLE ||
===============================
COMPROBAR_CONEXION
n=1
while true
do
unset $volver_comprobar_conexion
tping=3
var=$(ping -c 6 -q google.com | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}')
if [ "$var" -ge "$tping" ]; then
echo $n Conectado
n=`expr $n + 1`
else
echo "No Conectado"
n=1
fi
cat <<COMPROBAR_CONEXION
[-]¿Deseas volver atrás (al menu principal)? (1=SI/2=No)
Si seleccionas No, se repetirá la comprobación de la conexión
COMPROBAR_CONEXION
read volver_comprobar_conexion
if [ $volver_comprobar_conexion -eq 1 ]; then
break
fi
done
clear
inicio
}
##FUNCION SALIR
salir ()
{
cat <<SALIR
=====================================
| GRACIAS POR UTILIZAR ESTE PROGRAMA |
| AUTOR: hadrianweb |
| WEB: tufonera.com |
=====================================
SALIR
sleep 5
exit
}
##ESCANEAR REDES
escanear ()
{
clear
unset repetir_escaneo
cat <<ESCANEAR
**********hadrianweb***********
===============================
|| Escanear ||
===============================
[-]Nombres de las Redes
ESCANEAR
iwlist $interface scan | grep "ESSID"
cat <<ESCANEAR
[-]Calidad de estas redes, en el mismo orden
ESCANEAR
iwlist $interface scan | grep "Quality"
cat <<ESCANEAR
[-]¿Desea repetir el escaneo? (1=Si/2=No)
ESCANEAR
read repetir_escaneo
if [ $repetir_escaneo -eq 1 ]; then
clear
escanear
elif [ $repetir_escaneo -eq 2 ]; then
inicio
fi
}
#INICIO DEL SCRIPT
inicio