From 76c2a00c8b15c001c5671182bb127b9dd1cdd26c Mon Sep 17 00:00:00 2001 From: thewhiteh4t Date: Tue, 25 Jun 2024 02:04:52 +0530 Subject: [PATCH] binaryedge and zoomeye added in subdomain enum --- modules/subdom.py | 10 ++-- modules/subdomain_modules/binedge_subs.py | 58 +++++++++++++++++++++ modules/subdomain_modules/zoomeye_subs.py | 62 +++++++++++++++++++++++ 3 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 modules/subdomain_modules/binedge_subs.py create mode 100644 modules/subdomain_modules/zoomeye_subs.py diff --git a/modules/subdom.py b/modules/subdom.py index ff846bc..e21d0c6 100644 --- a/modules/subdom.py +++ b/modules/subdom.py @@ -12,9 +12,11 @@ from modules.subdomain_modules.virustotal_subs import virust from modules.subdomain_modules.shodan_subs import shodan from modules.subdomain_modules.certspot_subs import certspot -from modules.subdomain_modules.wayback_subs import machine +# from modules.subdomain_modules.wayback_subs import machine from modules.subdomain_modules.crtsh_subs import crtsh from modules.subdomain_modules.htarget_subs import hackertgt +from modules.subdomain_modules.binedge_subs import binedge +from modules.subdomain_modules.zoomeye_subs import zoomeye R = '\033[31m' # red G = '\033[32m' # green @@ -36,9 +38,11 @@ async def query(hostname, tout, conf_path): virust(hostname, conf_path, session), shodan(hostname, conf_path, session), certspot(hostname, session), - #machine(hostname, session), + # machine(hostname, session), hackertgt(hostname, session), - crtsh(hostname, session) + crtsh(hostname, session), + binedge(hostname, conf_path, session), + zoomeye(hostname, conf_path, session) ) await session.close() diff --git a/modules/subdomain_modules/binedge_subs.py b/modules/subdomain_modules/binedge_subs.py new file mode 100644 index 0000000..0c4ce2c --- /dev/null +++ b/modules/subdomain_modules/binedge_subs.py @@ -0,0 +1,58 @@ +#!/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 binedge(hostname, conf_path, session): + binedge_key = environ.get('FR_BINEDGE_KEY') + + if not binedge_key: + log_writer('[binedge_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: + binedge_key = json_load['binedge'] + except KeyError: + log_writer('[binedge_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['binedge'] = None + binedge_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) + + if binedge_key is not None: + print(f'{Y}[!] {C}Requesting {G}BinaryEdge{W}') + url = f'https://api.binaryedge.io/v2/query/domains/subdomain/{hostname}' + header = {'X-key': binedge_key} + + try: + async with session.get(url, headers=header) as resp: + status = resp.status + if status == 200: + json_data = await resp.json() + subdomains = json_data['events'] + print(f'{G}[+] {Y}binedge {W}found {C}{len(subdomains)} {W}subdomains!') + parent.found.extend(subdomains) + else: + print(f'{R}[-] {C}binedge Status : {W}{status}') + log_writer(f'[binedge_subs] Status = {status}, expected 200') + + except Exception as exc: + print(f'{R}[-] {C}binedge Exception : {W}{exc}') + log_writer(f'[binedge_subs] Exception = {exc}') + else: + print(f'{Y}[!] Skipping binedge : {W}API key not found!') + log_writer('[binedge_subs] API key not found') + log_writer('[binedge_subs] Completed') diff --git a/modules/subdomain_modules/zoomeye_subs.py b/modules/subdomain_modules/zoomeye_subs.py new file mode 100644 index 0000000..b39d906 --- /dev/null +++ b/modules/subdomain_modules/zoomeye_subs.py @@ -0,0 +1,62 @@ +#!/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 zoomeye(hostname, conf_path, session): + zoomeye_key = environ.get('FR_ZOOMEYE_KEY') + + if not zoomeye_key: + log_writer('[zoomeye_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: + zoomeye_key = json_load['zoomeye'] + except KeyError: + log_writer('[zoomeye_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['zoomeye'] = None + zoomeye_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) + + if zoomeye_key is not None: + print(f'{Y}[!] {C}Requesting {G}ZoomEye{W}') + url = f'https://api.zoomeye.hk/domain/search?q={hostname}&type=0' + header = { + 'API-KEY': zoomeye_key, + 'User-Agent': 'curl' + } + + try: + async with session.get(url, headers=header) as resp: + status = resp.status + if status == 200: + json_data = await resp.json() + subdomain_list = json_data['list'] + subdomains = [subd['name'] for subd in subdomain_list] + print(f'{G}[+] {Y}zoomeye {W}found {C}{len(subdomains)} {W}subdomains!') + parent.found.extend(subdomains) + else: + print(f'{R}[-] {C}zoomeye Status : {W}{status}') + log_writer(f'[zoomeye_subs] Status = {status}, expected 200') + + except Exception as exc: + print(f'{R}[-] {C}zoomeye Exception : {W}{exc}') + log_writer(f'[zoomeye_subs] Exception = {exc}') + else: + print(f'{Y}[!] Skipping zoomeye : {W}API key not found!') + log_writer('[zoomeye_subs] API key not found') + log_writer('[zoomeye_subs] Completed')