diff --git a/discordHelperWin.py b/discordHelperWin.py index b764c30..38ed48d 100644 --- a/discordHelperWin.py +++ b/discordHelperWin.py @@ -1,7 +1,7 @@ """ A windows executable for the discordHelper.py script. """ - +import os import sys import discordHelper @@ -14,6 +14,8 @@ from modules import spidey_test, test_template if __name__ == "__main__": argv = sys.argv[1:] if len(argv) == 0: - argv = f"--all --launch --continue --gen-data new_test_data_{int(time.time())}.yaml".split(" ") + user_path = os.path.join(os.path.expanduser("~"), "Documents", "DiscordHelper") + argv = f"--all --launch --continue --timeout 12 --gen-data {user_path}/new_test_data_{int(time.time())}.yaml".split(" ") + args = discordHelper.argument_parser.parse(argv) discordHelper.main(args) diff --git a/modules/argument_parser.py b/modules/argument_parser.py index ac7aaa7..79700c5 100644 --- a/modules/argument_parser.py +++ b/modules/argument_parser.py @@ -6,10 +6,26 @@ def parse(_args): prog="Spidey Detector", description='Checks for corrupt discord install' ) - parser.add_argument('--ptb', action='store_const', const="PTB", default="", help='Use Public Test Version') + + parser.add_argument('--ptb', action='store_const', const="PTB", default="", help='Force use of Public Test Version') + + # General arguments parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') parser.add_argument('-d', '--debug', action='store_true', help='Debug mode') parser.add_argument('-s', '--silent', action='store_true', help='Silent mode') + parser.add_argument("--continue_on_error", "--continue", action="store_true", help="Continue the analysis in case of failure") + parser.add_argument("--timeout", default=1, type=int, help="Timeout for the tests") + + # Post actions + parser.add_argument('--launch', action='store_true', help="Launch the discord client after the tests are done") + + # IO arguments + parser.add_argument("--force-path", nargs=1, default=None, help="Bypass the automatic path discovery with given path") + parser.add_argument("--only-known-paths", "--fast", action='store_true', help="Only run the check on the known paths") + parser.add_argument("--gen-data", "--generate-data", "--gen", nargs=1, default="", help="Generate data for the analysis") + parser.add_argument("--database", "--db", nargs=1, default="", help="Alternative database for the analysis") + + # Tests parser.add_argument('--spidey', action='store_true', help='Runs the spidey test') parser.add_argument('--line-count', action='store_true', help='Test all known files for line count') parser.add_argument('--file-count', action='store_true', help="Test the number of files in the discord folder") @@ -21,14 +37,8 @@ def parse(_args): parser.add_argument('--file-date', action='store_true', help="Test the date of the files in the discord folder") parser.add_argument('--analyze', action='store_true', help="Analyze the files in the discord folder for known js obfuscators") parser.add_argument('--all', action='store_true', help="Run all tests in parallel, and wait for a potential interupt") - parser.add_argument('--launch', action='store_true', help="Launch the discord client after the tests are done") - parser.add_argument("--force-path", nargs=1, default=None, help="Bypass the automatic path discovery with given path") - parser.add_argument("--only-known-paths", "--fast", action='store_true', help="Only run the check on the known paths") parser.add_argument("--no-eval", action="store_true", help="Check for the eval function wich is a HUGE red flag") parser.add_argument("--const-abuse", "--no-const", action="store_true", help="Check for the abuse of the const: keyword, wich is massively used for obfucation") - parser.add_argument("--gen-data", "--generate-data", "--gen", nargs=1, default="", help="Generate data for the analysis") - parser.add_argument("--database", "--db", nargs=1, default="", help="Alternative database for the analysis") - parser.add_argument("--continue_on_error", "--continue", action="store_true", help="Continue the analysis in case of failure") parser.add_argument("--test-walk", action="store_true", help="Test walk function") return parser.parse_args(_args) diff --git a/modules/main_runner.py b/modules/main_runner.py index ac81767..cfca3ac 100644 --- a/modules/main_runner.py +++ b/modules/main_runner.py @@ -254,11 +254,18 @@ def run_check(args, agnpath): if args.gen_data: print("Generating data...") data = tr.get_test_data() + print("Making folder...") + file_path = os.path.join(os.path.join("databases", args.gen_data[0])) + folder = os.path.dirname(file_path) + if not os.path.exists(folder): + os.makedirs(args.gen_data) print("Exporting data...") main_data = export_data(tr, data) # print(main_data) - with open(os.path.join("databases", args.gen_data[0]), "w") as f: + with open(file_path, "w") as f: json.dump(main_data, f, indent=4) # print(tr.get_test_data()) # TODO: Transorm the data into a yaml or json file - time.sleep(2) + + print(f"Exiting in {args.timeout}...") + time.sleep(args.timeout) sys.exit(tr.get_exit_code()) diff --git a/winspec.spec b/winspec.spec new file mode 100644 index 0000000..7deedea --- /dev/null +++ b/winspec.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['discordHelperWin.py'], + pathex=[], + binaries=[], + datas=[('databases/*', 'databases/')], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='discordHelperWin', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)