2017-02-24 47 views
1

我想建立一個scapy程序,掃描信標幀。每個路由器應該以X毫秒的間隔向空中發送信標幀,以便可能的主機知道路由器(AP)是活着的。蟒蛇scapy信標幀

我什麼也沒得到,到目前爲止我所能得到的唯一Dot11幀是Prob Request,很少有一些數據或控制幀。我在運行腳本之前將無線網卡設置爲監視模式,並且它也支持它。我不知道我可能是做錯了......下面的代碼:

from scapy.all import * 

global list_prob 
list_prob = [] 
def search_prob(packet1): 
    if (packet1.haslayer(Dot11)) and (packet1[Dot11].type == 0) and\ 
    (packet1[Dot11].subtype == 8) : #type 4 == ProbRequest 
     if packet1[Dot11].addr2 not in list_prob: 
      if packet1[Dot11].info not in list_prob: 
       print('[>]AP',packet1[Dot11].addr2,'SSID',packet1[Dot11].info) 
       list_prob.append(packet1[Dot11].addr2) 
       list_prob.append(packet1[Dot11].info) 

sniff(iface='wlan0mon',prn=search_prob) 

香港專業教育學院還與Dot11Beacon試圖代替亞型8並沒有什麼改變它。我在Linux上使用python3.5進行編程。 任何想法?

+1

這對我的作品。嘗試在後臺切換頻道。 – Yoel

+0

它工作正常!謝謝m8 scapy沒有改變頻道的功能我寫了一個python腳本來做它使用子進程庫 – user7519508

+0

很酷。我建議你把它寫成答案,因爲它可能有益於同樣問題的未來讀者。 – Yoel

回答

0

代碼以使用python不斷變化的網絡接口道:

from threading import Thread 
import subprocess,shlex,time 
import threading 
locky = threading.Lock() 

def Change_Freq_channel(channel_c): 
    print('Channel:',str(channel_c)) 
    command = 'iwconfig wlan1mon channel '+str(channel_c) 
    command = shlex.split(command) 
    subprocess.Popen(command,shell=False) # To prevent shell injection attacks ! 

while True: 
    for channel_c in range(1,15): 
     t = Thread(target=Change_Freq_channel,args=(channel_c,)) 
     t.daemon = True 
     locky.acquire() 
     t.start() 
     time.sleep(0.1) 
     locky.release()