From 19e73b6c79df5d01a716e9577c54a199b53b2220 Mon Sep 17 00:00:00 2001 From: MasOnShi Date: Mon, 4 Apr 2022 20:26:45 +0800 Subject: [PATCH] adds support for linux-x64 --- auto-analysis/utils.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/auto-analysis/utils.py b/auto-analysis/utils.py index 5648233..3a7b174 100644 --- a/auto-analysis/utils.py +++ b/auto-analysis/utils.py @@ -27,7 +27,10 @@ def download_file(from_link, to_path): def extract_file(from_path, to_path): - subprocess.check_call(["innoextract", from_path, "-d", to_path]) + if from_path.endswith(".exe"): + subprocess.check_call(["innoextract", from_path, "-d", to_path]) + elif from_path.endswith(".tar.gz"): + subprocess.check_call(["tar", "-zxvf", from_path, "-C", to_path]) def patch_file(_key, _iv, to_dir): @@ -44,7 +47,7 @@ def patch_file(_key, _iv, to_dir): open(patch_file_path, "w").write(content) -def scheduler(func, basedir, link): +def scheduler(func, basedir, link, root_path): download_path = os.path.join(basedir, os.path.basename(link)) log.info(f"downloading from {link}") @@ -53,7 +56,8 @@ def scheduler(func, basedir, link): extract_file(download_path, basedir) log.info("preparation stage completed") - main_node_path = os.path.join(basedir, "app/resources/app.asar.unpacked/main.node") + + main_node_path = os.path.join(basedir, os.path.join(root_path, "resources/app.asar.unpacked/main.node")) log.info("auto analysis start") key, iv = func.get_aes_key_and_iv(main_node_path) log.success("analysis done") @@ -66,21 +70,21 @@ def win_x64_run(): from win.x64 import analysis dirs = os.path.join(BASE_DIR, "win/x64") url = DOWNLOAD_LINK["win"]["x64"] - scheduler(func=analysis, basedir=dirs, link=url) + scheduler(func=analysis, basedir=dirs, link=url, root_path="app") def win_x86_run(): from win.x86 import analysis dirs = os.path.join(BASE_DIR, "win/x86") url = DOWNLOAD_LINK["win"]["x86"] - scheduler(func=analysis, basedir=dirs, link=url) + scheduler(func=analysis, basedir=dirs, link=url, root_path="app") def linux_x64_run(): from linux.x64 import analysis dirs = os.path.join(BASE_DIR, "linux/x64") url = DOWNLOAD_LINK["linux"]["x64"] - scheduler(func=analysis, basedir=dirs, link=url) + scheduler(func=analysis, basedir=dirs, link=url, root_path="bin/Typora-linux-x64") if __name__ == '__main__':