Untitled
unknown
plain_text
a year ago
1.6 kB
2
Indexable
Never
import scapy.all as scapy import requests import json import time WEBHOOK_URL = "https://webhook.site/898bae18-a5de-4100-8acb-1db15a02081e" NETWORK_IP = "192.168.0.0/24" SCAN_INTERVAL = 5 # seconds MAX_SCAN_ITERATIONS = 10 # maximum number of network scans def get_mac(ip): arp_request = scapy.ARP(pdst=ip) broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") arp_request_broadcast = broadcast/arp_request answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0] return answered_list[0][1].hwsrc if answered_list else None def scan_network(): arp_request = scapy.ARP(pdst=NETWORK_IP) broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") arp_request_broadcast = broadcast/arp_request answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0] devices = [] for item in answered_list: mac_address = item[1].hwsrc ip_address = item[1].psrc device = {"ip": ip_address, "mac": mac_address} devices.append(device) return devices def send_webhook(devices): data = {"devices": devices} headers = {'Content-type': 'application/json'} try: response = requests.post(WEBHOOK_URL, data=json.dumps(data), headers=headers) response.raise_for_status() print("Webhook sent successfully!") except requests.exceptions.RequestException as e: print(f"Failed to send webhook: {e}") iteration = 0 while iteration < MAX_SCAN_ITERATIONS: devices = scan_network() send_webhook(devices) iteration += 1 time.sleep(SCAN_INTERVAL)