From 71aa81a11ebeeca2b91118619b68c41de54400a4 Mon Sep 17 00:00:00 2001 From: ekultek Date: Fri, 19 Apr 2019 12:42:02 -0500 Subject: [PATCH 1/4] verifies program checksums before you can create an issue --- etc/text_files/checksum_link.txt | 1 + lib/creation/issue_creator.py | 58 +++++++++++++++++++++++++++++++- lib/settings.py | 3 ++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 etc/text_files/checksum_link.txt diff --git a/etc/text_files/checksum_link.txt b/etc/text_files/checksum_link.txt new file mode 100644 index 0000000..a1ffcf4 --- /dev/null +++ b/etc/text_files/checksum_link.txt @@ -0,0 +1 @@ +https://gist.githubusercontent.com/Ekultek/cdf0d417ab5f023e99b89c1a4c7c3be8/raw/f91496698d4218565cba01b2d1c620efe80e6095/checksums.md5 \ No newline at end of file diff --git a/lib/creation/issue_creator.py b/lib/creation/issue_creator.py index e300fbf..afaeae7 100644 --- a/lib/creation/issue_creator.py +++ b/lib/creation/issue_creator.py @@ -23,6 +23,54 @@ raw_input = input +def checksum(issue_template_path): + """ + verifies the checksums of the program before you can create an issue + """ + + file_skips = [ + "__init__", ".pyc", ".xml", + ".sample", "HEAD", "pack", + "dev-beta", "description", "config", + "exclude", "index", ".json", + ".gitignore", "LICENSE", "ISSUE_TEMPLATE", + "README", "CONTRIBUTING", "hosts.txt", + "requirements.txt", "checksum_link.txt", + ".key", ".id", ".csv" + ] + current_checksums = [] + failed_checks = 0 + for root, sub, files in os.walk(lib.settings.CUR_DIR): + for name in files: + if not any(c in name for c in file_skips): + path = os.path.join(root, name) + check = hashlib.md5() + check.update(open(path).read()) + check = check.hexdigest() + current_checksums.append("{}:{}".format(path.split("/")[-1], check)) + print "\n".join(current_checksums);exit(1) + try: + req = requests.get(lib.settings.CHECKSUM_LINK) + real_checksums = str(req.text).split("\n") + for real, current in zip(sorted(real_checksums), sorted(current_checksums)): + if real != current: + failed_checks += 1 + if failed_checks > 0: + return False + return True + except Exception: + sep = "-" * 35 + lib.output.error( + "something went wrong while verifying the checksums of the current application, " + "this could be due to your internet connectivity. Please either try again, or use " + "the following template to create an issue:" + ) + print("{}\n{}\n{}".format( + sep, open(issue_template_path).read(), sep + )) + return False + + def check_version_number(current_version): """ check the version number before creating an issue @@ -34,7 +82,7 @@ def check_version_number(current_version): if available_version != current_version: return False return True - except Exception as e: + except Exception: return True @@ -137,6 +185,14 @@ def request_issue_creation(path, arguments, error_message): request the creation and create the issue """ + if not checksum(path): + lib.output.error( + "it seems you have changed some of the code in the program. We do not accept issues from edited " + "code as we have no way of reliability testing your issue. We recommend that you only use the version " + "that is available on github, no issue will be created for this problem, DO NOT REPORT IT" + ) + exit(1) + question = raw_input( "do you want to create an anonymized issue?[y/N]: " ) diff --git a/lib/settings.py b/lib/settings.py index 91aba28..527807f 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -70,6 +70,9 @@ def complete_text(self, text, state): # autosploit command history file path HISTORY_FILE_PATH = "{}/.history".format(HOME) +# link to the checksums +CHECKSUM_LINK = open("{}/etc/text_files/checksum_link.txt".format(CUR_DIR)).read() + # path to the file containing all the discovered hosts HOST_FILE = "{}/hosts.txt".format(CUR_DIR) try: From 3de4a9e86d4fefbecc571fb1ce5e70101c395553 Mon Sep 17 00:00:00 2001 From: ekultek Date: Fri, 19 Apr 2019 12:43:20 -0500 Subject: [PATCH 2/4] minor fix --- lib/creation/issue_creator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/creation/issue_creator.py b/lib/creation/issue_creator.py index afaeae7..0930dd0 100644 --- a/lib/creation/issue_creator.py +++ b/lib/creation/issue_creator.py @@ -48,7 +48,6 @@ def checksum(issue_template_path): check.update(open(path).read()) check = check.hexdigest() current_checksums.append("{}:{}".format(path.split("/")[-1], check)) - print "\n".join(current_checksums);exit(1) try: req = requests.get(lib.settings.CHECKSUM_LINK) real_checksums = str(req.text).split("\n") From b38bb89b2b40a24837ca0cd2c140cdd839f72384 Mon Sep 17 00:00:00 2001 From: ekultek Date: Fri, 19 Apr 2019 12:44:00 -0500 Subject: [PATCH 3/4] it's not fair to put connection issues in the same cat as douches --- lib/creation/issue_creator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/creation/issue_creator.py b/lib/creation/issue_creator.py index 0930dd0..2555af3 100644 --- a/lib/creation/issue_creator.py +++ b/lib/creation/issue_creator.py @@ -67,7 +67,7 @@ def checksum(issue_template_path): print("{}\n{}\n{}".format( sep, open(issue_template_path).read(), sep )) - return False + exit(1) def check_version_number(current_version): From 7e586e64cafe92a1f740fef6bf08792ea99dd4f8 Mon Sep 17 00:00:00 2001 From: NullArray Date: Sun, 21 Apr 2019 00:05:30 +0000 Subject: [PATCH 4/4] Update issue_creator.py --- lib/creation/issue_creator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/creation/issue_creator.py b/lib/creation/issue_creator.py index 2555af3..5c53dbf 100644 --- a/lib/creation/issue_creator.py +++ b/lib/creation/issue_creator.py @@ -186,9 +186,9 @@ def request_issue_creation(path, arguments, error_message): if not checksum(path): lib.output.error( - "it seems you have changed some of the code in the program. We do not accept issues from edited " - "code as we have no way of reliability testing your issue. We recommend that you only use the version " - "that is available on github, no issue will be created for this problem, DO NOT REPORT IT" + "It seems you have changed some of the code in the program. We do not accept issues from edited " + "code as we have no way of reliably testing your issue. We recommend that you only use the version " + "that is available on github, no issue will be created for this problem." ) exit(1)