Skip to content

Commit 91ae176

Browse files
committed
fixes the issue creation issue where if if you don't have the correct version it will not create an issue, also changes how the identifier is created
1 parent 6976580 commit 91ae176

File tree

3 files changed

+81
-49
lines changed

3 files changed

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

66

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

lib/creation/issue_creator.py

Lines changed: 78 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,26 @@
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+
print e
39+
return True
40+
41+
2642
def create_identifier(data):
43+
"""
44+
create the exception identifier
45+
"""
2746
obj = hashlib.sha1()
2847
try:
2948
obj.update(data)
@@ -83,7 +102,7 @@ def find_url(params):
83102
split_information = str(html).split("\n")
84103
for i, line in enumerate(split_information):
85104
if searcher.search(line) is not None:
86-
href = split_information[i - 1]
105+
href = split_information[i]
87106
if href is not None:
88107
soup = BeautifulSoup(href, "html.parser")
89108
for item in soup.findAll("a"):
@@ -93,13 +112,17 @@ def find_url(params):
93112

94113

95114
def hide_sensitive():
115+
"""
116+
hide sensitive information from the terminal
117+
"""
96118
sensitive = (
97119
"--proxy", "-P", "--personal-agent", "-q", "--query", "-C", "--config",
98120
"--whitelist", "--msf-path"
99121
)
100122
args = sys.argv
101123
for item in sys.argv:
102124
if item in sensitive:
125+
# TODO:/ we need to block the IP addresses in the -C argument
103126
try:
104127
item_index = args.index(item) + 1
105128
hidden = ''.join([x.replace(x, "*") for x in str(args[item_index])])
@@ -119,56 +142,66 @@ def request_issue_creation(path, arguments, error_message):
119142
"do you want to create an anonymized issue?[y/N]: "
120143
)
121144
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,
145+
if check_version_number(lib.banner.VERSION):
146+
# gonna read a chunk of it instead of one line
147+
chunk = 4096
148+
with open(path) as data:
149+
identifier = create_identifier(error_message)
150+
# gotta seek to the beginning of the file since it's already been read `4096` into it
151+
data.seek(0)
152+
issue_title = "Unhandled Exception ({})".format(identifier)
153+
154+
issue_data = {
155+
"title": issue_title,
156+
"body": (
157+
"Autosploit version: `{}`\n"
158+
"OS information: `{}`\n"
159+
"Running context: `{}`\n"
160+
"Error mesage: `{}`\n"
161+
"Error traceback:\n```\n{}\n```\n"
162+
"Metasploit launched: `{}`\n".format(
163+
lib.banner.VERSION,
164+
platform.platform(),
165+
' '.join(sys.argv),
166+
error_message,
167+
open(path).read(),
168+
lib.settings.MSF_LAUNCHED,
169+
)
145170
)
146-
)
147-
}
171+
}
148172

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

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)
177+
if not ensure_no_issue(identifier):
178+
req = Request(
179+
url="https://api.github.com/repos/nullarray/autosploit/issues", data=_json_data,
180+
headers={"Authorization": "token {}".format(get_token(lib.settings.TOKEN_PATH))}
163181
)
164-
)
182+
urlopen(req, timeout=10).read()
183+
lib.output.info(
184+
"issue has been generated with the title '{}', at the following "
185+
"URL '{}'".format(
186+
issue_title, find_url(identifier)
187+
)
188+
)
189+
else:
190+
lib.output.error(
191+
"someone has already created this issue here: {}".format(find_url(identifier))
192+
)
193+
try:
194+
os.remove(path)
195+
except:
196+
pass
165197
else:
198+
sep = "-" * 35
166199
lib.output.error(
167-
"someone has already created this issue here: {}".format(find_url(identifier))
200+
"it appears you are not using the current version of AutoSploit please update to the newest version "
201+
"and try again, this can also happen when a new update has been pushed and the cached raw page has "
202+
"not been updated yet. If you feel this is the later please create and issue on AutoSploits Github "
203+
"page with the following info:"
168204
)
169-
try:
170-
os.remove(path)
171-
except:
172-
pass
205+
print("{}\n{}\n{}".format(sep, open(path).read(), sep))
173206
else:
174207
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)