From 5c8b2091dc7a3f85f51a7d37a790d59fbf020f8e Mon Sep 17 00:00:00 2001 From: thewhiteh4t Date: Sat, 18 May 2024 16:09:43 +0530 Subject: [PATCH] fixed resolv.conf error in termux, imporved exception handling --- modules/dns.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/dns.py b/modules/dns.py index 8a6e9ae..0cc4630 100644 --- a/modules/dns.py +++ b/modules/dns.py @@ -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'] @@ -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}') @@ -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!'])