我一直在使用数据包,这样做我已经制作了一些嗅探程序,其中拾取广播的数据包(其中一个在下面)。我想在我的程序中添加一种方法来告诉我设备MAC和(如果可能的话)他们在外部网络上被嗅探的IP地址(内部用于该网络)(扫描一个单独的网络)。我知道设备上的自动连接选项允许您查看设备IP / MAC以及它们过去连接到的网络(由于它们正在广播它),但据我所知,只有在他们在你的网络上。如果有任何办法可以做到这一点,那就太好了(比如airodump-ng)以下是代码:
#!/usr/bin/env python
import scapy
import os
import optparse
import sys
import socket
from scapy.all import *
import platform
os_type = platform.system()
if(os_type != "Linux"):
print("[-] Error. Made for Linux.")
try:
exit(0)
except:
sys.exit(1)
class c:
r = '\033[0;31m'
g = '\033[0;32n'
o = '\033[0;33m'
b = '\033[0;94m'
p = '\033[0;35m'
d = '\033[0;00m'
w = '\033[0;54m'
class ssid_fingerprint:
w_ssid = 'Dot11'
parser = optparse.OptionParser()
parser.add_option("-i", "--interface", action="store", dest="inter", help="Interface Protocal", default="no_interface")
(options, args) = parser.parse_args()
error = c.w+'['+c.r+'-'+c.w+'] '
if(options.inter=="no_interface"):
print(error+'You must supply a interface')
try:
exit(0)
except:
sys.exit(1)
#elif('mon' not in str(options.inter)):
# print(error+'You must use a monitor interface')
# try:
# exit(0)
# except:
# sys.exit(1)
ssid_captures = []
#subprocess.Popen(['ifconfig '+options.inter+' down ; ifconfig '+options.inter+' promisc ; ifconfig '+options.inter+' up'], shell=True)
while True:
try:
ssid_packet = sniff(iface=options.inter, count = 1)
for pck in ssid_packet:
if(pck.haslayer(Dot11)):
try:
ssid_layer = pck.getlayer(Dot11)
ssid_name = ssid_layer.info
ssid_mac = ssid_layer.addr2
ssid_string = str(ssid_name)+':'+str(ssid_mac)
if(ssid_string not in ssid_captures):
ssid_captures.append(str(ssid_name)+':'+str(ssid_mac))
print('[*] SSID: {} | SSID MAC: {}').format(ssid_name, ssid_mac)
except:
pass
except KeyboardInterrupt:
print("Captured SSID's:"),
print(ssid_captures)
try:
exit(0)
except:
sys.exit(1)
# except OSError:
# subprocess.Popen(['ifconfig '+options.inter+' down ; ifconfig '+options.inter+' promisc ; ifconfig '+options.inter+' up'], shell=True)
# except socket.error:
# pass
except:
raise