add --replace-url to allow changing the sysCheck url with pre-provided docker images
This commit is contained in:
parent
724761d130
commit
2ed992a8f5
2 changed files with 13 additions and 7 deletions
18
app.py
18
app.py
|
@ -17,8 +17,9 @@ from io import BytesIO
|
||||||
with open(f"{os.getcwd()}/config.json", "r") as f:
|
with open(f"{os.getcwd()}/config.json", "r") as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser(prog="syscheck_receiver", description="Server that saves SysCheck report uploads.")
|
||||||
parser.add_argument("-d", "--debug", dest="debug")
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
|
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
|
||||||
|
@ -40,6 +41,11 @@ else:
|
||||||
report_dir = f"{os.getcwd()}/reports"
|
report_dir = f"{os.getcwd()}/reports"
|
||||||
db_dir = f"{os.getcwd()}/reports.db"
|
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
|
# sever code
|
||||||
app = Flask('syscheck_receiver')
|
app = Flask('syscheck_receiver')
|
||||||
|
|
||||||
|
@ -111,9 +117,9 @@ def view_report():
|
||||||
|
|
||||||
@app.route("/syscheck_dl", methods=["GET"])
|
@app.route("/syscheck_dl", methods=["GET"])
|
||||||
def syscheck():
|
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
|
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
|
return "Replacement host has to be exactly 46 characters; Specified URL is too short!", 400
|
||||||
|
|
||||||
dol = BytesIO()
|
dol = BytesIO()
|
||||||
|
@ -121,7 +127,7 @@ def syscheck():
|
||||||
|
|
||||||
# hex edit boot.dol
|
# hex edit boot.dol
|
||||||
dol2 = open(f"{os.getcwd()}/static/syscheck/boot.dol", "rb")
|
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)
|
dol.seek(0)
|
||||||
dol2.close()
|
dol2.close()
|
||||||
|
|
||||||
|
@ -189,7 +195,7 @@ if __name__ == "__main__":
|
||||||
os.mkdir(report_dir)
|
os.mkdir(report_dir)
|
||||||
|
|
||||||
# start server
|
# start server
|
||||||
if args.debug == "1":
|
if args.debug:
|
||||||
print("Debug mode: on")
|
print("Debug mode: on")
|
||||||
app.run(host=config["ip"], port=config["port"], debug=True)
|
app.run(host=config["ip"], port=config["port"], debug=True)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"ip": "0.0.0.0",
|
"ip": "0.0.0.0",
|
||||||
"port": "6969",
|
"port": "6969",
|
||||||
"version": "1.0.8",
|
"version": "1.0.9",
|
||||||
"upload_passwords": [
|
"upload_passwords": [
|
||||||
"d2wRuTEObSAN",
|
"d2wRuTEObSAN",
|
||||||
"B277eNGp789a"
|
"B277eNGp789a"
|
||||||
|
|
Loading…
Add table
Reference in a new issue