Ever wondered how does your laptop or mobile phone know which wireless networks are available nearby ? It is actually very simple, Wireless Access Points continually send beacon frames to all nearby wireless devices, these frames include informations about the access point, such as the SSID (name), type of encryption, MAC address, etc.
In this tutorial, you will learn how can you send beacon frames into the air using Scapy library in Python to successfully forge fake access points!
Necessary packages to install for this tutorial:
It is highly suggested you follow along with Kali Linux environment, as it provides pre-installed utilities we gonna need in this tutorial.
Before we dive into the exciting code, you need to enable monitor mode in your network interface card:
- You need to make sure you're in a Unix-based system.
- Install aircrack-ng utility:
Note: aircrack-ng utility comes pre-installed with Kali Linux, so if you're on Kali, you shouldn't run this command.
- Enable monitor mode using airmon-ng command:
Note: My USB WLAN stick is named wlan0 in my case, you should run ifconfig command and see your proper network interface name.
Alright, now you have everything set, let's start with a simple recipe first:
The above code does the following:
We generate a random MAC address as well as setting a name of our access point we want to create and then we create a 802.11 frame, the fields are:
- type=0: indicates that it is a management frame.
- subtype=8: indicates that this management frame is a beacon frame.
- addr1: refers to the destination MAC address, in other words, the receiver's MAC address, we use the broadcast address here ("ff:ff:ff:ff:ff:ff"), if you want this fake access point to appear only in a target device, you can use the target's MAC address.
- addr2: source MAC address, the sender's MAC address.
- addr3: the MAC address of the access point.
So we should use the same MAC address of addr2 and addr3, that's because the sender is the access point!
We create our beacon frame with ssid infos and then stack them all together and send them using Scapy's sendp() function.
After we setup our interface into monitor mode and execute the script, we should see something like that in the list of available Wi-Fi access points:
Now let's get a little bit fancier and create many fake access points in the same time:
All I did here, is wrapping the previous lines of code in a function, and generate random MAC addresses and SSIDs using faker package, and then start a separate thread for each access point, once you execute the script, the interface will send 5 beacons each 100 milliseconds (at least in theory), this will result to an appearing of five fake access points, check this out:
Here is how it looks on Android OS:
That is amazing, note that attempting to connect to one of these access points will fail, as they are not real access points, just an illusion !
0 Comments