Python扫描WiFi [英] Python scan for WiFi
本文介绍了Python扫描WiFi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个程序,该程序可以扫描WiFi网络并打印所有SSID.我尝试用scapy,但失败了.我正在使用pyCharm编辑器.
I was searching for a program that can scan for WiFi networks and print all of the SSIDs. I tried with scapy but I failed. I am using the pyCharm editor.
我尝试了以下代码:
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)
推荐答案
尝试pip install wifi
然后进行扫描使用
from wifi import Cell, Scheme
Cell.all('wlan0')
这将返回Cell对象的列表.在后台,这将调用iwlist scan并解析不友好的输出.每个单元对象应具有以下属性:ssid,信号,质量等. 并用于连接
This returns a list of Cell objects. Under the hood, this calls iwlist scan and parses the unfriendly output. Each cell object should have the following attributes: ssid, signal, quality and more. and for connecting use
cell = Cell.all('wlan0')[0]
scheme = Scheme.for_cell('wlan0', 'home', cell, passkey)
scheme.save()
scheme.activate()
scheme = Scheme.find('wlan0', 'home')
scheme.activate()
有关更多信息,请转到 https://wifi.readthedocs.io/en/latest/
for more info goto https://wifi.readthedocs.io/en/latest/
这篇关于Python扫描WiFi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文