From 572396ad81a8535fbb31639f22df4ae2b6d32985 Mon Sep 17 00:00:00 2001 From: thewhiteh4t Date: Fri, 28 Jun 2024 11:05:47 +0530 Subject: [PATCH] netlas added for subdomain enum --- modules/subdom.py | 4 +- modules/subdomain_modules/netlas_subs.py | 67 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 modules/subdomain_modules/netlas_subs.py diff --git a/modules/subdom.py b/modules/subdom.py index e21d0c6..e4deb69 100644 --- a/modules/subdom.py +++ b/modules/subdom.py @@ -17,6 +17,7 @@ from modules.subdomain_modules.htarget_subs import hackertgt from modules.subdomain_modules.binedge_subs import binedge from modules.subdomain_modules.zoomeye_subs import zoomeye +from modules.subdomain_modules.netlas_subs import netlas R = '\033[31m' # red G = '\033[32m' # green @@ -42,7 +43,8 @@ async def query(hostname, tout, conf_path): hackertgt(hostname, session), crtsh(hostname, session), binedge(hostname, conf_path, session), - zoomeye(hostname, conf_path, session) + zoomeye(hostname, conf_path, session), + netlas(hostname, conf_path, session) ) await session.close() diff --git a/modules/subdomain_modules/netlas_subs.py b/modules/subdomain_modules/netlas_subs.py new file mode 100644 index 0000000..1f4890d --- /dev/null +++ b/modules/subdomain_modules/netlas_subs.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +from os import environ +from json import loads, dumps +import modules.subdom as parent +from modules.write_log import log_writer + +R = '\033[31m' # red +G = '\033[32m' # green +C = '\033[36m' # cyan +W = '\033[0m' # white +Y = '\033[33m' # yellow + + +async def netlas(hostname, conf_path, session): + netlas_key = environ.get('FR_NETLAS_KEY') + + if not netlas_key: + log_writer('[netlas_subs] key missing in env') + with open(f'{conf_path}/keys.json', 'r') as keyfile: + json_read = keyfile.read() + + json_load = loads(json_read) + try: + netlas_key = json_load['netlas'] + except KeyError: + log_writer('[netlas_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['netlas'] = None + netlas_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) + + if netlas_key is not None: + print(f'{Y}[!] {C}Requesting {G}Netlas{W}') + url = f'https://app.netlas.io/api/domains/download/' + header = {'X-API-Key': netlas_key} + payload = { + 'q': f'domain: *.{hostname}', + 'fields': ['domain'], + 'source_type': 'include', + 'size': '200' + } + + try: + async with session.post(url, headers=header, data=payload) as resp: + status = resp.status + if status == 200: + json_data = loads(await resp.text()) + subdomains = [] + for entry in json_data: + subdomain = entry['data']['domain'] + subdomains.append(subdomain) + print(f'{G}[+] {Y}netlas {W}found {C}{len(subdomains)} {W}subdomains!') + parent.found.extend(subdomains) + else: + print(f'{R}[-] {C}netlas Status : {W}{status}') + log_writer(f'[netlas_subs] Status = {status}, expected 200') + + except Exception as exc: + print(f'{R}[-] {C}netlas Exception : {W}{exc}') + log_writer(f'[netlas_subs] Exception = {exc}') + else: + print(f'{Y}[!] Skipping netlas : {W}API key not found!') + log_writer('[netlas_subs] API key not found') + log_writer('[netlas_subs] Completed')