I am trying to act as a fake machine that sends ARP requests to my host (as well as other machines on a specific network using a specific interface). Here's my code snippet to spam a specific host IP address on a specific interface with ARP requests, from a fake MAC address/IP address:
import scapy.all
import threading
import time
import argparse
def arp_sender(iface, host_ip, guest_ip, guest_mac):
arp_req = scapy.layers.l2.ARP(psrc=guest_ip, pdst=host_ip)
bcast = scapy.layers.l2.Ether(
src=guest_mac, dst='ff:ff:ff:ff:ff:ff')
arp_req_bcast = bcast / arp_req
while True:
time.sleep(2)
scapy.all.sendp(arp_req_bcast, iface=iface)
if __name__ == "__main__":
pasrer = argparse.ArgumentParser()
pasrer.add_argument('--iface', '-i', required=True)
pasrer.add_argument('--host-ip', required=True)
pasrer.add_argument('--guest-ip', required=True)
pasrer.add_argument('--guest-mac', required=True)
args = pasrer.parse_args()
th = threading.Thread(target=arp_sender, args=(
args.iface, args.host_ip, args.guest_ip, args.guest_mac
))
th.start()
th.join()
While sniffing the responses on Wireshark, other hosts on the same network do respond to the ARP requests, but not my host where the fake machine that sends ARP requests resides in. I also tried to send ARP requests to a Virtualbox machine in my host and no response either. Is there something wrong with the way I am sending layer 2 packets using Scapy, or is there something else I need to do in my host to accept incoming packets from my script?
Edit
Tested on Windows 10 host. While testing, I have disabled all firewall (private, public, and domain).