Sunday, July 21, 2019

Generate WiFi Beacons

I am going to pump Wifi Beacons in the air.  For this, I use Alfa-AWUS036NHA usb wifi dongle in Fedora.  I googled through some websites to create a virtual interface of usb wifi in monitor mode. Installed Scapy so as to program.

Beacon Frame
The Beacon Frame above is generated using the following python code.  Run the code, and in sniffer the above frame will be seen.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /usr/bin/env python
from scapy.all import *
import sys

####### Enter the interface ###########
iface = 'mon0'

####### Initializing the parameters in pairs of SSID and BSSID #########
pairs = [('ACTIVEHUB','00:90:12:34:56:78'),('ACTIVEHUB2','00:90:12:34:56:79')]

for SSID,BSSID in pairs:
        # Create MAC Header
        dot11 = Dot11(type=0, subtype=8, addr1='ff:ff:ff:ff:ff:ff',addr2=BSSID, addr3=BSSID)
        beacon = Dot11Beacon()
        # Create SSID Tag Parameter in Beacon Frame
        essid = Dot11Elt(ID='SSID',info=SSID, len=len(SSID))

        # Combine all objects into a single frame
        frame = RadioTap()/dot11/beacon/essid

        # Send 'count' number of frames with interval 'inter' seconds
        sendp(frame, iface=iface, inter=0.100, count=1)

In line 9, I have included 2 beacons. Each beacon represented as a pair (SSID, BSSID). You can include as many as you like.