Skip to content

Commit 5b798b4

Browse files
author
Ekultek
committed
just making some minor updates here and there
1 parent 1586613 commit 5b798b4

File tree

6 files changed

+61
-52
lines changed

6 files changed

+61
-52
lines changed

lib/banner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import random
33

4-
VERSION = "3.1.3"
4+
VERSION = "3.1.4"
55

66

77
def banner_1(line_sep="#--", space=" " * 30):

lib/cmdline/cmd.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def optparser():
2525
"""
2626

2727
parser = argparse.ArgumentParser(
28-
usage="python autosploit.py -[c|z|s|a] -[q] QUERY\n"
29-
"{spacer}[-C] WORKSPACE LHOST LPORT [-e] [--whitewash] PATH\n"
30-
"{spacer}[--ruby-exec] [--msf-path] PATH [-E] EXPLOIT-FILE-PATH\n"
31-
"{spacer}[--rand-agent] [--proxy] PROTO://IP:PORT [-P] AGENT".format(
28+
usage="python autosploit.py -c[z|s|a] -q QUERY [-O|A]\n"
29+
"{spacer}[-C WORKSPACE LHOST LPORT] [-e] [--whitewash PATH] [-H]\n"
30+
"{spacer}[--ruby-exec] [--msf-path] PATH [-E EXPLOIT-FILE-PATH]\n"
31+
"{spacer}[--rand-agent] [--proxy PROTO://IP:PORT] [-P AGENT] [-D QUERY,QUERY,..]".format(
3232
spacer=" " * 28
3333
)
3434
)
@@ -42,8 +42,10 @@ def optparser():
4242
se.add_argument("-a", "--all", action="store_true", dest="searchAll",
4343
help="search all available search engines to gather hosts")
4444
save_results_args = se.add_mutually_exclusive_group(required=False)
45-
save_results_args.add_argument("-O", "--overwrite", action="store_true", dest="overwriteHosts",
46-
help="When specified, start from scratch by overwriting the host file with new search results.")
45+
save_results_args.add_argument(
46+
"-O", "--overwrite", action="store_true", dest="overwriteHosts",
47+
help="When specified, start from scratch by overwriting the host file with new search results."
48+
)
4749
save_results_args.add_argument("-A", "--append", action="store_true", dest="appendHosts",
4850
help="When specified, append discovered hosts to the host file.")
4951

@@ -65,7 +67,7 @@ def optparser():
6567
exploit.add_argument("-e", "--exploit", action="store_true", dest="startExploit",
6668
help="start exploiting the already gathered hosts")
6769
exploit.add_argument("-d", "--dry-run", action="store_true", dest="dryRun",
68-
help="Do not launch metasploit's exploits. Do everything else. msfconsole is never called.")
70+
help="msfconsole will never be called when this flag is passed")
6971
exploit.add_argument("-f", "--exploit-file-to-use", metavar="PATH", dest="exploitFile",
7072
help="Run AutoSploit with provided exploit JSON file.")
7173
exploit.add_argument("-H", "--is-honeypot", type=float, default=1000, dest="checkIfHoneypot", metavar="HONEY-SCORE",

lib/creation/issue_creator.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def check_version_number(current_version):
7878
try:
7979
req = requests.get("https://raw.githubusercontent.com/NullArray/AutoSploit/master/lib/banner.py")
8080
available_version = version_checker.search(req.content).group().split("=")[-1].split('"')[1]
81-
if available_version != current_version:
81+
if available_version > current_version:
8282
return False
8383
return True
8484
except Exception:
@@ -168,15 +168,25 @@ def hide_sensitive():
168168
args = sys.argv
169169
for item in sys.argv:
170170
if item in sensitive:
171-
# TODO:/ we need to block the IP addresses in the -C argument
172-
try:
173-
item_index = args.index(item) + 1
174-
hidden = ''.join([x.replace(x, "*") for x in str(args[item_index])])
175-
args.pop(item_index)
176-
args.insert(item_index, hidden)
171+
if item in ["-C", "--config"]:
172+
try:
173+
item_index = args.index("-C") + 1
174+
except ValueError:
175+
item_index = args.index("--config") + 1
176+
for _ in range(3):
177+
hidden = ''.join([x.replace(x, '*') for x in str(args[item_index])])
178+
args.pop(item_index+_)
179+
args.insert(item_index, hidden)
177180
return ' '.join(args)
178-
except:
179-
return ' '.join([item for item in sys.argv])
181+
else:
182+
try:
183+
item_index = args.index(item) + 1
184+
hidden = ''.join([x.replace(x, "*") for x in str(args[item_index])])
185+
args.pop(item_index)
186+
args.insert(item_index, hidden)
187+
return ' '.join(args)
188+
except:
189+
return ' '.join([item for item in sys.argv])
180190

181191

182192
def request_issue_creation(path, arguments, error_message):

lib/exploitation/exploiter.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class AutoSploitExploiter(object):
4040
sorted_modules = []
4141

4242
def __init__(self, configuration, all_modules, hosts=None, **kwargs):
43+
self.hosts = hosts
4344
self.hosts = hosts
4445
self.configuration = configuration
4546
self.mods = all_modules
@@ -89,14 +90,13 @@ def start_exploit(self, sep="*" * 10):
8990
report_path = path.join(current_run_path, "report.csv")
9091
with open(report_path, 'w') as f:
9192
csv_file = csv.writer(f, quoting=csv.QUOTE_ALL)
92-
csv_file.writerow(['Target Host',
93-
'Date (UTC)',
94-
'MSF Module',
95-
"LocalHost",
96-
"Listening Port",
97-
"Successful Logs",
98-
"Failure Logs",
99-
"All Logs"])
93+
csv_file.writerow(
94+
[
95+
'Target Host', 'Date (UTC)', 'MSF Module',
96+
"LocalHost", "Listening Port", "Successful Logs",
97+
"Failure Logs", "All Logs"
98+
]
99+
)
100100

101101
lib.output.info("Launching exploits against {hosts_len} hosts:".format(hosts_len=len(self.hosts)))
102102

@@ -117,7 +117,7 @@ def start_exploit(self, sep="*" * 10):
117117
skip = True
118118
skip_amount += 1
119119
else:
120-
lib.output.misc_info("{} does not appear to be a honeypot, continuing attack")
120+
lib.output.misc_info("{} does not appear to be a honeypot, continuing attack".format(host))
121121
skip = False
122122
else:
123123
skip = False
@@ -188,27 +188,22 @@ def start_exploit(self, sep="*" * 10):
188188
ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
189189
msf_output_lines = [ansi_escape.sub('', x) for x in output if re.search('\[.\]', x)]
190190

191-
msf_wins = [x for x in msf_output_lines if re.search('\[\+\]', x) or
192-
'Meterpreter' in x or
193-
'Session' in x or
194-
'Sending stage' in x]
195-
196-
msf_fails = [x for x in msf_output_lines if re.search('\[-\]', x)]
191+
msf_wins = [
192+
x for x in msf_output_lines if re.search('\[\+\]', x) or
193+
'Meterpreter' in x or 'Session' in x or 'Sending stage' in x
194+
]
195+
msf_fails = [x for x in msf_output_lines if re.search('\[-\]', x) and 'Background' not in x]
197196

198197
if len(msf_wins):
199198
win_total += 1
200199
if len(msf_fails):
201200
fail_total += 1
202201

203202
csv_file = csv.writer(f, quoting=csv.QUOTE_ALL)
204-
csv_file.writerow([rhost,
205-
today_printable,
206-
module_name,
207-
lhost,
208-
lport,
209-
linesep.join(msf_wins),
210-
linesep.join(msf_fails),
211-
linesep.join(msf_output_lines)])
203+
csv_file.writerow([
204+
rhost, today_printable, module_name, lhost, lport,
205+
linesep.join(msf_wins), linesep.join(msf_fails), linesep.join(msf_output_lines)
206+
])
212207

213208
print("")
214209
lib.output.info("{}RESULTS{}".format(sep, sep))

lib/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def complete_text(self, text, state):
5151
exploit/run/attack Run the exploits on the already gathered hosts
5252
search/api/gather Search the API's for hosts
5353
exit/quit Exit the terminal session
54-
single Load a single host into the file
54+
single Load a single host into the file, or multiple hosts separated by a comma (1,2,3,..)
5555
personal/custom Load a custom host file
5656
tokens/reset Reset API tokens if needed
5757
external View loaded external commands

lib/term/terminal.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,22 +308,24 @@ def do_add_single_host(self, ip):
308308
Explanation:
309309
------------
310310
Add a single host by IP address
311+
Or a list of single hosts separatedd by a comma
311312
312313
Parameters:
313314
-----------
314315
:param ip: IP address to be added
315316
316317
Examples:
317318
---------
318-
single 89.76.12.124
319+
single 89.76.12.124[89.76.12.43,89.90.65.78,...]
319320
"""
320-
validated_ip = lib.settings.validate_ip_addr(ip)
321-
if not validated_ip:
322-
lib.output.error("provided IP '{}' is invalid, try again".format(ip))
323-
else:
324-
with open(lib.settings.HOST_FILE, "a+") as hosts:
325-
hosts.write(ip + "\n")
326-
lib.output.info("host '{}' saved to hosts file".format(ip))
321+
for item in ip.split(","):
322+
validated_ip = lib.settings.validate_ip_addr(item)
323+
if not validated_ip:
324+
lib.output.error("provided IP '{}' is invalid, try again".format(ip))
325+
else:
326+
with open(lib.settings.HOST_FILE, "a+") as hosts:
327+
hosts.write(item + "\n")
328+
lib.output.info("host '{}' saved to hosts file".format(item))
327329

328330
def do_quit_terminal(self, save_history=True):
329331
"""
@@ -518,7 +520,7 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
518520
lib.output.error(
519521
"must provide at least LHOST, LPORT, workspace name with `{}` keyword "
520522
"(IE {} 127.0.0.1 9076 default [whitelist-path] [honeycheck])".format(
521-
choice.strip(), choice.strip()
523+
choice.split(" ")[0].strip(), choice.split(" ")[0].strip()
522524
)
523525
)
524526
else:
@@ -574,7 +576,7 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
574576
lib.output.error(
575577
"must provide a list of API names after `{}` keyword and query "
576578
"(IE {} shodan,censys apache2)".format(
577-
choice.strip(), choice.strip()
579+
choice.split(" ")[0].strip(), choice.split(" ")[0].strip()
578580
)
579581
)
580582
else:
@@ -605,7 +607,7 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
605607
lib.output.error(
606608
"must supply API name with `{}` keyword along with "
607609
"new token (IE {} shodan mytoken123 [userID (censys)])".format(
608-
choice.strip(), choice.strip()
610+
choice.split(" ")[0].strip(), choice.split(" ")[0].strip()
609611
)
610612
)
611613
else:

0 commit comments

Comments
 (0)