在 AP 上查找所有 mac 台设备

Find all mac devices on AP

我尝试在 python 中用 scapy 编写代码,第一步是扫描所有可用的访问点,第二步是获取所有 mac 连接到 ap 的设备地址

我第一步成功了,但在第二步我做错了

#!/usr/bin/env python
#part 1
# import scapy module
import scapy.all as scapy





# Extracted Packet Format 
Pkt_Info = """
---------------[ Packet Captured ]-----------------------
Subtype  : {}   
Address 1  : {} | Address 2 : {} [BSSID] 
Address 3  : {} | Address 4 : {} 
 AP   : {} [SSID]
"""


# GetAPStations Function
def GetAPStation(*args,  **kwargs):
"""
Function For Filtering Beacon Frames And Extract Access 
Point Information From Captured Packets.

"""
ap=[]
packets=[]
CliList=[]
def PacketFilter(pkt):
if pkt.haslayer(scapy.Dot11Elt) and pkt.type == 0 and pkt.subtype == 
8:
 if pkt.addr2 not in ap:
  ap.append(pkt.addr2)
  packets.append(pkt)

  print Pkt_Info.format(pkt.subtype,pkt.addr1, pkt.addr2, pkt.addr3, 
pkt.addr4,pkt.info)

scapy.sniff(prn=PacketFilter, *args, **kwargs)
return (ap, packets)

# Main Trigger
if __name__=="__main__":

# Previous Function Trigger
#
# here, iface="mon0" for Interface with monitor mode enable
#
GetAPStation(iface="mon0", timeout=60)

我不知道如何过滤 Dot 11 以获得第 2 部分中的 mac 收件人,如果我需要信标帧或概率请求

好的,所以我发现可以在 Dot11Qos 层中使用 if (p.haslayer(scapy.Dot11QoS) and (p.addr1!="ff:ff:ff:ff:ff:ff") and (p.addr2== "ap mac")) :