Skip to content

Commit

Permalink
debug fqdn_scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
ugomeguerditchian committed May 30, 2023
1 parent 43158f4 commit cb6e333
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
6 changes: 2 additions & 4 deletions api/global_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ def main(domain: str, config: configuration):
warn = ""
logger.info(f"[*] No subdomains of {domain} found from {os_file}")
else:
#remove duplicates
# remove duplicates
results = list(dict.fromkeys(results))
logger.info(
f"[*] {len(results)} subdomains of {domain} found"
)
logger.info(f"[*] {len(results)} subdomains of {domain} found")
except Exception as e:
logger.error(f"Impossible to get subdomains of {domain} from {os_file}")
continue
Expand Down
9 changes: 2 additions & 7 deletions api/hackertarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ def main(domain, handler: handler, key: str):
# get all the subdomain of the domain from hackertarget
# the url is https://api.hackertarget.com/hostsearch/?q={domain}
# key is the api key
if key :
url = (
"https://api.hackertarget.com/hostsearch/?q="
+ domain
+ "&apikey="
+ key
)
if key:
url = "https://api.hackertarget.com/hostsearch/?q=" + domain + "&apikey=" + key
else:
url = "https://api.hackertarget.com/hostsearch/?q=" + domain
try:
Expand Down
2 changes: 1 addition & 1 deletion configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Proxy :
activate: False
activate: True
file: null #path to file, one proxy per line
links:
https://raw.githubusercontent.com/mertguvencli/http-proxy-list/main/proxy-list/data.txt : "http"
Expand Down
17 changes: 12 additions & 5 deletions lib/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def clear_screen():
os.system("cls" if os.name == "nt" else "clear")


def fqdn_scanner(main_fqdn: str, config: configuration, res: result, recursive: int = 0):
def fqdn_scanner(
main_fqdn: str, config: configuration, res: result, recursive: int = 0
):
logger.info("[*] Scanning fqdn {}".format(main_fqdn))
main_domain = domain(main_fqdn, config)
if main_domain.ip == "Dead":
Expand Down Expand Up @@ -100,7 +102,10 @@ def fqdn_scanner(main_fqdn: str, config: configuration, res: result, recursive:
sub_domain_future = executor.submit(domain, fqdn, config)
futures_domain_recursive[fqdn] = sub_domain_future
futures_get_subs.append(
executor.submit(sub_domain_future.result().get_subs, config.ip_trough_proxy)
executor.submit(
sub_domain_future.result().get_subs,
config.ip_trough_proxy,
)
)
logger.info(
"[*] Waiting for {} threads to finish to getting subs".format(
Expand All @@ -115,7 +120,11 @@ def fqdn_scanner(main_fqdn: str, config: configuration, res: result, recursive:
# remove duplicates
subs = list(dict.fromkeys(subs))
for fqdn in tqdm(subs, desc="Processing subdomains", ncols=100):
if fqdn == "localhost" or config.is_there_scope() or fqdn not in futures_domain_recursive and not futures_scope[fqdn] :
if (
fqdn == "localhost"
or config.is_there_scope()
or fqdn not in futures_domain_recursive
):
continue
sub_domain = futures_domain_recursive[fqdn].result()
if sub_domain.ip == "Dead":
Expand All @@ -132,8 +141,6 @@ def fqdn_scanner(main_fqdn: str, config: configuration, res: result, recursive:
res.status()




def ip_scanner(ip: str, config: configuration, res: result, recursive: int = 0):
ip_obj = ip_lib.ip(ip, config)
res.add_ip(ip_obj)
Expand Down
13 changes: 10 additions & 3 deletions lib/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def get(self, url, params=None, headers=None, redirect=True, until_ok=False):
while True:
if not self.there_is_proxy():
try:
data = http.request("GET", url, headers=headers, timeout=3.0, redirect=redirect)
data = http.request(
"GET", url, headers=headers, timeout=3.0, redirect=redirect
)
except:
data = None
return data
Expand Down Expand Up @@ -131,12 +133,17 @@ def get(self, url, params=None, headers=None, redirect=True, until_ok=False):
)
try:
# don't use proxy
data = http.request("GET", url, headers=headers, timeout=3.0, redirect=redirect)
data = http.request(
"GET",
url,
headers=headers,
timeout=3.0,
redirect=redirect,
)
except:
data = None
return data


def connect(self, ip: str, port: int):
"""Connect to the port using a random socks proxy"""
if self.socks5_proxy == []:
Expand Down

0 comments on commit cb6e333

Please sign in to comment.