How to Create Fake Access Points using Scapy in Python?
Last Updated :
15 Nov, 2021
In this article, we are going to discuss how to create fake access points using scapy module in python
This task can be done with the help of the python package scapy-fakeap. The intention behind using this library is not only making Fake Access Point but also Testing of 802.11 protocols and its implementation.
Scapy is a python module used for interacting with the packets on the network. It has several functionalities through which we can easily forge and manipulate the packet. It is a powerful interactive packet manipulation program. It is able to forge or decode packets of a wide number of protocols, send them on the wire, capture them, match requests and replies, and much more. Scapy can easily handle most classical tasks like scanning, trace routing, probing, unit tests, attacks or network discovery. It can replace hping, arpspoof, arp-sk, arping, p0f and even some parts of Nmap, tcpdump, and tshark.
Installation :
For using this library you need to have the following python packages installed in your system :
- scapy
- ip
- airmon-ng
- dnsmasq (Optional)
These all python packages which can be installed in simple steps via running the below command:
pip3 install scapy-fakeap
Note:
- For deep diving into the code we all need to keep your device or network into the monitor mode.
- Make sure that you are in to the Unix or Linux based System.
To keep our system in monitor more we some utilities i.e. aircrack-ng. It can be installed using the below command:
apt-get install aircrack-ng
Steps to go into the monitor mode :
- Enable monitor mode using airmon-ng command
- Firstly, kill all the process of your system using this command:
airmon-ng check kill
- Enable your WLAN network for this run the command ifconfig to check active networks in your system and then run the below command:
airmon-ng start (your WLAN name)
This will activate the connection of your WLAN.
You are all set for further process of building fake access point
Now we will generate a random MAC address as well as setting a name of our access point we want to create, and then we create an 802.11 frame, and the fields are:
- type=0: This will indicate that this is a management frame.
- subtype : This will indicate that this management frame is a beacon frame.
- addr1 : This will refer to the destination mac address.
- addr2 : This will refer to source MAC address or sender's MAC address.
- addr3 : This will refer to the access point's MAC address.
Now we will use the same MAC address of addr2 and addr3, because the sender is access point. And then we will create our beacon frame with ssid infos and then stack together and send them using sendp() method of scapy module. Below is the implementation:
Python3
# Import module
from scapy.all import *
# Make an variable interface and assign
# this name of wlan connection name "my-Wlan"
interface = "my_Wlan"
# This will be sender's MAC address
# This is there random MAC address generated
sender = RandMAC()
# Assign access point name
access_point_name = "Test"
# Here we will define 802.11 frame
dot11 = Dot11(type=0, subtype=8,
addr1="ff:ff:ff:ff:ff:ff",
addr2=sender, addr3=sender)
beacon = Dot11Beacon()
# Assign ssid in frame
e_SSID = Dot11Elt(ID="SSID", info=access_point_name,
len=len(access_point_name))
# stack all the layers and add a RadioTap
frame = RadioTap()/dot11/beacon/e_SSID
# Send the frame in layer 2 every 100 milliseconds
# using the iface interface
sendp(frame, inter=0.1, iface=interface, loop=1)
Output:
When you will reach the last line of your script and loop=0 then your system will only send 1 packet as an access point.
When you will reach the last line of code and loop=1 below output will be generated as the system continuously sends the packets as an access point which will be fake.
On pressing ctrl+c your system will stop sending the packets.
Similar Reads
Python script to change MAC address of Linux machine
What is MAC Address: In a computer network, the MAC Address is used at the lowest networking level, where network interfaces communicate with one another. See details here. Need of changing MAC Address: To bypass MAC Address filtering To bypass certain kind of MITM spoofing attack To avoid device tr
3 min read
Making a Port-Scanner in Kali Linux Terminal Using Python
In computer networking, a port is a virtual point where network connections start and end. It's like an open door of your home, If you don't close this then anyone can Enter your home. A port scanner is a program that is searching ports in a network and tries to find which ports are virtually open a
3 min read
Return Data in JSON Format Using FastAPI in Python
FastAPI is a modern, fast, web framework for building APIs with Python 3.7+ based on standard Python type hints. It is designed to be easy to use and efficient, providing automatic generation of OpenAPI and JSON Schema documentation. In this article, we will see how to return data in JSON format usi
2 min read
Finding IP Address using Python
An IP(Internet Protocol) address is an identifier assigned to each computer and other device(e.g., router, mobile, etc.) connected to a TCP/IP network that is used to locate and identify the node in communication with other nodes on the network. IP addresses are usually written and displayed in huma
2 min read
Python - Generate Random String of given Length
Generating random strings is a common requirement for tasks like creating unique identifiers, random passwords, or testing data. Python provides several efficient ways to generate random strings of a specified length. Below, weâll explore these methods, starting from the most efficient.Using random.
2 min read
Getting Saved Wifi Passwords using Python
Usually while connecting with the wifi we have to enter some password to access the network, but we are not directly able to see the password we have entered earlier i.e password of saved network. In this article, we will see how we can get all the saved WiFi name and passwords using Python, in orde
3 min read
Python program to determine if the given IPv4 Address is reserved using ipaddress module
Given a IPv4 Address, the task is to determine whether it is reserved (i.e belongs to class E) or not. What is class E? IP addresses belonging to class E are reserved for experimental and research purposes. IP addresses of class E range from 240.0.0.0 â 255.255.255.254. This class doesnât have any s
1 min read
Python program to validate an IP Address
Prerequisite: Python Regex Given an IP address as input, write a Python program to check whether the given IP Address is Valid or not. What is an IP (Internet Protocol) Address? Every computer connected to the Internet is identified by a unique four-part string, known as its Internet Protocol (IP) a
4 min read
Connectionerror - Try: Except Does Not Work" in Python
Python, a versatile and powerful programming language, is widely used for developing applications ranging from web development to data analysis. However, developers often encounter challenges, one of which is the "ConnectionError - Try: Except Does Not Work." This error can be frustrating as it hind
4 min read
Python - Getting all the Wifi Devices the system has connected
In this article we will see how we can all those wifi network on which the system is ever connected to. Wi-Fi is a wireless networking technology that allows devices such as computers (laptops and desktops), mobile devices (smart phones and wearables), and other equipment (printers and video cameras
2 min read