Wi-Fi Security (WPA2) Using Python
Wi-Fi Security (WPA2) Using Python
Mini-project
Sector: Telecommunications
Module: RSF-RM
Theme
Group:
Acronyms
Bibliography ........................................................................................................................... 19
Table of Figure
Chapter 01
Chapter 02
AP Access Point
ID Identification
IV Initialization Vector
P2P Peer-to-Peer
PMP Point-to-Multipoint
PN Packet Number
STA Station
1.1. Introduction
Wi-Fi (Wireless Fidelity) is a wireless networking technology that allows devices such
as laptops, smart phones, and other equipment (printers and video cameras) to interface with
the Internet. It allows these devices--and many more--to exchange information with one
another, creating a network. It created in 1997 by WECA (Wireless Ethernet Compatibility
Alliance), which aims to ensure interoperability of 802.11 products and enhance this
technology. When devices are approved for Wi-Fi, they should have a logo (Figure 1.1).
It is the technology most vulnerable to hacking. Without the security of Wi-Fi, anyone
can connect to a network device using a computer within range, which threatens the stability of
the system and data protection. So, how can it be protected? [1]
7
Chapter 01: Generality of Security Wi-Fi Network
1.3.1.Physical Layer
known as PHY, it consists of two sub-layers:
• PMP determines the type of medium, connector, transmitter and receiver, and
modulation techniques.
• PLCP detects the medium and sends a signal called CCA to the MAC to know if
the medium is busy or not. It is characterized by three modulation techniques:
FHSS, DSSS, OFDM. [4] [3]
8
Chapter 01: Generality of Security Wi-Fi Network
9
Chapter 01: Generality of Security Wi-Fi Network
Figure 1. 6. Construction of TKIP based on RC4 stream cipher which uses long IV
10
Chapter 01: Generality of Security Wi-Fi Network
1.4.4. Authentication
The IEEE has defined two authentication algorithms for 802.11 networks:
• Open authentication that corresponds to the null algorithm: any terminal that requests
authentication gets access.
• Shared key authentication requires that both the requesting station and the station
granting access be configured with identical WEP keys. So, station A sends an
authentication request to B, which sends it a clear test frame. A encrypts the test frame
with its WEP key and sends it back to the authentication station. This attempts to decrypt
the frame: if the decoded text matches the plaintext that was initially sent, it grants
access. [1]
1.5. Conclusion
Wi-Fi, based on the IEEE 802.11 standard, is an integral part of our everyday lives,
enabling wireless connectivity for a wide range of devices. This technology has evolved over
the years, introducing many architectures, encryption and authentication methods to ensure that
information is transmitted smoothly and securely.
11
Chapter 02:
implementation Security and Attack
Wi-Fi
Chapter 02: implementation Security and Attack Wi-Fi
2.1. Introduction
In this chapter, we will implement the encryption algorithms used by the Wi-Fi network
in WEP and WPA/WPA2, that is, the AES and RC4 algorithms. Therefore, we created a
simulation of AES and a simulation of RC4 using the Python program. To know the efficiency
of the Wi-Fi protection system, we attacked three WPA2+WPS protection modes using Wircut,
and WPA2 using Kali Linux operating system. [7]
2.2. Simulation of RC4 and AES algorithm
The RC4 and AES encryption algorithm is considered one of the basic pillars of
protecting the Wi-Fi network from hacking, and since this type of encryption is not open source,
that is why we used the Python program in the simulation process, as shown in Figure 2.1.
13
Chapter 02: implementation Security and Attack Wi-Fi
We notice that in this simulation we sent the text “Oussama” using the key “000011101”,
so it was encrypted as follows: “XcKtUV5JaTQ=”. To retrieve the message, we note that the
key used must be known. If there is an error in the key, the message will not be retrieved.
14
Chapter 02: implementation Security and Attack Wi-Fi
• Shift Rows: Block rows are shifted by different offsets. The number of positions each
byte is shifted depends on the row index Figure 2.4.
• Columns mix: It operates on the columns of the state matrix, which is the block of
data that is being processed. Each column is treated as a polynomial over a finite field,
and the matrix multiplication is performed on each column Figure 2.5.
• Key addition: The circular key derived from the original encryption key is XORed
with a state array. The rotated key is generated from the original key using the key
table. Each round of AES uses a different round key Figure 2.6.
15
Chapter 02: implementation Security and Attack Wi-Fi
In the end, after simulating these steps, we were able to encrypt and decrypt the
message, Figure 2.7.
We note that the AES algorithm is very complex, as by placing the message
“Oussama&Hamouda”, the message was directly encrypted using its private keys randomly
without using a single key, in the same way but in reverse, where the encrypted message
“AAAAAAAAAAAAAAAAAAAAAIMdezLyVsgc4UtnhTQ5cg==” was taken and the
steps were reversed. Retrieve the message.
We also note that the AES algorithm is more secure since the encryption key is variable
and random for each round.
2.3. Attack on WPA2/WPS
We carried out an attack on a router that uses the WPA2+WPS security system, using the
Waircut program, which works to find a WPS vulnerability that allows us to hack the Wi-Fi
device and know the password, Figure 2.8. [7] [9]
16
Chapter 02: implementation Security and Attack Wi-Fi
17
Chapter 02: implementation Security and Attack Wi-Fi
We note that in this case, the WPA2 Wi-Fi network was hacked and the password was
found within a few minutes. We also note that this method is successful with victims for whom
we have information such as dates of birth, and that the victim must be connected to the
network.
2.5. Conclusion
RC4 encryption depends on a single key, which makes it easy to hack, and this is what
makes WEP weak compared to protection with WPA2, which relies on AES encryption, which
has a variable key, which makes it more complex and difficult to hack. However, through our
experience, it has been proven that even WPA2 can be hacked, and this is what confirms that
the methods Wi-Fi security does not provide sufficient security guarantees.
18
Bibliography
[6] M. Terré, "WiFi Le Standard 802.11 Couche physique et couche MAC," Mars 2007.