Skip to content

Instantly share code, notes, and snippets.

@r4ulcl
Created April 25, 2018 21:07
Show Gist options
  • Save r4ulcl/3070253835c2d70c34c31807042754dc to your computer and use it in GitHub Desktop.
Save r4ulcl/3070253835c2d70c34c31807042754dc to your computer and use it in GitHub Desktop.
Inicia captura automaticamente en la interfaz con mac X
#!/bin/bash
#!/bin/bash
### BEGIN INIT INFO
# Provides: Raul Calvo
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Inicia captura automaticamente en la interfaz con mac x
# Description:
#
### END INIT INFO
#mac a buscar
macBuscar=#mac
aux=1 #aux modo boolean para el bucle, si encuentra la interfaz se pone a cero y acaba el bucle
CONTADOR=0 #contador para las interfaces empezando por wlan0
while [ $aux -eq 1 ] && [ $CONTADOR -lt 5 ] ; do #mientras no lo haya encontrado y la interfaz wlan sea menor que wlan5
mac=$(ip link show wlan$CONTADOR| grep 'link/ether' | sed 's/^[ \t]*//' | cut -f2 -d" ") #obtenemos la mac de la interfaz
if [ "$mac" == "$macBuscar" ] #si es la mac que buscamos ponemos aux a cero para acabar el bucle
then
aux=0
else #si no sumamos 1 al contador
CONTADOR=$((CONTADOR + 1))
fi
done
if [ $aux -eq 0 ] # si ha acabado el bucle porque ha encontrado la mac buscada iniciamos airmon y airodump junto con el gpsd
then
sudo killall gpsd ; sudo service gpsd stop ; adb devices ; adb forward tcp:20175 tcp:50000 ; gpsd -b tcp://localhost:20175
sudo airmon-ng start wlan$CONTADOR
while :
do
screen -d -m sudo airodump-ng wlan${CONTADOR}mon --write-interval 10 --berlin 60 --gpsd --wps -w airmon
sleep 5400 #duerme 90 minutos y cierra la captura y vuelve a iniciar
for session in $(screen -ls | grep -o '[0-9]\{5\}')
do
screen -S "${session}" -X quit;
done
done
echo wlan$CONTADOR
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment