Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WLAN SSID Sniffer in Python using Scapy
#!/usr/bin/env python
from scapy.all import *
ap_list = []
def PacketHandler(pkt) :
if pkt.haslayer(Dot11) :
if pkt.type == 0 and pkt.subtype == 8 :
if pkt.addr2 not in ap_list :
ap_list.append(pkt.addr2)
print "AP MAC: %s with SSID: %s " %(pkt.addr2, pkt.info)
sniff(iface="mon0", prn = PacketHandler)
@mwatts7222

This comment has been minimized.

Show comment
Hide comment

Very nice.

@lifeofpentester

This comment has been minimized.

Show comment
Hide comment
@lifeofpentester

lifeofpentester Feb 6, 2014

Hi, I wanted to know how I can leverage Scapy to tell me the Encryption type as well (WEP, WPA, WPA2, WPS Enabled). I am doing some research on Wifi security and I really need to code something using python and scapy that would tell me the ENC type. Can you help please?

Hi, I wanted to know how I can leverage Scapy to tell me the Encryption type as well (WEP, WPA, WPA2, WPS Enabled). I am doing some research on Wifi security and I really need to code something using python and scapy that would tell me the ENC type. Can you help please?

@uforek

This comment has been minimized.

Show comment
Hide comment
@uforek

uforek Jul 21, 2014

Quick question...

Would checking the packet for the Dot11Beacon layer be the same as checking the packet type for 0x00 and subtype for 0x08, as in your script above?

I wrote a similar script where I was getting strange results on occasion and unfortunately never logged the complete packet to debug the issue, but it appeared as the value in the packet's info var would sometimes appear empty or with unexpected ascii chars.

uforek commented Jul 21, 2014

Quick question...

Would checking the packet for the Dot11Beacon layer be the same as checking the packet type for 0x00 and subtype for 0x08, as in your script above?

I wrote a similar script where I was getting strange results on occasion and unfortunately never logged the complete packet to debug the issue, but it appeared as the value in the packet's info var would sometimes appear empty or with unexpected ascii chars.

@adamziaja

This comment has been minimized.

Show comment
Hide comment
@adamziaja

adamziaja Nov 11, 2014

If you want to sniff SSID then why you only catch beacon packets? Correct version https://github.com/adamziaja/python/blob/master/ssid_sniffer.py and probe request sniffer https://github.com/adamziaja/python/blob/master/probe_request_sniffer.py . Also please try keep your script running a long period of time and look your cpu/mem... all packets will be in memory.

If you want to sniff SSID then why you only catch beacon packets? Correct version https://github.com/adamziaja/python/blob/master/ssid_sniffer.py and probe request sniffer https://github.com/adamziaja/python/blob/master/probe_request_sniffer.py . Also please try keep your script running a long period of time and look your cpu/mem... all packets will be in memory.

@adamziaja

This comment has been minimized.

Show comment
Hide comment
@adamziaja

adamziaja Nov 11, 2014

@uforek: yes, subtype 8 is beacon

@uforek: yes, subtype 8 is beacon

@vickydasta

This comment has been minimized.

Show comment
Hide comment
@vickydasta

vickydasta Feb 14, 2015

is there some spesification for the network interface ? it didn't works well on mine

is there some spesification for the network interface ? it didn't works well on mine

@ajdumanhug

This comment has been minimized.

Show comment
Hide comment
@ajdumanhug

ajdumanhug Dec 14, 2015

I'm having a problem with my sniff().
I used from scapy import * instead of scapy.all import *

I'm having a problem with my sniff().
I used from scapy import * instead of scapy.all import *

@chaya2090

This comment has been minimized.

Show comment
Hide comment
@chaya2090

chaya2090 Jun 13, 2016

hello evryone,
I am using mininet-wifi to send dot11 packets from station1 to station 2 but I am not able to send.May b I am making mistake in send and sniff commands...Please suggest

hello evryone,
I am using mininet-wifi to send dot11 packets from station1 to station 2 but I am not able to send.May b I am making mistake in send and sniff commands...Please suggest

@lucascouto

This comment has been minimized.

Show comment
Hide comment
@lucascouto

lucascouto May 26, 2018

Thank you, very much!

Thank you, very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment