Pabed commited on
Commit
0241daf
·
verified ·
1 Parent(s): 87381c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -35,7 +35,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
 
36
  @tool
37
  def subfinder_tool(domain: str, subdomains: str) -> str:
38
- """A tool that checks which subdomains of a given domain exist by performing DNS lookups.
39
  Args:
40
  domain: The main domain (e.g., 'example.com').
41
  subdomains: A comma-separated list of subdomains to check (e.g., 'www,mail,blog').
@@ -49,11 +49,13 @@ def subfinder_tool(domain: str, subdomains: str) -> str:
49
  continue
50
  full_domain = f"{sub}.{domain}"
51
  try:
52
- # Perform DNS lookup
53
- socket.gethostbyname(full_domain)
54
- valid_subdomains.append(full_domain)
55
- except socket.gaierror:
56
- continue # If domain doesn't resolve
 
 
57
  except Exception as e:
58
  return f"Error checking {full_domain}: {str(e)}"
59
 
 
35
 
36
  @tool
37
  def subfinder_tool(domain: str, subdomains: str) -> str:
38
+ """A tool that checks which subdomains of a given domain exist by querying a public DNS API.
39
  Args:
40
  domain: The main domain (e.g., 'example.com').
41
  subdomains: A comma-separated list of subdomains to check (e.g., 'www,mail,blog').
 
49
  continue
50
  full_domain = f"{sub}.{domain}"
51
  try:
52
+ # Query Google's DNS-over-HTTPS API
53
+ response = requests.get(
54
+ f"https://dns.google/resolve?name={full_domain}&type=A"
55
+ )
56
+ data = response.json()
57
+ if "Answer" in data:
58
+ valid_subdomains.append(full_domain)
59
  except Exception as e:
60
  return f"Error checking {full_domain}: {str(e)}"
61