Rogue APs, Evil Twins and Wireless Intrusion Detection
The firewall watches the cables, the IDS watches the packets on them, and the air in between is often watched by nobody. Yet the air is where an employee's €30 travel router turns the office LAN into an open hotspot, where an evil twin copies the corporate SSID, and where a deauthentication flood knocks the warehouse scanners offline. A wireless intrusion detection system (WIDS) is a set of radio sensors plus rules that compare what they hear with what should be there. This lesson builds the two core detectors, an AP classifier and a deauthentication counter, on synthetic sensor data.
What counts as "rogue"
| Class | What it is | Risk | Typical signal |
|---|---|---|---|
| Rogue AP | an unauthorised AP connected to your wired network (an employee's router, a forgotten test AP) | a back door into the LAN that bypasses the firewall and 802.1X | unknown BSSID whose wired MAC appears on your switch ports |
| Evil twin | someone else's AP advertising your SSID | credential capture, downgrade, machine in the middle | your SSID on an unknown BSSID, often with different or weaker security, often strong signal |
| Misconfigured own AP | one of your APs whose settings drifted | e.g. the IoT network suddenly open | known BSSID, unexpected security or channel |
| Neighbour | other people's networks | none to you | unknown BSSID, unknown SSID, no wired presence |
| Hotspots and ad hoc | phones sharing their connection, devices in ad hoc mode | bridging managed laptops to unmanaged networks | client-side: managed devices connected to unknown SSIDs |
The classification matters because the response differs: a rogue AP on your switch is removed, an evil twin is located and reported, a neighbour is left alone (scope).
Detector 1: classify every beacon
The sensor data below is synthetic. The classifier compares each beacon with the AP inventory, and checks the wired side: many APs derive their BSSIDs from their wired MAC address plus a small offset, so a BSSID "next to" a MAC on your switch's address table points to a device plugged into your network.
inventory = { # BSSID -> (SSID, channel, security) of the APs we installed
"02:00:00:0a:0a:01": ("LabNet", 6, "SAE+PSK"), "02:00:00:0a:0a:02": ("LabNet", 36, "SAE+PSK"),
"02:00:00:0a:0c:01": ("LabCorp", 44, "802.1X"), "02:00:00:0a:0b:01": ("LabNet-IoT", 11, "PSK"),
}
our_ssids = {ssid: set() for ssid, _, _ in inventory.values()}
for ssid, _, sec in inventory.values():
our_ssids[ssid].add(sec)
switch_macs = {"02:00:00:0a:0a:00", "02:00:00:0a:0c:00", "02:00:00:0a:0b:00", "3c:5a:b4:77:00:10"} # wired MACs on our switch ports
survey = [ # (sensor, SSID, BSSID, channel, security, RSSI dBm): beacons heard by the lab's sensors (synthetic)
("s1", "LabNet", "02:00:00:0a:0a:01", 6, "SAE+PSK", -48), ("s2", "LabNet", "02:00:00:0a:0a:02", 36, "SAE+PSK", -52),
("s1", "LabCorp", "02:00:00:0a:0c:01", 44, "802.1X", -50), ("s3", "LabCorp", "02:00:00:0a:0c:66", 44, "802.1X", -41),
("s2", "LabNet", "02:00:00:0a:0a:77", 6, "PSK", -45), ("s3", "TP-Office", "3c:5a:b4:77:00:11", 1, "PSK", -60),
("s1", "LabNet-IoT", "02:00:00:0a:0b:01", 11, "open", -55), ("s1", "CafeFreeWiFi", "6e:00:11:22:33:44", 1, "open", -80),
]
def wired_side(bssid): # many APs derive the BSSID from the wired MAC plus a small offset
last = int(bssid[-2:], 16)
return any(f"{bssid[:-2]}{last + d:02x}" in switch_macs for d in (-2, -1, 0, 1, 2) if 0 <= last + d <= 255)
def classify(ssid, bssid, ch, sec):
if bssid in inventory:
return "ok" if inventory[bssid] == (ssid, ch, sec) else f"CHANGED: our AP now shows {sec} (expected {inventory[bssid][2]})"
if ssid in our_ssids:
return "EVIL TWIN suspect: our SSID, unknown BSSID" + ("" if sec in our_ssids[ssid] else ", weaker security")
if wired_side(bssid):
return "ROGUE: unknown AP whose wired side is on our switch"
return "neighbour (log, don't touch)"
for sensor, ssid, bssid, ch, sec, rssi in survey:
print(f"{sensor} {ssid:12} {bssid} {sec:8} {rssi:>4} dBm {classify(ssid, bssid, ch, sec)}")s1 LabNet 02:00:00:0a:0a:01 SAE+PSK -48 dBm ok
s2 LabNet 02:00:00:0a:0a:02 SAE+PSK -52 dBm ok
s1 LabCorp 02:00:00:0a:0c:01 802.1X -50 dBm ok
s3 LabCorp 02:00:00:0a:0c:66 802.1X -41 dBm EVIL TWIN suspect: our SSID, unknown BSSID
s2 LabNet 02:00:00:0a:0a:77 PSK -45 dBm EVIL TWIN suspect: our SSID, unknown BSSID, weaker security
s3 TP-Office 3c:5a:b4:77:00:11 PSK -60 dBm ROGUE: unknown AP whose wired side is on our switch
s1 LabNet-IoT 02:00:00:0a:0b:01 open -55 dBm CHANGED: our AP now shows open (expected PSK)
s1 CafeFreeWiFi 6e:00:11:22:33:44 open -80 dBm neighbour (log, don't touch)
Four findings from one survey:
- an unknown
LabCorpBSSID with the strongest signal at sensor s3: an Enterprise evil-twin suspect; - an unknown
LabNetBSSID offering only PSK where the real network offers SAE: the transition-mode downgrade setup; TP-Office, whose wired side is on our switch: a rogue AP, the most urgent, because it bypasses every control on the LAN;- our own IoT AP now showing open: drift, probably a reset to factory settings.
The neighbour's café network is logged and otherwise ignored.
Detector 2: deauthentication floods
Deauthentication and disassociation frames are normal in small numbers (clients leaving, APs balancing load). A burst from one source, especially to the broadcast address, is a denial-of-service attack or an attempt to force handshakes, on networks without PMF. Note that the "source" is whatever the frame claims, usually your AP's address, forged.
from collections import Counter
# Management frames logged by sensor s2 (synthetic): (second, frame type, source, destination)
frames = [(t, "deauth", "02:00:00:0a:0a:01", "02:11:22:33:44:55") for t in range(100, 160, 2)] # 30 in a minute
frames += [(t, "deauth", "02:00:00:0a:0a:01", "ff:ff:ff:ff:ff:ff") for t in range(130, 160, 1)] # 30 broadcast
frames += [(40, "deauth", "02:00:00:0a:0a:02", "02:aa:00:00:00:09"), (300, "disassoc", "02:00:00:0a:0a:02", "02:aa:00:00:00:10")]
BASELINE, WINDOW = 5, 60 # normal: a few per AP per minute
counts = Counter((t // WINDOW, src) for t, kind, src, dst in frames if kind in ("deauth", "disassoc"))
for (w, src), n in sorted(counts.items()):
bcast = sum(1 for t, k, s, d in frames if t // WINDOW == w and s == src and d.startswith("ff:"))
flag = "ALERT deauth flood" if n > BASELINE else "normal"
print(f"minute {w}: {src} sent {n:2} deauth/disassoc ({bcast} broadcast) {flag}")minute 0: 02:00:00:0a:0a:02 sent 1 deauth/disassoc (0 broadcast) normal
minute 1: 02:00:00:0a:0a:01 sent 10 deauth/disassoc (0 broadcast) ALERT deauth flood
minute 2: 02:00:00:0a:0a:01 sent 50 deauth/disassoc (30 broadcast) ALERT deauth flood
minute 5: 02:00:00:0a:0a:02 sent 1 deauth/disassoc (0 broadcast) normal
Minute 2 has 30 broadcast deauthentications: every client of that AP was thrown off. The same rule applies to other management-frame floods (association, authentication, SAE Commit), each with its own baseline.
Locating and responding
- Location: several sensors hear the same transmitter at different strengths; the strongest sensor (s3 for the
LabCorptwin) narrows the area, and controllers estimate positions from three or more sensors. A person with a directional antenna does the rest. - Wired-side response for rogue APs: shut the switch port, find the device, apply 802.1X on wired ports so unknown devices can't join at all.
- Evil twins: alert users near the location, check client logs for certificate failures, involve physical security; it is often a crime by the operator, so preserve the evidence (sensor logs, times, locations).
- Containment caution: some WIPS products can "contain" a rogue by sending deauthentication frames to its clients. Doing that to networks you don't own is itself interference; in 2014 the US FCC fined a hotel operator $600,000 for deauthenticating guests' personal hotspots. Contain only on your own infrastructure, and prefer wired-side responses.
Building a WIDS
- Sensors: dedicated sensors or AP radios in monitor mode (time-shared scanning misses short events); coverage of all bands you use, including 6 GHz.
- Inventory: the authoritative list of BSSIDs, SSIDs, channels and security per AP; updated by change management, not by hand.
- Rules: unknown BSSID with our SSID; known BSSID with changed settings; wired-side match; management-frame floods; PMF-protected clients receiving unprotected deauths; SAE/PSK failure bursts (handshake failures).
- Output: alerts into the SIEM with sensor, location, time and RSSI, like any IDS (IDS basics).
Open-source building blocks exist (Kismet for monitoring and alerting, Wireshark/tshark for analysis), and enterprise WLAN controllers include WIDS features.
How the WIDS itself is kept honest
- Test it in a shielded lab or with
mac80211_hwsim: a test AP with your SSID must raise an alert. - Tune baselines per site: a warehouse with roaming scanners has more deauths than an office.
- Review false positives: a new AP installed without updating the inventory is a process finding.
Pitfalls
- Matching on SSID only: twins copy it, so the BSSID is what matters.
- Treating every unknown BSSID as hostile and "containing" it: neighbours are not yours to touch.
- Watching only 2.4 GHz while clients roam on 5 and 6 GHz.
Practice
1. Add a beacon ("s2", "LabNet-IoT", "02:00:00:0a:0b:05", 11, "PSK", -70) to the survey. What does the classifier say, and what would you check?
"EVIL TWIN suspect: our SSID, unknown BSSID" (the security matches, so no "weaker" note). Check change records for a new IoT AP, then the wired side; at -70 dBm it is far from s2, so look near other sensors or outside.
2. Why does the deauthentication rule work even though the attacker forges the AP's address?
The rule counts frames that claim that source; the real AP rarely sends many, so a burst is anomalous whoever sent it. Sequence-number gaps and the sensor's RSSI (different from the real AP's usual level) can show that the frames were forged.
3. A rogue AP is found on switch port 2/14. List the response steps.
Shut or quarantine the port, locate and remove the device, find out who connected it and why (often convenience, sometimes malice), check what connected through it (DHCP leases, logs), then enable 802.1X/MAB on access ports and add the case to awareness training.
Test yourself
What distinguishes a rogue AP from an evil twin?
- The channel
- A rogue AP is connected to your wired network; an evil twin imitates your SSID from outside it
- Evil twins are always open
- Rogue APs use WPA3
Which finding in the survey was the most urgent?
- CafeFreeWiFi
- The rogue TP-Office AP on our switch
- LabNet on 02:00:00:0a:0a:01
- Signal strengths below -60 dBm
Why should WIPS containment by deauthentication be used with care?
- It is slow
- Sending deauthentication frames to networks you don't own is interference and can be illegal
- It needs WPA3
- It only works on 6 GHz
How do several sensors help with an evil twin?
- They decrypt it
- Comparing signal strengths at each sensor locates the transmitter
- They change its channel
- They block its SSID