我正在尝试执行发送 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、来源、bssid。我应该将目的地从 "ff:ff:ff:ff:ff:ff"更改为 aa 的 MAC 地址吗?
最佳答案
除非我错了,否则您正在发送探测,然后嗅探响应。如果一个答案到达,它很可能同时到达。
您可能应该使用 srp()
函数来完成发送帧和匹配答案的工作。
关于python - Scapy 发送探测请求并接收探测响应,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39685316/