From e6d3d5aaff29af29b125b29a5e703b15272427f2 Mon Sep 17 00:00:00 2001 From: MasOnShi Date: Mon, 4 Apr 2022 20:07:57 +0800 Subject: [PATCH] resolved --- auto-analysis/utils.py | 59 +++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/auto-analysis/utils.py b/auto-analysis/utils.py index 5007f6b..5648233 100644 --- a/auto-analysis/utils.py +++ b/auto-analysis/utils.py @@ -6,26 +6,13 @@ @Desc: It's all about getting better. """ from loguru import logger as log +from config import DOWNLOAD_LINK import subprocess import json import os -# Usage: -# innoextract -# -BASE_DIR = os.path.dirname(__file__) -DOWNLOAD_LINK = { - "win": { - "x86": "https://typora.io/windows/typora-setup-ia32.exe", - "x64": "https://typora.io/windows/typora-setup-x64.exe", - "arm": "https://typora.io/windows/typora-setup-arm64.exe", - }, - "linux": { - "x64": "https://download.typora.io/linux/Typora-linux-x64.tar.gz", - "arm": "https://download.typora.io/linux/Typora-linux-arm64.tar.gz", - }, -} +BASE_DIR = os.path.dirname(__file__) def get_version(to_path): @@ -57,10 +44,7 @@ def patch_file(_key, _iv, to_dir): open(patch_file_path, "w").write(content) -def win_x64_run(): - from win.x64 import analysis - basedir = os.path.join(BASE_DIR, "win/x64") - link = DOWNLOAD_LINK["win"]["x64"] +def scheduler(func, basedir, link): download_path = os.path.join(basedir, os.path.basename(link)) log.info(f"downloading from {link}") @@ -71,24 +55,35 @@ def win_x64_run(): log.info("preparation stage completed") main_node_path = os.path.join(basedir, "app/resources/app.asar.unpacked/main.node") log.info("auto analysis start") - key, iv = analysis.get_aes_key_and_iv(main_node_path) + key, iv = func.get_aes_key_and_iv(main_node_path) log.success("analysis done") patch_file(key.hex(), iv.hex(), basedir) log.success("patch done") +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) + + +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) + + +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) + + if __name__ == '__main__': + win_x86_run() win_x64_run() - - # hashString = open("LATEST_VERSION", "r").read() - # if hashString == "": - # log.info("not history for typora version") - # exit() - - # basedir = os.path.dirname(__file__) - # for h1 in DOWNLOAD_LINK.keys(): - # h1dir = os.path.join(basedir, h1) - # for h2 in DOWNLOAD_LINK.get(h1).keys(): - # h2dir = os.path.join(h1dir, h2) - # print(h2dir) + linux_x64_run()