Skip to content

Commit

Permalink
revised the logic to check open dns resolver.
Browse files Browse the repository at this point in the history
Previous logic was too simple to detect a related domain/IP is active as an open DNS resolver, and the chances of a false positive were too high.
  • Loading branch information
shamimrezasohag authored Jan 13, 2024
1 parent a36d1ec commit 9561325
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dns_security_analysis_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import argparse
import logging
import pandas as pd
import subprocess
import requests
from tqdm import tqdm

# Setup logging
Expand Down Expand Up @@ -46,13 +48,18 @@ def check_reverse_dns(self, ip_addresses):
except Exception as e:
ptr_records.append(str(e))
return "; ".join(ptr_records), "NOERROR"


#revised the logic to check the open_dns_resolver
def check_open_resolver(self, domain):
try:
self.resolver.resolve('example.com', 'A')
return "Potentially Open Resolver"
except Exception:
return "Not an Open Resolver"
result = subprocess.run(
["dig", "+short", "test.openresolver.com", "TXT", f"@{domain}"],
capture_output=True,
text=True
)
return "Open Resolver" if "ANSWER" in result.stdout else "Not an Open Resolver"
except subprocess.CalledProcessError:
return "Check Failed"

def check_dnssec(self, domain, nameservers):
if nameservers:
Expand Down

0 comments on commit 9561325

Please sign in to comment.