Skip to content

Commit 94677e7

Browse files
authored
Merge pull request #673 from NullArray/dev-beta
Fixes some issues
2 parents ba72dd0 + 104b773 commit 94677e7

File tree

5 files changed

+102
-70
lines changed

5 files changed

+102
-70
lines changed

Docker/Dockerfile

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
FROM kalilinux/kali-linux-docker
1+
FROM phocean/msf
22

3-
RUN apt update \
4-
&& apt install -y \
5-
apache2 \
6-
build-essential \
7-
git \
8-
metasploit-framework \
9-
postgresql \
10-
python-dev \
11-
python-pip
3+
COPY "entrypoint.sh" .
124

13-
RUN git clone https://github.com/NullArray/AutoSploit.git \
14-
&& pip install -r AutoSploit/requirements.txt
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
git \
8+
python-dev \
9+
python-pip \
10+
apache2
1511

16-
COPY database.yml /root/.msf4/database.yml
17-
18-
WORKDIR AutoSploit
19-
20-
EXPOSE 80 443 4444
21-
22-
ENTRYPOINT ["python", "autosploit.py"]
23-
# ENTRYPOINT ["bash"]
12+
RUN chmod +x entrypoint.sh && \
13+
git clone https://github.com/NullArray/AutoSploit.git && \
14+
pip install -r AutoSploit/requirements.txt
15+
16+
EXPOSE 4444
17+
CMD [ "./entrypoint.sh" ]

Docker/entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
/etc/init.d/postgresql start
4+
/etc/init.d/apache2 start
5+
cd AutoSploit/
6+
7+
python autosploit.py

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"
4+
VERSION = "3.1.1"
55

66

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

lib/creation/issue_creator.py

Lines changed: 78 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,25 @@
2323
raw_input = input
2424

2525

26+
def check_version_number(current_version):
27+
"""
28+
check the version number before creating an issue
29+
"""
30+
version_checker = re.compile(r"version.=.\S\d.\d.(\d)?", re.I)
31+
try:
32+
req = requests.get("https://raw.githubusercontent.com/NullArray/AutoSploit/master/lib/banner.py")
33+
available_version = version_checker.search(req.content).group().split("=")[-1].split('"')[1]
34+
if available_version != current_version:
35+
return False
36+
return True
37+
except Exception as e:
38+
return True
39+
40+
2641
def create_identifier(data):
42+
"""
43+
create the exception identifier
44+
"""
2745
obj = hashlib.sha1()
2846
try:
2947
obj.update(data)
@@ -83,7 +101,7 @@ def find_url(params):
83101
split_information = str(html).split("\n")
84102
for i, line in enumerate(split_information):
85103
if searcher.search(line) is not None:
86-
href = split_information[i - 1]
104+
href = split_information[i]
87105
if href is not None:
88106
soup = BeautifulSoup(href, "html.parser")
89107
for item in soup.findAll("a"):
@@ -93,13 +111,17 @@ def find_url(params):
93111

94112

95113
def hide_sensitive():
114+
"""
115+
hide sensitive information from the terminal
116+
"""
96117
sensitive = (
97118
"--proxy", "-P", "--personal-agent", "-q", "--query", "-C", "--config",
98119
"--whitelist", "--msf-path"
99120
)
100121
args = sys.argv
101122
for item in sys.argv:
102123
if item in sensitive:
124+
# TODO:/ we need to block the IP addresses in the -C argument
103125
try:
104126
item_index = args.index(item) + 1
105127
hidden = ''.join([x.replace(x, "*") for x in str(args[item_index])])
@@ -119,56 +141,66 @@ def request_issue_creation(path, arguments, error_message):
119141
"do you want to create an anonymized issue?[y/N]: "
120142
)
121143
if question.lower().startswith("y"):
122-
# gonna read a chunk of it instead of one line
123-
chunk = 4096
124-
with open(path) as data:
125-
identifier = create_identifier(data.read(chunk))
126-
# gotta seek to the beginning of the file since it's already been read `4096` into it
127-
data.seek(0)
128-
issue_title = "Unhandled Exception ({})".format(identifier)
129-
130-
issue_data = {
131-
"title": issue_title,
132-
"body": (
133-
"Autosploit version: `{}`\n"
134-
"OS information: `{}`\n"
135-
"Running context: `{}`\n"
136-
"Error meesage: `{}`\n"
137-
"Error traceback:\n```\n{}\n```\n"
138-
"Metasploit launched: `{}`\n".format(
139-
lib.banner.VERSION,
140-
platform.platform(),
141-
' '.join(sys.argv),
142-
error_message,
143-
open(path).read(),
144-
lib.settings.MSF_LAUNCHED,
144+
if check_version_number(lib.banner.VERSION):
145+
# gonna read a chunk of it instead of one line
146+
chunk = 4096
147+
with open(path) as data:
148+
identifier = create_identifier(error_message)
149+
# gotta seek to the beginning of the file since it's already been read `4096` into it
150+
data.seek(0)
151+
issue_title = "Unhandled Exception ({})".format(identifier)
152+
153+
issue_data = {
154+
"title": issue_title,
155+
"body": (
156+
"Autosploit version: `{}`\n"
157+
"OS information: `{}`\n"
158+
"Running context: `{}`\n"
159+
"Error mesage: `{}`\n"
160+
"Error traceback:\n```\n{}\n```\n"
161+
"Metasploit launched: `{}`\n".format(
162+
lib.banner.VERSION,
163+
platform.platform(),
164+
' '.join(sys.argv),
165+
error_message,
166+
open(path).read(),
167+
lib.settings.MSF_LAUNCHED,
168+
)
145169
)
146-
)
147-
}
170+
}
148171

149-
_json_data = json.dumps(issue_data)
150-
if sys.version_info > (3,): # python 3
151-
_json_data = _json_data.encode("utf-8")
172+
_json_data = json.dumps(issue_data)
173+
if sys.version_info > (3,): # python 3
174+
_json_data = _json_data.encode("utf-8")
152175

153-
if not ensure_no_issue(identifier):
154-
req = Request(
155-
url="https://api.github.com/repos/nullarray/autosploit/issues", data=_json_data,
156-
headers={"Authorization": "token {}".format(get_token(lib.settings.TOKEN_PATH))}
157-
)
158-
urlopen(req, timeout=10).read()
159-
lib.output.info(
160-
"issue has been generated with the title '{}', at the following "
161-
"URL '{}'".format(
162-
issue_title, find_url(identifier)
176+
if not ensure_no_issue(identifier):
177+
req = Request(
178+
url="https://api.github.com/repos/nullarray/autosploit/issues", data=_json_data,
179+
headers={"Authorization": "token {}".format(get_token(lib.settings.TOKEN_PATH))}
163180
)
164-
)
181+
urlopen(req, timeout=10).read()
182+
lib.output.info(
183+
"issue has been generated with the title '{}', at the following "
184+
"URL '{}'".format(
185+
issue_title, find_url(identifier)
186+
)
187+
)
188+
else:
189+
lib.output.error(
190+
"someone has already created this issue here: {}".format(find_url(identifier))
191+
)
192+
try:
193+
os.remove(path)
194+
except:
195+
pass
165196
else:
197+
sep = "-" * 35
166198
lib.output.error(
167-
"someone has already created this issue here: {}".format(find_url(identifier))
199+
"it appears you are not using the current version of AutoSploit please update to the newest version "
200+
"and try again, this can also happen when a new update has been pushed and the cached raw page has "
201+
"not been updated yet. If you feel this is the later please create and issue on AutoSploits Github "
202+
"page with the following info:"
168203
)
169-
try:
170-
os.remove(path)
171-
except:
172-
pass
204+
print("{}\n{}\n{}".format(sep, open(path).read(), sep))
173205
else:
174-
lib.output.info("the issue has been logged to a file in path: '{}'".format(path))
206+
lib.output.info("the issue has been logged to a file in path: '{}'".format(path))

lib/exploitation/exploiter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ def start_exploit(self, sep="*" * 10):
7878
if self.dry_run:
7979
lib.settings.close("dry run was initiated, exploitation will not be done")
8080

81-
lib.settings.MSF_LAUNCHED = True
82-
8381
today_printable = datetime.datetime.today().strftime("%Y-%m-%d_%Hh%Mm%Ss")
8482
current_run_path = path.join(lib.settings.RC_SCRIPTS_PATH, today_printable)
8583
try:
@@ -105,6 +103,7 @@ def start_exploit(self, sep="*" * 10):
105103
win_total = 0
106104
fail_total = 0
107105
skip_amount = 0
106+
lib.settings.MSF_LAUNCHED = True
108107

109108
for host in self.hosts:
110109
host = host.strip()
@@ -113,7 +112,7 @@ def start_exploit(self, sep="*" * 10):
113112
honey_score = api_calls.honeyscore_hook.HoneyHook(host, self.shodan_token).make_request()
114113
if honey_score >= self.compare_honey:
115114
lib.output.warning(
116-
"honeypot score ({}) is above requested, skipping target".format(honey_score)
115+
"honeypot score ({}) is above (or equal to) requested, skipping target".format(honey_score)
117116
)
118117
skip = True
119118
skip_amount += 1

0 commit comments

Comments
 (0)