Skip to content

Commit 75d4e50

Browse files
author
ekultek
committed
added TODO's for reference
1 parent e31bb3e commit 75d4e50

File tree

7 files changed

+71
-43
lines changed

7 files changed

+71
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ hosts.txt
55
secret.p
66
uid.p
77
etc/tokens/*
8+
autosploit_out/*

autosploit/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def main():
7777
loaded_tokens = load_api_keys()
7878
AutoSploitParser().parse_provided(opts)
7979

80+
# TODO[5] figure out why this isn't used anywhere
81+
# maybe we can just remove it, idk
8082
loaded_exploits = []
8183
if not opts.exploitFile:
8284
misc_info("checking if there are multiple exploit files")

lib/cmdline/cmd.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def single_run_args(opt, keys, loaded_modules):
154154
elif opt.appendHosts:
155155
search_save_mode = "a"
156156

157+
# TODO[4]:// move the searches into their own class and call it from the static method if a search is needed
158+
# this is ugly and i wanna change it
157159
if opt.searchCensys:
158160
lib.output.info(single_search_msg.format("Censys"))
159161
api_searches[2](

lib/exploitation/exploiter.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import datetime
2-
import csv
31
import re
2+
import csv
3+
import datetime
4+
45
from os import (
56
makedirs,
67
path,
@@ -37,8 +38,16 @@ def __init__(self, configuration, all_modules, hosts=None, **kwargs):
3738
self.hosts = hosts
3839
self.configuration = configuration
3940
self.mods = all_modules
41+
# TODO[1]:// fix the relevant module sorting
42+
# there's a bug in the way the modules are sorted right here
43+
# it creates a temp file wit hthe query name, but if the terminal
44+
# is run multiple times, it will not recreate the file and instead
45+
# opens an empty
4046
self.query = kwargs.get("query", lib.settings.QUERY_FILE_PATH)
41-
self.query_file = open(self.query).read()
47+
try:
48+
self.query_file = open(self.query).read()
49+
except:
50+
self.query_file = ""
4251
self.single = kwargs.get("single", None)
4352
self.ruby_exec = kwargs.get("ruby_exec", False)
4453
self.msf_path = kwargs.get("msf_path", None)
@@ -47,7 +56,7 @@ def __init__(self, configuration, all_modules, hosts=None, **kwargs):
4756
def view_sorted(self):
4857
"""
4958
view the modules that have been sorted by the relevance
50-
there is a chance this will display 0
59+
there is a chance this will display 0 (see TODO[1])
5160
"""
5261
for mod in self.sorted_modules:
5362
print(mod)
@@ -83,7 +92,6 @@ def start_exploit(self, sep="*" * 10):
8392
"All Logs"])
8493

8594
lib.output.info("Launching exploits against {hosts_len} hosts:".format(hosts_len=len(self.hosts)))
86-
lib.output.info("{}".format((linesep+"\t").join(self.hosts)))
8795

8896
win_total = 0
8997
fail_total = 0

lib/settings.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
RC_SCRIPTS_PATH = "{}/autosploit_out/".format(CUR_DIR)
3535

3636
# path to the file that will contain our query
37-
QUERY_FILE_PATH = tempfile.NamedTemporaryFile(delete=False).name
37+
# QUERY_FILE_PATH = tempfile.NamedTemporaryFile(delete=False).name
3838

3939
# default HTTP User-Agent
4040
DEFAULT_USER_AGENT = "AutoSploit/{} (Language=Python/{}; Platform={})".format(
@@ -151,9 +151,7 @@ def load_api_keys(unattended=False, path="{}/etc/tokens".format(CUR_DIR)):
151151
load the API keys from their .key files
152152
"""
153153

154-
"""
155-
make the directory if it does not exist
156-
"""
154+
# make the directory if it does not exist
157155
if not os.path.exists(path):
158156
os.mkdir(path)
159157

@@ -177,14 +175,9 @@ def load_api_keys(unattended=False, path="{}/etc/tokens".format(CUR_DIR)):
177175

178176
def cmdline(command):
179177
"""
180-
Function that allows us to store system command output in a variable.
181-
We'll change this later in order to solve the potential security
182-
risk that arises when passing untrusted input to the shell.
183-
184-
I intend to have the issue resolved by Version 1.5.0.
178+
send the commands through subprocess
185179
"""
186180

187-
#os.system(command)
188181
lib.output.info("Executing command '{}'".format(command.strip()))
189182
split_cmd = [x.strip() for x in command.split(" ") if x]
190183

@@ -205,6 +198,7 @@ def check_for_msf():
205198
"""
206199
return os.getenv("msfconsole", False) or distutils.spawn.find_executable("msfconsole")
207200

201+
208202
def logo():
209203
"""
210204
display a random banner from the banner.py file

lib/term/terminal.py

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def view_gathered_hosts(self):
8080

8181
def add_single_host(self):
8282
"""
83-
add a singluar host to the hosts.txt file and check if the host
83+
add a singular host to the hosts.txt file and check if the host
8484
will resolve to a true IP address, if it is not a true IP address
8585
you will be re-prompted for an IP address
8686
@@ -129,7 +129,13 @@ def gather_hosts(self, query, given_choice=None, proxy=None, agent=None):
129129
else:
130130
choice = given_choice
131131
while not searching:
132+
# TODO[2]:// bug in the animation, if the user chooses one search engine to search
133+
# the animation does not stop when the user chooses a single search engine, instead
134+
# the user will see the animation continuously until they either:
135+
# A) exit the terminal
136+
# B) search another search engine
132137
try:
138+
# something in here needs to change (see TODO[2])
133139
choice = int(choice)
134140
if choice == 1:
135141
choice_dict[choice](
@@ -204,29 +210,36 @@ def exploit_gathered_hosts(self, loaded_mods, hosts=None):
204210
ruby_exec=ruby_exec,
205211
msf_path=msf_path
206212
)
207-
sorted_mods = exploiter.sort_modules_by_query()
208-
choice = lib.output.prompt(
209-
"a total of {} modules have been sorted by relevance, would you like to display them[y/N]".format(
210-
len(sorted_mods)
213+
try:
214+
sorted_mods = exploiter.sort_modules_by_query()
215+
choice = lib.output.prompt(
216+
"a total of {} modules have been sorted by relevance, would you like to display them[y/N]".format(
217+
len(sorted_mods)
218+
)
211219
)
212-
)
213-
if not choice.lower().strip().startswith("y"):
214-
mods = lib.output.prompt("use relevant modules[y/N]")
215-
if mods.lower().startswith("n"):
216-
lib.output.info("starting exploitation with all loaded modules (total of {})".format(len(loaded_mods)))
217-
exploiter.start_exploit()
218-
elif mods.lower().startswith("y"):
219-
lib.output.info("starting exploitation with sorted modules (total of {})".format(len(sorted_mods)))
220-
exploiter.start_exploit()
221-
else:
222-
exploiter.view_sorted()
223-
mods = lib.output.prompt("use relevant modules[y/N]")
224-
if mods.lower().startswith("n"):
225-
lib.output.info("starting exploitation with all loaded modules (total of {})".format(len(loaded_mods)))
226-
exploiter.start_exploit()
227-
elif mods.lower().startswith("y"):
228-
lib.output.info("starting exploitation with sorted modules (total of {})".format(len(sorted_mods)))
229-
exploiter.start_exploit()
220+
221+
if not choice.lower().strip().startswith("y"):
222+
mods = lib.output.prompt("use relevant modules[y/N]")
223+
if mods.lower().startswith("n"):
224+
lib.output.info(
225+
"starting exploitation with all loaded modules (total of {})".format(len(loaded_mods)))
226+
exploiter.start_exploit()
227+
elif mods.lower().startswith("y"):
228+
lib.output.info("starting exploitation with sorted modules (total of {})".format(len(sorted_mods)))
229+
exploiter.start_exploit()
230+
else:
231+
exploiter.view_sorted()
232+
mods = lib.output.prompt("use relevant modules[y/N]")
233+
if mods.lower().startswith("n"):
234+
lib.output.info(
235+
"starting exploitation with all loaded modules (total of {})".format(len(loaded_mods)))
236+
exploiter.start_exploit()
237+
elif mods.lower().startswith("y"):
238+
lib.output.info("starting exploitation with sorted modules (total of {})".format(len(sorted_mods)))
239+
exploiter.start_exploit()
240+
except AttributeError:
241+
lib.output.warning("unable to sort modules by relevance")
242+
230243

231244
def custom_host_list(self, mods):
232245
"""
@@ -268,6 +281,7 @@ def __config_headers():
268281
for i in lib.settings.AUTOSPLOIT_TERM_OPTS.keys():
269282
print("{}. {}".format(i, lib.settings.AUTOSPLOIT_TERM_OPTS[i].title()))
270283
choice = raw_input(lib.settings.AUTOSPLOIT_PROMPT)
284+
# TODO[3] this is ugly so it needs to change
271285
try:
272286
choice = int(choice)
273287
if choice == 99:
@@ -296,6 +310,7 @@ def __config_headers():
296310
with open(lib.settings.QUERY_FILE_PATH, "a+") as _query:
297311
_query.write(query)
298312
proxy, agent = __config_headers()
313+
# possibly needs to change here (see TODO[2])
299314
self.gather_hosts(query, proxy=proxy, agent=agent)
300315
print(self.sep)
301316
elif choice == 1:

run_autosploit.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#!/bin/bash
22

33

4-
if [[ $# -lt 2 ]]; then
4+
# TODO[6] this causes an AttributeError somewhere
5+
6+
if [[ $# -lt 1 ]]; then
57
echo "Syntax:"
6-
echo -e "\t./run_autosploit.sh <whitelist.txt> <exposed_lport>"
8+
echo -e "\t./run_autosploit.sh PORT [WHITELIST]"
79
exit 1
810
fi
911

10-
WHITELIST=$1
11-
LPORT=$2
12+
WHITELIST=$2
13+
LPORT=$1
1214

1315
LHOST=`dig +short @resolver1.opendns.com myip.opendns.com`
1416
TIMESTAMP=`date +%s`
1517

16-
python autosploit.py --whitelist $WHITELIST -e -C "msf_autorun_${TIMESTAMP}" $LHOST $LPORT -f etc/json/default_modules.json
18+
if [[ ! $WHITELIST ]]; then
19+
python autosploit.py -e -C "msf_autorun_${TIMESTAMP}" $LHOST $LPORT -f etc/json/default_modules.json
20+
else
21+
python autosploit.py --whitelist $WHITELIST -e -C "msf_autorun_${TIMESTAMP}" $LHOST $LPORT -f etc/json/default_modules.json
22+
fi;

0 commit comments

Comments
 (0)