From d870e234c3827e7d0923baf4fadccfcc9c4d9ffc Mon Sep 17 00:00:00 2001 From: MasOnShi Date: Sun, 3 Apr 2022 20:14:34 +0800 Subject: [PATCH] dev commits. --- auto-analysis/version_download.py | 78 +------------------------------ 1 file changed, 2 insertions(+), 76 deletions(-) diff --git a/auto-analysis/version_download.py b/auto-analysis/version_download.py index 0453f24..f263df2 100644 --- a/auto-analysis/version_download.py +++ b/auto-analysis/version_download.py @@ -5,82 +5,8 @@ @Time: 2022/4/3 18:36 @Desc: It's all about getting better. """ -from loguru import logger as log -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", - }, -} - -def get_version(to_path): - package_file_path = os.path.join(to_path, "app/resources/package.json") - package_info = open(package_file_path, "r").read() - package_obj = json.loads(package_info) - return package_obj["version"] - - -def download_file(from_link, to_path): - log.info(f"downloading from {from_link}") - subprocess.check_call(["wget", from_link, "-O", to_path]) - log.info("ready extract package") - - - -def patch_file(_key, _iv): - patch_file_path = os.path.join(BASE_DIR, "../typora.py") - fd = open(patch_file_path, "a") - content = fd.read() - content = content.replace("{AES_KEY}", f"b''.fromhex('{_key}')") - content = content.replace("{AES_IV}", f"b''.fromhex('{_iv}')") - fd.write(content) - - -def win_x64_run(): - from win.x64 import analysis - basedir = os.path.join(BASE_DIR, "win/x64") - link = DOWNLOAD_LINK["win"]["x64"] - - download_path = os.path.join(basedir, os.path.basename(link)) - download_file(link, download_path) - - subprocess.check_call(["innoextract", download_path]) - 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) - log.success("analysis done") - - patch_file(key.hex(), iv.hex()) - log.success("patch done") - +import utils if __name__ == '__main__': - win_x64_run() + utils.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)