Run this Python script on your kali terminal to scan your network for connected devices.
#!/usr/bin/env python
import scapy.all as scapy
import subprocess
import re
import maclookup
from maclookup import ApiClient
import logging
# 1. pip install maclookup
# 2. python3 sceptrescan.py
# 3. if ApiClient out of use, please get
# new ApiClient https://macaddress.io/
client = ApiClient('at_QY6om50bspgqg83KBf0fDHDaHbiRC')
#function to find gateway IP using subprocess and regex
def get_gateway():
get_route = subprocess.check_output(["ip route"], shell=True)
gateway_result = re.search(r"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]\
|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", str(get_route))
return gateway_result.group(0)
def scan(ip):
arp_request = scapy.ARP(pdst=ip) #create arp packet
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")#direct to mac address
arp_request_broadcast = broadcast/arp_request #join packets
answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0] #send and receive function
clients_list = []
for element in answered_list:
client_dict = {"ip":element[1].psrc, "mac": element[1].hwsrc}
mac_vendor = client.get_vendor(client_dict["mac"])
macmac = {"macvendor":mac_vendor}
client_dict.update(macmac)
clients_list.append(client_dict)
return clients_list
def print_result(results_list):
print("IP\t\tAt MAC Address\t Vendor Name")
print("------------------------------------------------")
for client in results_list:
print(client["ip"] + "\t" + client["mac"], client["macvendor"] )
#get gateway ip and add subnet
gateway = get_gateway()
gateway = (gateway + "/24")
print("Scanning Gateway Address " + gateway + " for network clients")
scan_result = scan(gateway)
print_result(scan_result)