Skip to content

Commit 986910f

Browse files
authored
Merge pull request #1048 from NullArray/dev-beta
Checksums
2 parents 94677e7 + 7e586e6 commit 986910f

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

etc/text_files/checksum_link.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://gist.githubusercontent.com/Ekultek/cdf0d417ab5f023e99b89c1a4c7c3be8/raw/f91496698d4218565cba01b2d1c620efe80e6095/checksums.md5

lib/creation/issue_creator.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,53 @@
2323
raw_input = input
2424

2525

26+
def checksum(issue_template_path):
27+
"""
28+
verifies the checksums of the program before you can create an issue
29+
"""
30+
31+
file_skips = [
32+
"__init__", ".pyc", ".xml",
33+
".sample", "HEAD", "pack",
34+
"dev-beta", "description", "config",
35+
"exclude", "index", ".json",
36+
".gitignore", "LICENSE", "ISSUE_TEMPLATE",
37+
"README", "CONTRIBUTING", "hosts.txt",
38+
"requirements.txt", "checksum_link.txt",
39+
".key", ".id", ".csv"
40+
]
41+
current_checksums = []
42+
failed_checks = 0
43+
for root, sub, files in os.walk(lib.settings.CUR_DIR):
44+
for name in files:
45+
if not any(c in name for c in file_skips):
46+
path = os.path.join(root, name)
47+
check = hashlib.md5()
48+
check.update(open(path).read())
49+
check = check.hexdigest()
50+
current_checksums.append("{}:{}".format(path.split("/")[-1], check))
51+
try:
52+
req = requests.get(lib.settings.CHECKSUM_LINK)
53+
real_checksums = str(req.text).split("\n")
54+
for real, current in zip(sorted(real_checksums), sorted(current_checksums)):
55+
if real != current:
56+
failed_checks += 1
57+
if failed_checks > 0:
58+
return False
59+
return True
60+
except Exception:
61+
sep = "-" * 35
62+
lib.output.error(
63+
"something went wrong while verifying the checksums of the current application, "
64+
"this could be due to your internet connectivity. Please either try again, or use "
65+
"the following template to create an issue:"
66+
)
67+
print("{}\n{}\n{}".format(
68+
sep, open(issue_template_path).read(), sep
69+
))
70+
exit(1)
71+
72+
2673
def check_version_number(current_version):
2774
"""
2875
check the version number before creating an issue
@@ -34,7 +81,7 @@ def check_version_number(current_version):
3481
if available_version != current_version:
3582
return False
3683
return True
37-
except Exception as e:
84+
except Exception:
3885
return True
3986

4087

@@ -137,6 +184,14 @@ def request_issue_creation(path, arguments, error_message):
137184
request the creation and create the issue
138185
"""
139186

187+
if not checksum(path):
188+
lib.output.error(
189+
"It seems you have changed some of the code in the program. We do not accept issues from edited "
190+
"code as we have no way of reliably testing your issue. We recommend that you only use the version "
191+
"that is available on github, no issue will be created for this problem."
192+
)
193+
exit(1)
194+
140195
question = raw_input(
141196
"do you want to create an anonymized issue?[y/N]: "
142197
)

lib/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ def complete_text(self, text, state):
7070
# autosploit command history file path
7171
HISTORY_FILE_PATH = "{}/.history".format(HOME)
7272

73+
# link to the checksums
74+
CHECKSUM_LINK = open("{}/etc/text_files/checksum_link.txt".format(CUR_DIR)).read()
75+
7376
# path to the file containing all the discovered hosts
7477
HOST_FILE = "{}/hosts.txt".format(CUR_DIR)
7578
try:

0 commit comments

Comments
 (0)