我正在尝试发送 802.11 探测请求并从中接收探测响应。但结果并不好。
这是我的发送框架部分,我在python中使用Scapy
:
class Scapy80211():
def __init__(self,intf='wlan0',ssid='test',\
source='00:00:de:ad:be:ef',\
bssid='00:11:22:33:44:55',srcip='10.10.10.10'):
self.rates = "\x03\x12\x96\x18\x24\x30\x48\x60"
self.ssid = ssid
self.source = source
self.srcip = srcip
self.bssid = bssid
self.intf = intf
self.intfmon = intf + 'mon'
def ProbeReq(self,count=10,ssid='',dst='ff:ff:ff:ff:ff:ff', fc=0):
if not ssid: ssid=self.ssid
param = Dot11ProbeReq()
essid = Dot11Elt(ID='SSID',info=ssid)
rates = Dot11Elt(ID='Rates',info=self.rates)
dsset = Dot11Elt(ID='DSset',info='\x01')
pkt = RadioTap()\
/Dot11(type=0,subtype=4,FCfield=fc,addr1=dst,addr2=self.source,addr3=self.bssid)\
/param/essid/rates/dsset
print '[*] 802.11 Probe Request: SSID=[%s], count=%d' % (ssid,count)
try:
sendp(pkt,count=count,inter=0.1,verbose=1)
except:
raise
ssid = 'aa' #This is the AP I want to interact with
sdot11 = Scapy80211(intf='mon0')
sdot11.ProbeReq(ssid=ssid)
sniff(count=10, timeout=5, prn=PacketHandler, filter="type mgt subtype probe-resp")
我运行代码20次,有一次我可以得到结果。
此外,结果也有点奇怪,当我收到回复时,我当时经常收到很多。
那么,任何人都可以帮助我吗?你通常如何做收发工作?
我已将代码更改为srp()
。我删除了sniff()语句并用srp()替换sendp()。这是我的结果,我对它很困惑。
[*] 802.11 Probe Request: SSID=[aa], count=10
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Received 0 packets, got 0 answers, remaining 1 packets
[*] 802.11 Probe Request: SSID=[aa], count=10
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Begin emission:
Finished to send 1 packets.
Received 12 packets, got 0 answers, remaining 1 packets
我想从 aa 接收探测响应帧,我发送探测请求的帧。
所以结果没有答案?而且我不确定是否与我没有填写正确的参数如SSID,source,bssid相关。我应该将目的地从“ff:ff:ff:ff:ff:ff”更改为 aa 的MAC地址吗?
答案 0 :(得分:0)
除非我错了,否则您正在发送探测器,然后嗅探响应。如果答案到了,很可能会同时到达。
你应该使用srp()
函数来完成发送帧和匹配答案的工作。
答案 1 :(得分:0)
试试你的代码:
如果不是 ssid:ssid = self.ssid
而不是:
if ssid != "":ssid = self.ssid
希望对你有帮助!