Skip to content

Commit

Permalink
Fixed truedomains
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjazeroone committed Sep 28, 2019
1 parent a9b2690 commit ee78abb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions dnschef.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def findnametodns(self,qname,nametodns):

# HACK: It is important to search the nametodns dictionary before iterating it so that
# global matching ['*.*.*.*.*.*.*.*.*.*'] will match last. Use sorting for that.
for domain,host in sorted(iter(nametodns.items()), key=operator.itemgetter(1)):
for domain,host in sorted(iter(nametodns.items()), key=operator.itemgetter(1), reverse=True):

# NOTE: It is assumed that domain name was already lowercased
# when it was loaded through --file, --fakedomains or --truedomains
Expand All @@ -337,7 +337,10 @@ def findnametodns(self,qname,nametodns):
break
else:
# Could be a real IP or False if we are doing reverse matching with 'truedomains'
return host
if host == 'False':
return False
else:
return host
else:
return False

Expand Down Expand Up @@ -624,27 +627,27 @@ def start_cooking(interface, nametodns, nameservers, tcp=False, ipv6=False, port
domain = domain.strip()

if fakeip:
nametodns["A"][domain] = False
nametodns["A"][domain] = 'False'
log.info(f"Cooking A replies to point to {options.fakeip} not matching: {domain}")
nametodns["A"]['*.*.*.*.*.*.*.*.*.*'] = fakeip

if fakeipv6:
nametodns["AAAA"][domain] = False
nametodns["AAAA"][domain] = 'False'
log.info(f"Cooking AAAA replies to point to {options.fakeipv6} not matching: {domain}")
nametodns["AAAA"]['*.*.*.*.*.*.*.*.*.*'] = fakeipv6

if fakemail:
nametodns["MX"][domain] = False
nametodns["MX"][domain] = 'False'
log.info(f"Cooking MX replies to point to {options.fakemail} not matching: {domain}")
nametodns["MX"]['*.*.*.*.*.*.*.*.*.*'] = fakemail

if fakealias:
nametodns["CNAME"][domain] = False
nametodns["CNAME"][domain] = 'False'
log.info(f"Cooking CNAME replies to point to {options.fakealias} not matching: {domain}")
nametodns["CNAME"]['*.*.*.*.*.*.*.*.*.*'] = fakealias

if fakens:
nametodns["NS"][domain] = False
nametodns["NS"][domain] = 'False'
log.info(f"Cooking NS replies to point to {options.fakens} not matching: {domain}")
nametodns["NS"]['*.*.*.*.*.*.*.*.*.*'] = fakealias

Expand Down

0 comments on commit ee78abb

Please sign in to comment.