2016-09-24 188 views
0

我正在尋找一個可以掃描WiFi網絡並打印所有SSID的程序。我用scapy試過但我失敗了。我正在使用pyCharm編輯器。用於WiFi的Python掃描

我試過這段代碼:

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

您好,歡迎StackOverflow上。請花些時間閱讀幫助頁面,特別是[Stack Overflow問題清單](http://meta.stackexchange.com/q/156810/204922)。就目前而言,您應該添加關於此代碼給您的問題的描述(以及適當的完整堆棧跟蹤),以適應您的問題 – JGreenwell

+0

代碼的結果是什麼? – Noob123

回答

2

嘗試pip install wifi然後掃描使用

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

這將返回Cell對象的列表。在引擎蓋下,這調用iwlist掃描並解析不友好的輸出。每個單元格對象應具有以下屬性:ssid,信號,質量等。 以及用於連接使用

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/