Python扫描WiFi

时间:2016-09-24 18:03:54

标签: python wifi python-3.5 scapy sniffer

我正在搜索可以扫描WiFi网络并打印所有SSID的程序。我尝试用scapy,但我失败了。我正在使用pyCharm编辑器。

我试过这段代码:

from scapy.all import *
from scapy.layers.dot11 import Dot11

def packet_handler(pkt):        
    if pkt.haslayer(Dot11) and pkt.type == 2:        
        print(pkt.show())
scapy.sniff(iface="mon0", prn=packet_handler)

1 个答案:

答案 0 :(得分:5)

尝试pip install wifi然后进行扫描使用

from wifi import Cell, Scheme
Cell.all('wlan0')

返回Cell对象列表。在引擎盖下,这称为iwlist扫描并解析不友好的输出。每个单元对象应具有以下属性:ssid,signal,quality等。 和连接使用

cell = Cell.all('wlan0')[0]
scheme = Scheme.for_cell('wlan0', 'home', cell, passkey)
scheme.save()
scheme.activate()

scheme = Scheme.find('wlan0', 'home')
scheme.activate()

了解更多信息goto https://wifi.readthedocs.io/en/latest/