Skip to content

Commit 71aa81a

Browse files
committed
verifies program checksums before you can create an issue
1 parent 94677e7 commit 71aa81a

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-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: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,54 @@
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+
print "\n".join(current_checksums);exit(1)
52+
try:
53+
req = requests.get(lib.settings.CHECKSUM_LINK)
54+
real_checksums = str(req.text).split("\n")
55+
for real, current in zip(sorted(real_checksums), sorted(current_checksums)):
56+
if real != current:
57+
failed_checks += 1
58+
if failed_checks > 0:
59+
return False
60+
return True
61+
except Exception:
62+
sep = "-" * 35
63+
lib.output.error(
64+
"something went wrong while verifying the checksums of the current application, "
65+
"this could be due to your internet connectivity. Please either try again, or use "
66+
"the following template to create an issue:"
67+
)
68+
print("{}\n{}\n{}".format(
69+
sep, open(issue_template_path).read(), sep
70+
))
71+
return False
72+
73+
2674
def check_version_number(current_version):
2775
"""
2876
check the version number before creating an issue
@@ -34,7 +82,7 @@ def check_version_number(current_version):
3482
if available_version != current_version:
3583
return False
3684
return True
37-
except Exception as e:
85+
except Exception:
3886
return True
3987

4088

@@ -137,6 +185,14 @@ def request_issue_creation(path, arguments, error_message):
137185
request the creation and create the issue
138186
"""
139187

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

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)