Skip to content

Commit 778bcce

Browse files
author
ekultek
committed
fixed the ID call for censys, will now also prompt for an ID instead of just the API key
1 parent 28a5c86 commit 778bcce

File tree

2 files changed

+70
-8
lines changed

2 files changed

+70
-8
lines changed

autosploit.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,63 @@ def try_shodan():
557557

558558
if __name__ == "__main__":
559559

560+
'''from api_calls import (
561+
shodan,
562+
censys,
563+
zoomeye
564+
)
565+
from lib.settings import (
566+
load_api_keys,
567+
API_URLS,
568+
AUTOSPLOIT_PROMPT
569+
)
570+
571+
from lib.output import (
572+
prompt,
573+
info,
574+
warning
575+
)
576+
577+
tokens = load_api_keys()
578+
579+
possible_apis = API_URLS.keys()
580+
581+
def get_query():
582+
query = prompt("enter your search query")
583+
return query
584+
585+
selected = False
586+
info_msg = "searching {} API with query '{}'"
587+
info("pick a search engine")
588+
for i, api in enumerate(sorted(possible_apis), start=1):
589+
print("{}. {}".format(i, api))
590+
591+
while not selected:
592+
choice = raw_input(AUTOSPLOIT_PROMPT)
593+
try:
594+
choice = int(choice)
595+
if choice == 1:
596+
selected = True
597+
query = get_query()
598+
info(info_msg.format("Shodan", query))
599+
censys.CensysAPIHook(tokens["censys"][1], tokens["censys"][0], query).censys()
600+
elif choice == 2:
601+
selected = True
602+
query = get_query()
603+
info(info_msg.format("Censys", query))
604+
shodan.ShodanAPIHook(tokens["shodan"][0], query).shodan()
605+
elif choice == 3:
606+
query = get_query()
607+
selected = True
608+
info("ZoomEye token will be loaded automatically")
609+
info(info_msg.format("Zoomeye", query))
610+
zoomeye.ZoomEyeAPIHook(query).zoomeye()
611+
else:
612+
warning("choice must be between 1-{}".format(len(API_URLS.keys())))
613+
except:
614+
warning("choice must be integer not string")'''
615+
616+
560617
logo()
561618

562619
if len(sys.argv) > 1:

lib/settings.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import psutil
66

77
import lib.output
8+
import api_calls
89

910

1011
HOST_FILE = "{}/hosts.txt".format(os.getcwd())
@@ -13,8 +14,8 @@
1314
PLATFORM_PROMPT = "\n{}@\033[36mPLATFORM\033[0m$ ".format(getpass.getuser())
1415
AUTOSPLOIT_PROMPT = "\n\033[31m{}\033[0m@\033[36mautosploit\033[0m# ".format(getpass.getuser())
1516
API_KEYS = {
16-
"censys": "{}/etc/tokens/censys.key".format(os.getcwd()),
17-
"shodan": "{}/etc/tokens/shodan.key".format(os.getcwd())
17+
"censys": ("{}/etc/tokens/censys.key".format(os.getcwd()), "{}/etc/tokens/censys.id".format(os.getcwd())),
18+
"shodan": ("{}/etc/tokens/shodan.key".format(os.getcwd()), )
1819
}
1920
API_URLS = {
2021
"shodan": "https://api.shodan.io/shodan/host/search?key={token}&query={query}",
@@ -94,14 +95,18 @@ def makedir(dir):
9495

9596
makedir(path)
9697
for key in API_KEYS.keys():
97-
if not os.path.isfile(API_KEYS[key]):
98+
if not os.path.isfile(API_KEYS[key][0]):
9899
access_token = lib.output.prompt("enter your {} API token".format(key.title()), lowercase=False)
99-
with open(API_KEYS[key], "a+") as log:
100+
if key.lower() == "censys":
101+
identity = lib.output.prompt("enter your {} ID".format(key.title()), lowercase=False)
102+
with open(API_KEYS[key][1], "a+") as log:
103+
log.write(identity)
104+
with open(API_KEYS[key][0], "a+") as log:
100105
log.write(access_token.strip())
101106
else:
102-
lib.output.info("{} API token loaded from {}".format(key.title(), API_KEYS[key]))
107+
lib.output.info("{} API token loaded from {}".format(key.title(), API_KEYS[key][0]))
103108
api_tokens = {
104-
"censys": open(API_KEYS["censys"]).read(),
105-
"shodan": open(API_KEYS["shodan"]).read()
109+
"censys": (open(API_KEYS["censys"][0]).read(), open(API_KEYS["censys"][1]).read()),
110+
"shodan": (open(API_KEYS["shodan"][0]).read(), )
106111
}
107-
return api_tokens
112+
return api_tokens

0 commit comments

Comments
 (0)