Skip to content

Commit 3d363d3

Browse files
author
ekultek
committed
you are now able to download modules, see the etc/text_files/links.txt file for links to the mods
1 parent a3f7d31 commit 3d363d3

File tree

7 files changed

+99
-82
lines changed

7 files changed

+99
-82
lines changed

autosploit/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
check_services,
1919
cmdline,
2020
close,
21+
download_modules_list,
2122
EXPLOIT_FILES_PATH,
2223
START_SERVICES_PATH
2324
)
@@ -40,6 +41,16 @@ def main():
4041

4142
opts = AutoSploitParser().optparser()
4243

44+
if opts.downloadModules is not None:
45+
info("downloading modules")
46+
for search in opts.downloadModules:
47+
downloaded = download_modules_list(search)
48+
info("downloaded {} file(s)".format(len(downloaded)))
49+
for f in downloaded:
50+
print("=> {}".format(f))
51+
info("new exploit paths have been added to JSON files, re-run autosploit to access them")
52+
exit(1)
53+
4354
logo()
4455
info("welcome to autosploit, give us a little bit while we configure")
4556
misc_info("checking your running platform")
@@ -73,7 +84,7 @@ def main():
7384
except psutil.NoSuchProcess:
7485
pass
7586
else:
76-
process_start_command = "`sudo systemctl {} start`"
87+
process_start_command = "`sudo service {} start`"
7788
if "darwin" in platform_running.lower():
7889
process_start_command = "`brew services start {}`"
7990
close(

etc/text_files/links.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
https://gist.githubusercontent.com/Ekultek/f51e6d61817721aa9341a1f1e66d3602/raw/82dfa8234d2f744c99bc277a1c73efc39770cff6/wordpress_exploits.txt
2+
https://gist.githubusercontent.com/Ekultek/76202c6fa170d6da501da5ab303f01f0/raw/da5205919f1a47f2ccc9c75ab26e1456ad91d3d4/all_exploits.txt
3+
https://gist.githubusercontent.com/Ekultek/e04f27632d40bf10da338b61b8416f95/raw/8c949dd2aa8047ded828b1220e13101b6f28d9ab/linux_exploits.txt
4+
https://gist.githubusercontent.com/Ekultek/d4658fe488f9edafe2b2edc1910e1983/raw/13c21c0ed20b4b10df79b93566fdd111df77f1ed/windows_exploits.txt
5+
https://gist.githubusercontent.com/Ekultek/219036c05e21d8352b4181cbe3df5f4f/raw/0e907b387fa2b35dc75cb94120172155d8d3eb3e/smb_exploits.txt
6+
https://gist.githubusercontent.com/Ekultek/066e1c9285f2a60d2b7103b4d1972864/raw/03d06809a3d79d51f19e3d0c77fb9783f961c485/samba_exploits.txt
7+
https://gist.githubusercontent.com/Ekultek/e9a5c7d37fc58b77bed241d8f2811e8a/raw/789839b93c2c8ce7cc6240cafedfa8e30c2ae4e1/all_rce_exploits.txt
8+
https://gist.githubusercontent.com/Ekultek/c69a01e688ed1739d9e572722ea37ed5/raw/63ead0225784de9389059745b1c869face015d7c/2018_rce_exploits.txt
9+
https://gist.githubusercontent.com/Ekultek/6d1d2d0a83715cb0314fead1ff2768a1/raw/b4fb17df1c3c09464741547ccff674262168a015/excellent_exploits.txt
10+
https://gist.githubusercontent.com/Ekultek/4a06da7d69f8f7f24542f7e978ad67a5/raw/5623ac8b9e4dc8e246e013dc7d7e2b5a31948d78/os_command_exploits.txt
11+
https://gist.githubusercontent.com/Ekultek/2d7e0d98b37b1d06676d409fe0c5b899/raw/f4fe9b3c400dcf86a8147fd903a6ee13e3fbe5f5/buffer_overflow_exploit.txt
12+
https://gist.githubusercontent.com/Ekultek/fdac157e66b82fea3075d2149e9aa1d3/raw/c5002d9c9e2918084e16b83fc1a9af06cf26bd05/osx_exploits.txt

lib/banner.py

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import os
22
import random
33

4-
VERSION = "2.2"
5-
COLOR_CODEX = {
6-
"red": "\033[31m", "bright red": "\033[1m\033[31m",
7-
"blue": "\033[36m", "bright blue": "\033[1m\033[36m",
8-
"green": "\033[32m", "bright green": "\033[1m\033[32m",
9-
"grey": "\033[37m", "white": "\033[1m\033[38m",
10-
"end": "\033[0m"
11-
}
4+
VERSION = "2.2.1"
125

136

147
def banner_1(line_sep="#--", space=" " * 30):
@@ -32,11 +25,9 @@ def banner_2():
3225
{blue}--+{end} {red}AutoSploit{end} {blue}+--{end}
3326
{blue}--+{end} NullArray/Eku {blue}+--{end}
3427
{blue}--+{end}{minor_space2} v({red}{vnum}{end}){minor_space} {blue}+--{end}
35-
""".format(
36-
vnum=VERSION, blue=COLOR_CODEX["blue"], red=COLOR_CODEX["red"], end=COLOR_CODEX["end"],
37-
minor_space=" " * 1 if len(VERSION) == 3 else "",
38-
minor_space2=" " * 1 if len(VERSION) == 3 else ""
39-
)
28+
""".format(vnum=VERSION, blue="\033[36m", red="\033[31m", end="\033[0m",
29+
minor_space=" " * 1 if len(VERSION) == 3 else "",
30+
minor_space2=" " * 1 if len(VERSION) == 3 else "")
4031
return banner
4132

4233

@@ -66,11 +57,11 @@ def banner_3():
6657
| / | |
6758
\ \__ | \__
6859
/\____=\ /\_____=\{end} v({vnum})'''''.format(
69-
green=COLOR_CODEX["bright green"], end=COLOR_CODEX["end"], vnum=VERSION
60+
green="\033[1m\033[32m", end="\033[0m", vnum=VERSION
7061
)
7162
return banner
7263

73-
64+
7465
def banner_4():
7566
banner = r"""
7667
{red} .__. , __. . , {end}
@@ -90,10 +81,8 @@ def banner_4():
9081
{blue}-----+ v({red}{vnum}{end}{blue}){spacer}+-----{end}
9182
{blue}-----------NullArray/Eku----------{end}
9283
{blue}__________________________________{end}
93-
""".format(
94-
vnum=VERSION, blue=COLOR_CODEX["blue"], red=COLOR_CODEX["red"], end=COLOR_CODEX["end"],
95-
spacer=" " * 9 if len(VERSION) == 3 else " " * 7
96-
)
84+
""".format(vnum=VERSION, blue="\033[36m", red="\033[31m", end="\033[0m",
85+
spacer=" " * 9 if len(VERSION) == 3 else " " * 7)
9786
return banner
9887

9988

@@ -114,50 +103,7 @@ def banner_5():
114103
{grey}| |{end}
115104
{grey}`-.___.-'{end}
116105
v({red}{version}{end})
117-
""".format(
118-
end=COLOR_CODEX["end"], grey=COLOR_CODEX["grey"], white=COLOR_CODEX["white"],
119-
version=VERSION, red=COLOR_CODEX["red"]
120-
)
121-
return banner
122-
123-
124-
def banner_6():
125-
banner = r"""{red}
126-
________ _____ _____.__ __ .__
127-
/ _____/___________ _/ ____\/ ____\__|/ |_|__|
128-
/ \ __\_ __ \__ \\ __\\ __\| \ __\ |
129-
\ \_\ \ | \// __ \| | | | | || | | |
130-
\______ /__| (____ /__| |__| |__||__| |__|
131-
\/ \/{end}{green}
132-
___________.__
133-
\__ ___/| |__ ____
134-
| | | | \_/ __ \
135-
| | | Y \ ___/
136-
|____| |___| /\___ >
137-
\/ \/{blue}
138-
__ __ .__ .___
139-
/ \ / \___________| | __| _/
140-
\ \/\/ / _ \_ __ \ | / __ |
141-
\ ( <_> ) | \/ |__/ /_/ |
142-
\__/\ / \____/|__| |____/\____ |
143-
\/ \/{end}{grey}
144-
__ __.__ __ .__
145-
/ \ / \__|/ |_| |__
146-
\ \/\/ / \ __\ | \
147-
\ /| || | | Y \
148-
\__/\ / |__||__| |___| /
149-
\/ \/{end}{white}
150-
___________ .__ .__ __
151-
\_ _____/__ _________ | | ____ |__|/ |_ ______
152-
| __)_\ \/ /\____ \| | / _ \| \ __\/ ___/
153-
| \> < | |_> > |_( <_> ) || | \___ \
154-
/_______ /__/\_ \| __/|____/\____/|__||__| /____ >
155-
\/ \/|__| \/ {end}
156-
{white}v{version}->NullArray/Eku{end}""".format(
157-
end=COLOR_CODEX["end"], grey=COLOR_CODEX["grey"], white=COLOR_CODEX["white"],
158-
version=VERSION, red=COLOR_CODEX["bright red"], green=COLOR_CODEX["bright green"],
159-
blue=COLOR_CODEX["bright blue"]
160-
)
106+
""".format(end="\033[0m", grey="\033[36m", white="\033[37m", version=VERSION, red="\033[31m")
161107
return banner
162108

163109

@@ -166,7 +112,7 @@ def banner_main():
166112
grab a random banner each run
167113
"""
168114
banners = [
169-
banner_6, banner_5, banner_4,
115+
banner_5, banner_4,
170116
banner_3, banner_2, banner_1
171117
]
172118
if os.getenv("Graffiti", False):

lib/cmdline/cmd.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def optparser():
4343
help="search all available search engines to gather hosts")
4444
save_results_args = se.add_mutually_exclusive_group(required=False)
4545
save_results_args.add_argument("-O", "--overwrite", action="store_true", dest="overwriteHosts",
46-
help="When specified, start from scratch by overwriting the host "
47-
"file with new search results.")
46+
help="When specified, start from scratch by overwriting the host file with new search results.")
4847
save_results_args.add_argument("-A", "--append", action="store_true", dest="appendHosts",
4948
help="When specified, append discovered hosts to the host file.")
5049

@@ -78,7 +77,9 @@ def optparser():
7877
misc.add_argument("--ethics", action="store_true", dest="displayEthics",
7978
help=argparse.SUPPRESS) # easter egg!
8079
misc.add_argument("--whitelist", metavar="PATH", dest="whitelist",
81-
help="only exploit hosts listed in the whitelist file")
80+
help="only exploit hosts listed in the whitelist file")
81+
misc.add_argument("-D", "--download", nargs="+", metavar="SEARCH1 SEARCH2 ...", dest="downloadModules",
82+
help="download new exploit modules with a provided search flag")
8283
opts = parser.parse_args()
8384
return opts
8485

@@ -139,6 +140,8 @@ def single_run_args(opt, keys, loaded_modules):
139140
lib.settings.close(
140141
"You should take this ethical lesson into consideration "
141142
"before you continue with the use of this tool:\n\n{}\n".format(ethic))
143+
if opt.downloadModules is not None:
144+
print "downloading MODULES!"
142145
if opt.exploitList:
143146
try:
144147
lib.output.info("converting {} to JSON format".format(opt.exploitList))

lib/jsonize.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,9 @@ def load_exploits(path, node="exploits"):
4848
"""
4949
retval = []
5050
file_list = os.listdir(path)
51-
exploit_files = []
5251
if len(file_list) != 1:
52+
lib.output.info("total of {} exploit files discovered for use, select one:".format(len(file_list)))
5353
for i, f in enumerate(file_list, start=1):
54-
# we're going to go ahead and make sure that the file is not a directory
55-
# this will allow us to create directories and fill them with JSON data
56-
# in the future
57-
if os.path.isfile(os.path.join(path, f)):
58-
exploit_files.append(f)
59-
# after we've done that, we'll go ahead and continue with what we where doing
60-
lib.output.info("total of {} exploit files discovered for use, select one:".format(len(exploit_files)))
61-
for i, f in enumerate(exploit_files, start=1):
6254
print("{}. '{}'".format(i, f[:-5]))
6355
action = raw_input(lib.settings.AUTOSPLOIT_PROMPT)
6456
selected_file = file_list[int(action) - 1]
@@ -77,7 +69,7 @@ def load_exploits(path, node="exploits"):
7769
return retval
7870

7971

80-
def text_file_to_dict(path):
72+
def text_file_to_dict(path, filename=None):
8173
"""
8274
take a text file path, and load all of the information into a `dict`
8375
send that `dict` into a JSON format and save it into a file. it will
@@ -89,7 +81,10 @@ def text_file_to_dict(path):
8981
for exploit in exploits.readlines():
9082
# load everything into the dict
9183
start_dict["exploits"].append(exploit.strip())
92-
filename_path = "{}/etc/json/{}.json".format(os.getcwd(), random_file_name())
84+
if filename is None:
85+
filename_path = "{}/etc/json/{}.json".format(os.getcwd(), random_file_name())
86+
else:
87+
filename_path = filename
9388
with open(filename_path, "a+") as exploits:
9489
# sort and indent to make it look pretty
9590
_data = json.dumps(start_dict, indent=4, sort_keys=True)

lib/settings.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@
3131
# one bash script to rule them all takes an argument via the operating system
3232
START_SERVICES_PATH = "{}/etc/scripts/start_services.sh".format(CUR_DIR)
3333

34+
# rc script path
3435
RC_SCRIPTS_PATH = "{}/autosploit_out/".format(CUR_DIR)
3536

37+
# links to all the downloadable modules
38+
MODULE_DOWNLOAD_LINKS = "{}/etc/text_files/links.txt".format(CUR_DIR)
39+
3640
# path to the file that will contain our query
3741
QUERY_FILE_PATH = tempfile.NamedTemporaryFile(delete=False).name
3842

@@ -293,3 +297,50 @@ def configure_requests(proxy=None, agent=None, rand_agent=False):
293297
}
294298

295299
return proxy_dict, header_dict
300+
301+
302+
def download_modules_list(search_string):
303+
"""
304+
download msf exploit module paths
305+
"""
306+
import re
307+
import requests
308+
import lib.jsonize
309+
try:
310+
from bs4 import BeautifulSoup
311+
except ImportError:
312+
close("in order to install modules you will need to install BeautifulSoup: `pip install beautifulsoup4`")
313+
314+
related = []
315+
downloaded_files = []
316+
317+
with open(MODULE_DOWNLOAD_LINKS) as downloads:
318+
for link in downloads.readlines():
319+
if search_string == "all":
320+
related.append(link.strip())
321+
else:
322+
searcher = re.compile(search_string, re.I)
323+
discovered = searcher.findall(link)
324+
if len(discovered) != 0:
325+
related.append(link.strip())
326+
lib.output.info("discovered a total of {} relevant file(s)".format(len(related)))
327+
for link in related:
328+
filepath = "{}/{}".format(EXPLOIT_FILES_PATH, link.split("/")[-1].replace(".txt", ".json"))
329+
if not os.path.exists(filepath):
330+
req = requests.get(link)
331+
random_temp_file_for_download = "/tmp/{}.AS".format(lib.jsonize.random_file_name())
332+
raw_content = req.content
333+
with open(random_temp_file_for_download, "a+") as tmp:
334+
raw_exploits = raw_content.split("\n")
335+
length = len(raw_exploits)
336+
lib.output.info("downloading a total of {} module paths".format(length))
337+
for i, line in enumerate(raw_exploits):
338+
tmp.write(line.split(" ")[3] + os.linesep)
339+
tmp.seek(0)
340+
lib.jsonize.text_file_to_dict(random_temp_file_for_download, filename=filepath)
341+
lib.output.misc_info("removing created tmp file: '{}'".format(random_temp_file_for_download))
342+
os.remove(random_temp_file_for_download)
343+
downloaded_files.append(filepath)
344+
else:
345+
lib.output.warning("file: '{}' already exists, skipping".format(filepath))
346+
return downloaded_files

lib/term/terminal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import os
22
import sys
3-
import tempfile
43

54
import lib.settings
65
import lib.output
7-
import lib.errors
86
import lib.exploitation.exploiter
97
import api_calls.shodan
108
import api_calls.zoomeye
@@ -242,6 +240,7 @@ def exploit_gathered_hosts(self, loaded_mods, hosts=None):
242240
except AttributeError:
243241
lib.output.warning("unable to sort modules by relevance")
244242

243+
245244
def custom_host_list(self, mods):
246245
"""
247246
provided a custom host list that will be used for exploitation
@@ -312,11 +311,11 @@ def __config_headers():
312311
with open(lib.settings.QUERY_FILE_PATH, "w") as _query:
313312
_query.write(query)
314313
except AttributeError:
314+
import tempfile # oooops
315315
filename = tempfile.NamedTemporaryFile(delete=False).name
316316
with open(filename, "w") as _query:
317317
_query.write(query)
318318
lib.settings.QUERY_FILE_PATH = filename
319-
print lib.settings.QUERY_FILE_PATH
320319
proxy, agent = __config_headers()
321320
# possibly needs to change here (see TODO[2])
322321
self.gather_hosts(query, proxy=proxy, agent=agent)

0 commit comments

Comments
 (0)