Attacking Wi-Fi Networks
Attacking Wi-Fi Networks
Now we are going to see how you can exploit vulnerabilities of Wi-Fi security protocols and gain access to protected wireless networks.
WEP
Given the low security level provided by the WEP encryption scheme, less and less networks are configured to use it.
Still, it's useful to know how to deal with them as corporations or individuals could still be using this configuration for various compatibility reasons.
The main flaws of WEP encryption are:
Weak authentication scheme
Short Initialization Vector (IV) and subsequent frequent reuse
vulnerable to replay attacks
Weak frame integrity protection
Low resistance to related key attacks enabling efficient statistical attacks
The key of all attacks directed against WEP key recovery is getting a sufficient amount of encrypted packets to be able to successfully execute the statistical attacks.
In a medium-sized network, the actual traffic between legitimate clients could be enough to gather the required encrypted data very quickly but this will not always be the case.
Setup your environment with the following guidelines:
Access Point SSID: LabNetwork
Use WEP Encryption
Set WEP key size to 40bit and choso your key (10 hexadecimal characters)
1 vicitim STA (associated to Lab Network), this shouldn't be the same device you will use for the attack!
The attacker machine
Have a note of your AP channel as you'll need it later.
1. Start airmon-ng
and airodump-ng
airmon-ng
and airodump-ng
airodump-ng
will start scanning. As you can see LabNetwork
is listed in the command output with the encryption correctly identified as WEP.
We can also see our victim client associated stations section.
#Data
column indicates the number of data frames collected thus far on a particular network while#/s
displays the data frames capture rate as frames per second.You do want high values for these columns in order to succeed.
2. Deauthentication attack: Increment packet rate
If LabNetwork
does not produce a lot of traffic, we might need to have a way to increment the packet rate.
When deauthenticated from a wireless network, normally a client will try to re-authenticate shortly later (just as the IEEE 802.11 standard specifies a management frame for this purpose, this is sent completely unencrypted and requires no authentication from the sender).
deauth frames aren't encrypted. They are not useful per se to increase the number of collected IVs.
On the other hand, after re-associating a client, the client will most certainly send some gratuitous ARP or DHCP messages and this traffic is clearly valuable as it's sent encrypted.
To deauthenticate a client:
This will increase the number of data frames.
Deauthentication attacks force the victim to actually disconnect from the network. If you abuse this techniques, chances are that your attack will be noticed! So keep this is in mind when pentesting a real-world wireless network.
2.1 ARP Replay Attack
ARP replay is the most effective way to generate new IVs. Once you sniff an ARP request generated by a STA, you can re-inject that packet due to WEP's lack of message replay countermeasures.
As it's a broadcast message, the AP will forward the request to the associated STAs and each of these request will contain a new IV for you to collect.
The ARP replay attack is a bit more complicated than simple deauthentication. As such, it will be useful to get an overview of the attack before diving into it.
Steps of an ARP Replay attack:
Stations normally communicate with the AP while the attacker machine is not yet operating.
aireplay-ng -1 15 -a <bssid> -e <ssid> <interface>
. This will associate your adapter to the specified network. You have to provide both the BSSID and SSID. The-1
stands for fake authentication, while the number on the right is the delay between authentication attempts. When successful, you should see something likeAssociation successful
The attacking machine associates itself with the AP, with Open Authentication system, this is only a matter of exchanging 4 frames without providing any credentials. In the
aircrack-ng
terminology, this is called fake authentication.During the real attack, you can find that your adapter constantly receives deauthentication messages from the victim AP. You can try this variation for "picky APs":
aireplay-ng -1 6000 -1 10 -o 1 -a <bssid> -e <ssid> <interface>
-q 10
enables keep-alive packets. This command causes this packets to be sent every 10 seconds to maintain the authentication status. The long re-authentication time permits these packets to be sent.-o 1
forcesaireplay-ng
to send one set of packets at a time, these can be necessary as some APs can get confused by aireplay-ng's default behavior.Do not close opened terminal windows as
aireplay-ng
will need to continue running while performing the attack.
Once the attacker is associated, the attacker starts to passively scan for ARP request, listen for broadcasted ARP request frames.
Now we need to listen for ARP requests sent by clients on the network. Obviously this will not work if your STA is the only associated one.
aireplay-ng -3 -b <bssid> <interface>
After a while, STA1 sends an ARP request to all of the nodes in the network, and the AP forwards it and the attacker is thus able to capture the frame.
After a few minutes you should capture at least an ARP request.
At this point, the attacker can flood the network by re-injecting the same ARP frame over and over. Simply put: the attacker floods the AP with ARP requests.
Almost instantly
aireplay-ng
will start to re-inject the captured ARP request.
Following the protocol, the AP simply forwards each received ARP using a new IV every time.
airodump-ng will show the increase in received frames as you are flooding the AP.
By collecting all of these frames, the attacker can then mount one of the statistical attacks.
3. Cracking the key with aircrack-ng
aircrack-ng
is a software that encapsulates a series of cracking techniques for both WEP and WPA network keys.
This command needs packets in order to crack the WEP key. The minimum amount of packets depend on the key length.
As you do not know they key length of the attack, a good strategy is first trying with 64 bits.
If that fails for more than 10000 IVs, just try again with a key of 128 bits.
Now aircrack-ng
will start reading all of the IVs from the specified files then the cracking process will begin. If the number of IVs isn't sufficient, aircrack-ng
will just wait for airodump-ng
to get more so you do not need to restart the command.
WPA and WPA2
Steps of the 4-way handshake
Step 0
At first the shared passphrase is used to generate the so-called PMK (Pairwise Master Key), which is 256bits long.
Both the STA and AP independently calculate this value combining the PSK and SSID name.
Step 1/4
When the handshake starts, the AP sends the STA a message containing a nonce
, a security cryptographic random number. In the WPA specification, this number is called Anonce
(as Authenticator Nonce).
Step 2/4
STA generates another nonce, called SNonce
(Supplicant Nonce), and builds the PTK containing the PMK, both nonces, the MAC addresses of AP and STA and processing this product through a cryptographic hash function called PBKDF2-SAH1
.
Step 3/4
STA then sends its SNonce
to the AP that can now build the PTK. As it uses the same information, both PTKs will be the same without the original PSK ever being transmitted over the air. This third message also contains a MIC (Message Integrity Code) which is used to authenticate the sending STA.
Step 4/4
Finally, the AP replies back with a message containing the GTK (Group Temporal Key) used to decrypt multicast and broadcast traffic. This message is also authenticated by means of MIC. An acknowledgment concludes the process.
Perform an attack
Capturing the Handshake
Setup LAB
AP SSID: LabNetwork, channel 11, WPA enabled.
1 vicitim STA associated to the AP
The attacker PC
Capturing the handshake is actually quite simple. Launch airodump-ng
and start sniffing on the correct channel:
If we wanted to perform a totally passive attack, we could have waited for a new client to join the network but this could require more time.
Write down the client MAC address and launch the deauth attack against it:
If the victim STA is inside the reachable area of your wireless card, it will be forced to rejoin the network and you should be able to get a new 4-way handshake (airodump-ng
notifies when the handshake reception happens).
Now that we have captured the handshake and it is stored into a file, it's time to crack it!
Use aircrack-ng against the handshake
aircrack-ng
has two cracking options when it comes to WPA/WPA2 keys:
Dictionary Attack (also available for WEP)
Pure brute force attack
The syntax is very simple, you only have to provide a wordlist file (or comma-separated list) and the path to your .cap
file containing the captured handshake. This is the file saved by airodump-ng
at the previous step.
Build a wordlist with crunch
crunch
will generate all of the possible combination of words between the two length values.
Notes on Speed
If you want to compare your computing power, you can run a simple test with
aircrack-ng
itself:aircrack-ng -S
Exploiting GPU power tools
Pyrit
John the Ripper
"Cracking as a Service" can be an option for those without a powerful GPU. These services only require you to upload the .cap
file containing the 4-way handshake and specify the target SSID. Once you have uploaded the file, you often choose between a series of different dictionaries so if you have a clue of the key, you can better restrict the search. Please note that most powerful services need you to pay a small fee.
CloudCracker
WPS: Wireless Protected Setup
In 2011, Stefan Viehbock published a paper describing a new attack against WPS (Wireless Protected Setup).
WPS was designed a simple and secure way to setup a protected wireless network.
Stefan also found that design and implementation flaws in various devices may lead to a very effective attack method that can disclose the wireless encryption key.
WPS provides 3 different setup alternative methods:
Push-Button-Connect
Internal-Registrar
External-Registrar
While the former two methods require stronger authentication procedures (physical access or web interface access) the External-Registrar method only requires the client to provide a PIN (8 digits).
Normally, bruteforcing a 8 digits number will require testing for 10^8 (=1000000000) combinations but the actual form of authentication used by WPS highly reduces this number.
This is the representation of the WPS PIN number:
1st half of PIN (4 bits)
2nd half of PIN (4 bits)
0, 1, 2, 3
4, 5, 6, 7 (7 = checksum digit)
It's divided into two halves of 4 digits each. The last digit of the 2nd half is a checksum meaning it is always calculated from the other digits.
The authentication process works like this:
Both AP and client initialize encryption keys and internal state
Client proves possession of 1st half of the PIN
Client proves possession of 2nd half of the PIN
AP sends network security configuration
At every step, if the client is sending wrong data the AP terminates the process and sends a NACK
packet.
This behavior, combined with the split PIN allows us to build a quite optimized brute force attack.
How many combinations do we need to try?
Splitting the PIN get us from 10^8 to 10^4 + 10^4 (=20000) while having a checksum digit reduces the number of guesses for the 2nd half and we get the final result of only 10^4 + 10^3 (=11000) combinations.
There are two tools that can help to exploit this vulnerability:
Reaver
Bully
WPS attacks have been around since 2011. Since then, many vendors have upgraded their devices and AP firmware now contains a protection against PIN bruteforce. This protection is called WPS Lockdown and it's simply a self-defense procedure that temporarily disables WPS registration if a repeated number of attempts to register is detected.
When your attack is detected, an AP can lockdown the WPS registration procedure for a time that varies between a few seconds to one hour or more. Some devices could even require a complete reboot.
If bully
detects a lockout, it will normally display the following output and then wait for 43 seconds before next attempt. On the other hand, you can also disable lockout detection in bully
and force it to continue the attack but this is not recommended.
The -L
switch is used to disable lockdown detection.
A better option to avoid being locked out is to add a certain delay after every PIN attempt. By adding a pause between each try, you could bypass the attack detection system and get a smoother bruteforce attack.
This will increase the needed time to test each PIN; most of the time, this will be the only viable solution given that newer firmware disables WPS registration for hours after multiple authentication attempts are detected in a few seconds.
The syntax to use to enable delay for the bully command goes as follows:
Where the -1
option controls the delay in the first phase of the attack (first half of the PIN) and -2
options sets the delay value for the second phase. Values of 60 seconds or more are recommended for most APs.
Last updated