From 724714cd6f345524576197074b1fc2c0ae0b498c Mon Sep 17 00:00:00 2001 From: thewhiteh4t Date: Sat, 22 Jun 2024 13:58:46 +0530 Subject: [PATCH] read api keys from env vars --- modules/subdomain_modules/anubis_subs.py | 8 ++-- modules/subdomain_modules/bevigil_subs.py | 41 +++++++++++--------- modules/subdomain_modules/certspot_subs.py | 8 ++-- modules/subdomain_modules/crtsh_subs.py | 7 ++-- modules/subdomain_modules/fb_subs.py | 30 ++++++++++---- modules/subdomain_modules/htarget_subs.py | 6 +-- modules/subdomain_modules/shodan_subs.py | 30 ++++++++++---- modules/subdomain_modules/sonar_subs.py | 8 ++-- modules/subdomain_modules/thcrowd_subs.py | 8 ++-- modules/subdomain_modules/thminer_subs.py | 8 ++-- modules/subdomain_modules/virustotal_subs.py | 30 ++++++++++---- modules/subdomain_modules/wayback_subs.py | 6 +-- 12 files changed, 119 insertions(+), 71 deletions(-) diff --git a/modules/subdomain_modules/anubis_subs.py b/modules/subdomain_modules/anubis_subs.py index f1c36b8..187c320 100644 --- a/modules/subdomain_modules/anubis_subs.py +++ b/modules/subdomain_modules/anubis_subs.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 +from json import loads +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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def anubisdb(hostname, session): print(f'{Y}[!] {C}Requesting {G}AnubisDB{W}') diff --git a/modules/subdomain_modules/bevigil_subs.py b/modules/subdomain_modules/bevigil_subs.py index b5ad16e..aaa8183 100644 --- a/modules/subdomain_modules/bevigil_subs.py +++ b/modules/subdomain_modules/bevigil_subs.py @@ -1,31 +1,36 @@ #!/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 -from json import loads, dumps -import modules.subdom as parent -from modules.write_log import log_writer - async def bevigil(hostname, conf_path, session): - with open(f'{conf_path}/keys.json', 'r') as keyfile: - json_read = keyfile.read() - - json_load = loads(json_read) - try: - bevigil_key = json_load['bevigil'] - except KeyError: - log_writer('[bevigil_subs] key missing in keys.json') - with open(f'{conf_path}/keys.json', 'w') as outfile: - json_load['bevigil'] = None - bevigil_key = None - outfile.write( - dumps(json_load, sort_keys=True, indent=4) - ) + bevigil_key = environ.get('FR_BEVIGIL_KEY') + + if not bevigil_key: + log_writer('[bevigil_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: + bevigil_key = json_load['bevigil'] + except KeyError: + log_writer('[bevigil_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['bevigil'] = None + bevigil_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) if bevigil_key is not None: print(f'{Y}[!] {C}Requesting {G}BeVigil{W}') diff --git a/modules/subdomain_modules/certspot_subs.py b/modules/subdomain_modules/certspot_subs.py index a05b61a..e18f374 100644 --- a/modules/subdomain_modules/certspot_subs.py +++ b/modules/subdomain_modules/certspot_subs.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 +from json import loads +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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def certspot(hostname, session): print(f'{Y}[!] {C}Requesting {G}CertSpotter{W}') diff --git a/modules/subdomain_modules/crtsh_subs.py b/modules/subdomain_modules/crtsh_subs.py index 092c78a..d781d95 100644 --- a/modules/subdomain_modules/crtsh_subs.py +++ b/modules/subdomain_modules/crtsh_subs.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 +from json import loads +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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer async def crtsh(hostname, session): print(f'{Y}[!] {C}Requesting {G}crt.sh{W}') diff --git a/modules/subdomain_modules/fb_subs.py b/modules/subdomain_modules/fb_subs.py index 8f799e5..4155e37 100644 --- a/modules/subdomain_modules/fb_subs.py +++ b/modules/subdomain_modules/fb_subs.py @@ -1,22 +1,36 @@ #!/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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def fb_cert(hostname, conf_path, session): - with open(f'{conf_path}/keys.json', 'r') as keyfile: - json_read = keyfile.read() + fb_key = environ.get('FR_FB_KEY') - json_load = loads(json_read) - fb_key = json_load['facebook'] + if not fb_key: + log_writer('[fb_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: + fb_key = json_load['facebook'] + except KeyError: + log_writer('[fb_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['facebook'] = None + fb_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) if fb_key is not None: print(f'{Y}[!] {C}Requesting {G}Facebook{W}') diff --git a/modules/subdomain_modules/htarget_subs.py b/modules/subdomain_modules/htarget_subs.py index 9133623..a818213 100644 --- a/modules/subdomain_modules/htarget_subs.py +++ b/modules/subdomain_modules/htarget_subs.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 +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 -import modules.subdom as parent -from modules.write_log import log_writer - async def hackertgt(hostname, session): print(f'{Y}[!] {C}Requesting {G}HackerTarget{W}') diff --git a/modules/subdomain_modules/shodan_subs.py b/modules/subdomain_modules/shodan_subs.py index a1da409..6c3a20b 100644 --- a/modules/subdomain_modules/shodan_subs.py +++ b/modules/subdomain_modules/shodan_subs.py @@ -1,22 +1,36 @@ #!/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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def shodan(hostname, conf_path, session): - with open(f'{conf_path}/keys.json', 'r') as keyfile: - json_read = keyfile.read() + sho_key = environ.get('FR_SHODAN_KEY') - json_load = loads(json_read) - sho_key = json_load['shodan'] + if not sho_key: + log_writer('[shodan_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: + sho_key = json_load['shodan'] + except KeyError: + log_writer('[shodan_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['shodan'] = None + sho_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) if sho_key is not None: print(f'{Y}[!] {C}Requesting {G}Shodan{W}') diff --git a/modules/subdomain_modules/sonar_subs.py b/modules/subdomain_modules/sonar_subs.py index 6bc3cab..4938f1b 100644 --- a/modules/subdomain_modules/sonar_subs.py +++ b/modules/subdomain_modules/sonar_subs.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 +from json import loads +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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def sonar(hostname, session): print(f'{Y}[!] {C}Requesting {G}Sonar{W}') diff --git a/modules/subdomain_modules/thcrowd_subs.py b/modules/subdomain_modules/thcrowd_subs.py index 1ce44d6..b0add95 100644 --- a/modules/subdomain_modules/thcrowd_subs.py +++ b/modules/subdomain_modules/thcrowd_subs.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 +from json import loads +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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def thcrowd(hostname, session): print(f'{Y}[!] {C}Requesting {G}ThreatCrowd{W}') diff --git a/modules/subdomain_modules/thminer_subs.py b/modules/subdomain_modules/thminer_subs.py index afd570d..b2589d8 100644 --- a/modules/subdomain_modules/thminer_subs.py +++ b/modules/subdomain_modules/thminer_subs.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 +from json import loads +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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def thminer(hostname, session): print(f'{Y}[!] {C}Requesting {G}ThreatMiner{W}') diff --git a/modules/subdomain_modules/virustotal_subs.py b/modules/subdomain_modules/virustotal_subs.py index c5a6ae6..2677038 100644 --- a/modules/subdomain_modules/virustotal_subs.py +++ b/modules/subdomain_modules/virustotal_subs.py @@ -1,22 +1,36 @@ #!/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 -from json import loads -import modules.subdom as parent -from modules.write_log import log_writer - async def virust(hostname, conf_path, session): - with open(f'{conf_path}/keys.json', 'r') as keyfile: - json_read = keyfile.read() + vt_key = environ.get('FR_VT_KEY') - json_load = loads(json_read) - vt_key = json_load['virustotal'] + if not vt_key: + log_writer('[virustotal_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: + vt_key = json_load['virustotal'] + except KeyError: + log_writer('[virustotal_subs] key missing in keys.json') + with open(f'{conf_path}/keys.json', 'w') as outfile: + json_load['virustotal'] = None + vt_key = None + outfile.write( + dumps(json_load, sort_keys=True, indent=4) + ) if vt_key is not None: print(f'{Y}[!] {C}Requesting {G}VirusTotal{W}') diff --git a/modules/subdomain_modules/wayback_subs.py b/modules/subdomain_modules/wayback_subs.py index 219b9b4..3a9f8e1 100644 --- a/modules/subdomain_modules/wayback_subs.py +++ b/modules/subdomain_modules/wayback_subs.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 +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 -import modules.subdom as parent -from modules.write_log import log_writer - async def machine(hostname, session): print(f'{Y}[!] {C}Requesting {G}Wayback{W}')