0

所以这是我的脚本:

#!/usr/bin/env python
import sys
from scapy.all import *
from subprocess import *

call(["clear"])

print "Probe Investigator"
print "-----------------------------------------------------"

intf = raw_input("Enter the Name of the interface to sniff: ")
print ("\n")
clients = []
uni = 0
mach = []

def phandle(p):
    if p.haslayer(Dot11ProbeReq):
        mac = p.addr2
        if p.haslayer(Dot11Elt):
            if p.ID == 0:
                ssid = p.info
                if ssid not in clients and ssid != "":
                    clients.append(ssid)
                    print len(clients),mac+"--Probing-->"+ssid
                    if mac not in mach:
                        mach.append(mac)
                        global uni
                        uni+=1              
                    else:   
                        return

sniff(iface=intf,prn=phandle, store=0)
print ("\n")
print "Unique MACs: ",uni

如您所见,我正在过滤探测请求并过滤以查看请求是否不是广播的,而是针对特定 SSID 的。我在wireshark中分析了探测请求,发现这些探测在层中也有一个标签没有221Dot11ELt ,它指定了供应商。如果我只是将p.ID == 0语句更改为p.ID == 221then 它应该在技术上给我供应商信息,但脚本只是挂起并且永远不会与脚本的其余部分一起前进。

如何从数据包中提取供应商信息?

我的 python 版本: 2.7.3(默认,2014 年 3 月 13 日,11:03:55)[GCC 4.7.2] 我的 linux 版本:发行商 ID:Kali 描述:Kali GNU/Linux 1.1.0 版本:1.1.0 代号: moto Linux 版本3.18.0-kali3-amd64 gcc 版本 4.7.2 Debian 4.7.2-5) ) #1 SMP Debian 3.18.6-1~kali2 (2015-03-02)

4

1 回答 1

1

一个探测请求包可能有好Dot11Elt几层,你需要遍历它们直到你找到想要的那一层,如下:

dot11elt = p.getlayer(Dot11Elt)
while dot11elt and dot11elt.ID != 221:
    dot11elt = dot11elt.payload.getlayer(Dot11Elt)
if dot11elt:
    ...  # dot11elt.ID == 221:
于 2015-05-01T14:44:16.947 回答