From 2ed992a8f57ddd2363101e2761969b1ec4a88f46 Mon Sep 17 00:00:00 2001 From: CrafterPika Date: Sun, 3 Nov 2024 15:36:44 +0100 Subject: [PATCH] add --replace-url to allow changing the sysCheck url with pre-provided docker images --- app.py | 18 ++++++++++++------ config.json | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index f254b0f..39b7d17 100644 --- a/app.py +++ b/app.py @@ -17,8 +17,9 @@ from io import BytesIO with open(f"{os.getcwd()}/config.json", "r") as f: config = json.load(f) -parser = ArgumentParser() -parser.add_argument("-d", "--debug", dest="debug") +parser = ArgumentParser(prog="syscheck_receiver", description="Server that saves SysCheck report uploads.") +parser.add_argument("-d", "--debug", dest="debug", action='store_true', help="Runs with Flask debug server instead of Waitress. DO NOT USE IN PRODUCTION!!!!") +parser.add_argument("-r", "--replace-url", dest="replace_url", help="Allows to replace the default sysCheck url with your own (mostly meant for the pre-provided docker images).") args = parser.parse_args() def id_generator(size=6, chars=string.ascii_uppercase + string.digits): @@ -40,6 +41,11 @@ else: report_dir = f"{os.getcwd()}/reports" db_dir = f"{os.getcwd()}/reports.db" +if args.replace_url is None: + replace_url = config["replace_str"] +else: + replace_url = args.replace_url + # sever code app = Flask('syscheck_receiver') @@ -111,9 +117,9 @@ def view_report(): @app.route("/syscheck_dl", methods=["GET"]) def syscheck(): - if len("http://syscheck.rc24.xyz/syscheck_receiver.php") < len(config["replace_str"]): + if len("http://syscheck.rc24.xyz/syscheck_receiver.php") < len(replace_url): return "Replacement host has to be exactly 46 characters; Specified URL is too long!", 400 - elif len("http://syscheck.rc24.xyz/syscheck_receiver.php") > len(config["replace_str"]): + elif len("http://syscheck.rc24.xyz/syscheck_receiver.php") > len(replace_url): return "Replacement host has to be exactly 46 characters; Specified URL is too short!", 400 dol = BytesIO() @@ -121,7 +127,7 @@ def syscheck(): # hex edit boot.dol dol2 = open(f"{os.getcwd()}/static/syscheck/boot.dol", "rb") - dol.write(dol2.read().replace("http://syscheck.rc24.xyz/syscheck_receiver.php".encode("utf-8"), config["replace_str"].encode("utf-8"))) + dol.write(dol2.read().replace("http://syscheck.rc24.xyz/syscheck_receiver.php".encode("utf-8"), replace_url.encode("utf-8"))) dol.seek(0) dol2.close() @@ -189,7 +195,7 @@ if __name__ == "__main__": os.mkdir(report_dir) # start server - if args.debug == "1": + if args.debug: print("Debug mode: on") app.run(host=config["ip"], port=config["port"], debug=True) else: diff --git a/config.json b/config.json index a9bde4b..91429e4 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "ip": "0.0.0.0", "port": "6969", - "version": "1.0.8", + "version": "1.0.9", "upload_passwords": [ "d2wRuTEObSAN", "B277eNGp789a"