I am doing a Security Research on Wireless networks which involves coding a small tool that scans for Wifi Access points in the vicinity. Based on the Encryption type found it goes on with some other security tests.
So far I have python code that uses Scapy to enumerate different access points and whether they have Encryption Enabled (Enc= Y or Enc=N). The code for this is:
def sniffAP(p):
if ( (p.haslayer(Dot11Beacon) or p.haslayer(Dot11ProbeResp))
and not aps.has_key(p[Dot11].addr3)):
ssid = p[Dot11Elt].info
bssid = p[Dot11].addr3
channel = int( ord(p[Dot11Elt:3].info))
capability = p.sprintf("{Dot11Beacon:%Dot11Beacon.cap%}\
{Dot11ProbeResp:%Dot11ProbeResp.cap%}")
# Check for encrypted networks
if re.search("privacy", capability): enc = 'Y'
else: enc = 'N'
What I want is the ability to distinguish between different Encryption Type (WEP, WPA, WPA2, WPS) using python and scapy. Any ideas?
Based on airodump-ng code (aicrack-ng suite), the information you're looking for is inside specific
Dot11Elt
layers. By the way in your code, you get SSID and channel by guessing that they are located in the first and thirdDot11Elt
layers, which seems to be the case, but I don't think it's mandatory.This code should do the work:
Update: this code is now obsolete. An updated version of this code has been integrated to Scapy.