Python scapy Beacon Frames

时间:2017-02-24 21:09:59

标签: python-3.x scapy

我正在尝试构建一个扫描Beacon Frames的scapy程序。每个路由器都应该以X毫秒的间隔向空中发送信标帧,以便可能的主机知道路由器(AP)是否存活。

我什么都没得到,到目前为止我能够获得的唯一一种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 个答案:

答案 0 :(得分: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()
相关问题