Skip to content

Commit

Permalink
fixed resolv.conf error in termux, imporved exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhiteh4t committed May 18, 2024
1 parent 486b094 commit 5c8b209
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def dnsrec(domain, output, data):
'TA', 'TKEY', 'TLSA', 'TSIG', 'TXT', 'URI', 'ZONEMD']
full_ans = []

res = dns.asyncresolver.Resolver()
res = dns.asyncresolver.Resolver(configure=False)
res.nameservers = ['1.1.1.1', '1.0.0.1', '8.8.8.8', '8.8.4.4', '9.9.9.9', '149.112.112.112']


Expand All @@ -41,6 +41,8 @@ async def fetch_records(res, domain, record):
log_writer(f'[dns] Exception = {exc}')
except dns.resolver.NoMetaqueries as exc:
log_writer(f'[dns] Exception = {exc}')
except dns.resolver.NoNameservers as exc:
log_writer(f'[dns] Exception = {exc}')
except dns.resolver.NXDOMAIN as exc:
log_writer(f'[dns] Exception = {exc}')
print(f'{R}[-] {C}DNS Records Not Found!{W}')
Expand All @@ -58,11 +60,11 @@ async def fetch_records(res, domain, record):
try:
dmarc_ans = asyncio.run(fetch_records(res, dmarc_target, 'TXT'))
for entry in dmarc_ans:
print(f'{C}DMARK \t: {W}{entry.to_text()}')
print(f'{C}DMARC \t: {W}{entry.to_text()}')
if output != 'None':
result.setdefault('dmarc', []).append(f'DMARK : {entry.to_text()}')
result.setdefault('dmarc', []).append(f'DMARC : {entry.to_text()}')
except dns.resolver.NXDOMAIN as exc:
log_writer(f'[dns.dmark] Exception = {exc}')
log_writer(f'[dns.dmarc] Exception = {exc}')
print(f'\n{R}[-] {C}DMARC Record Not Found!{W}')
if output != 'None':
result.setdefault('dmarc', ['DMARC Record Not Found!'])
Expand Down

0 comments on commit 5c8b209

Please sign in to comment.