我有两个无线接口,wlan0
和wlan1
。我通过wlan0
连接到家庭网络上的树莓派,并使用wlan1
作为访问点来收集探测请求。
我将wlan1
设置为监视器模式(iwconfig显示模式:更改时显示主模式(
subprocess.run(f'ifconfig wlan{interface_id} down', shell=True)
subprocess.run(f'ifconfig wlan{interface_id} mode Monitor', shell=True)
subprocess.run(f'ifconfig wlan{interface_id} up', shell=True)
当运行此代码以检查卡是否处于监视器(主(模式时,它返回true:
def is_card_in_mon_mode(interface_id):
output = subprocess.Popen(['iwconfig', f'wlan{interface_id}'], stdout=subprocess.PIPE)
for param in output.stdout:
if b'Master' in param:
return True
然后,执行:sniff(iface="wlan1", prn=handle_packet)
不访问handle_packet方法。
使用sniff(iface="wlan0", prn=handle_packet)
确实访问了handle_packet
方法,有什么原因可以在wlan0上工作而在wlan1上不工作吗?
我太笨了。没有网络流量,因此没有回叫功能。上面的代码按预期工作,如果其他人有这个问题,请考虑通过该接口发送数据包,然后看看是否发生了什么。。