mirror of
https://github.com/Mas0nShi/typoraCracker.git
synced 2023-07-10 13:41:20 +08:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ac472a198 | ||
|
|
c3ed1499cc | ||
|
|
637bc99b44 | ||
|
|
d294746a36 | ||
|
|
db41e7942c | ||
|
|
d8f253e0c8 | ||
|
|
19e73b6c79 | ||
|
|
e6b6d7a9e1 | ||
|
|
ea2e2b479c | ||
|
|
e562f37282 | ||
|
|
b8726b62ae | ||
|
|
e6d3d5aaff | ||
|
|
c1beef1a98 | ||
|
|
2e5bfcfb50 | ||
|
|
bab9df1f5f | ||
|
|
1c701eb7ae | ||
|
|
df4320c481 | ||
|
|
d16428a8b2 | ||
|
|
37cb084073 | ||
|
|
ce93881acd | ||
|
|
d13b7df457 | ||
|
|
8659ad77d8 | ||
|
|
f09cf7a8b5 | ||
|
|
591853fd67 | ||
|
|
8df8b7f18e | ||
|
|
6968976033 | ||
|
|
b582671923 | ||
|
|
ff414f6d79 | ||
|
|
3643ec2de3 | ||
|
|
a312537aa2 | ||
|
|
97a4f578b6 | ||
|
|
43b858c3ce | ||
|
|
df5bb4473f | ||
|
|
facaed285a | ||
|
|
937e3aa178 |
59
.github/workflows/manual.yml
vendored
59
.github/workflows/manual.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
# This is a basic workflow that is manually triggered
|
# This is a basic workflow that is manually triggered
|
||||||
|
|
||||||
name: Manual workflow
|
name: Automatic analysis
|
||||||
|
|
||||||
# Controls when the action will run. Workflow runs when manually triggered using the UI
|
# Controls when the action will run. Workflow runs when manually triggered using the UI
|
||||||
# or API.
|
# or API.
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install innoextract -y
|
sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install innoextract -y
|
||||||
python3 -m pip install loguru
|
python3 -m pip install loguru
|
||||||
|
|
||||||
- name: Check Latest Version
|
- name: Check Latest Version (use win-x64)
|
||||||
id: checkVersion
|
id: checkVersion
|
||||||
run: |
|
run: |
|
||||||
python3 auto-analysis/check_version.py
|
python3 auto-analysis/check_version.py
|
||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
id: createRelease
|
id: createRelease
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: '${{ needs.check_version.outputs.LATEST_VERSION }}'
|
tag_name: '${{ needs.check_version.outputs.LATEST_VERSION }}'
|
||||||
release_name: '${{ needs.check_version.outputs.LATEST_VERSION }}'
|
release_name: '${{ needs.check_version.outputs.LATEST_VERSION }}'
|
||||||
@@ -76,28 +76,29 @@ jobs:
|
|||||||
needs: [check_version, create_release]
|
needs: [check_version, create_release]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
if: needs.check_version.outputs.RELEASE_VERSION != needs.check_version.outputs.LATEST_VERSION
|
if: needs.check_version.outputs.RELEASE_VERSION != needs.check_version.outputs.LATEST_VERSION
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v3
|
- uses: actions/setup-python@v3
|
||||||
with:
|
with:
|
||||||
python-version: '3.8' # Version range or exact version of a Python version to use, using SemVer's version range syntax
|
python-version: '3.8'
|
||||||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
architecture: 'x64'
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install innoextract cmake -y
|
sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install innoextract zip -y
|
||||||
python3 -m pip install r2pipe loguru
|
python3 -m pip install r2pipe loguru
|
||||||
|
|
||||||
- name: build radare2
|
- name: build radare2
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/radareorg/radare2
|
git clone https://github.com/radareorg/radare2
|
||||||
radare2/sys/install.sh
|
radare2/sys/install.sh
|
||||||
|
|
||||||
- name: patch version
|
- name: patch version
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
python3 auto-analysis/patch.py
|
python3 auto-analysis/patch.py
|
||||||
tar -zcvf auto-analysis/win/x64/build/typoraCracker.tar.gz auto-analysis/win/x64/build/*
|
|
||||||
|
zip -rjq auto-analysis/win/x64/build/typoraCracker.zip auto-analysis/win/x64/build/*
|
||||||
|
zip -rjq auto-analysis/win/x86/build/typoraCracker.zip auto-analysis/win/x86/build/*
|
||||||
|
zip -rjq auto-analysis/linux/x64/build/typoraCracker.zip auto-analysis/linux/x64/build/*
|
||||||
|
|
||||||
- name: Check release version
|
- name: Check release version
|
||||||
id: checkReleaseVersion
|
id: checkReleaseVersion
|
||||||
@@ -123,13 +124,43 @@ jobs:
|
|||||||
core.setFailed(e.message);
|
core.setFailed(e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Upload win x64 typora.py for typoraCracker
|
- name: Upload win-x64
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: '${{ steps.checkReleaseVersion.outputs.upload_url }}'
|
upload_url: '${{ steps.checkReleaseVersion.outputs.upload_url }}'
|
||||||
asset_path: '${{ github.workspace }}/auto-analysis/win/x64/build/typoraCracker.tar.gz'
|
asset_path: '${{ github.workspace }}/auto-analysis/win/x64/build/typoraCracker.zip'
|
||||||
asset_name: 'typoraCracker-${{ needs.check_version.outputs.LATEST_VERSION }}-win-x64.tar.gz'
|
asset_name: 'typoraCracker-${{ needs.check_version.outputs.LATEST_VERSION }}-win-x64.zip'
|
||||||
asset_content_type: application/x-tgz
|
asset_content_type: application/zip
|
||||||
|
|
||||||
|
- name: Upload win-x86
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: '${{ steps.checkReleaseVersion.outputs.upload_url }}'
|
||||||
|
asset_path: '${{ github.workspace }}/auto-analysis/win/x86/build/typoraCracker.zip'
|
||||||
|
asset_name: 'typoraCracker-${{ needs.check_version.outputs.LATEST_VERSION }}-win-x86.zip'
|
||||||
|
asset_content_type: application/zip
|
||||||
|
|
||||||
|
- name: Upload linux-x64
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: '${{ steps.checkReleaseVersion.outputs.upload_url }}'
|
||||||
|
asset_path: '${{ github.workspace }}/auto-analysis/linux/x64/build/typoraCracker.zip'
|
||||||
|
asset_name: 'typoraCracker-${{ needs.check_version.outputs.LATEST_VERSION }}-linux-x64.zip'
|
||||||
|
asset_content_type: application/zip
|
||||||
|
|
||||||
|
- name: verify scripts
|
||||||
|
run: |
|
||||||
|
python3 -m pip install -r auto-analysis/win/x64/build/requirements.txt
|
||||||
|
|
||||||
|
python3 auto-analysis/win/x64/build/typora.py auto-analysis/win/x64/app/resources/app.asar auto-analysis/win/x64
|
||||||
|
echo "win x64 test completed"
|
||||||
|
python3 auto-analysis/win/x86/build/typora.py auto-analysis/win/x86/app/resources/app.asar auto-analysis/win/x86
|
||||||
|
echo "win x86 test completed"
|
||||||
|
python3 auto-analysis/linux/x64/build/typora.py auto-analysis/linux/x64/bin/Typora-linux-x64/resources/app.asar auto-analysis/linux/x64
|
||||||
|
echo "linux x64 test completed"
|
||||||
39
README.md
39
README.md
@@ -3,8 +3,18 @@
|
|||||||
|
|
||||||
# typora Cracker
|
# typora Cracker
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
[](https://github.com/Mas0nShi/typoraCracker/actions/workflows/manual.yml)
|
||||||
|
|
||||||
|
|
||||||
A extract & decryption and pack & encryption tools for typora.
|
A extract & decryption and pack & encryption tools for typora.
|
||||||
|
|
||||||
@@ -20,17 +30,28 @@ ANY PROBLEMS ARISING FROM THIS WILL BE BORNE BY THE USER (YOU).
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Supports Version 1.0.0+ (At least for now.)
|
- Supports Version 1.0.0 - 1.2.0 [(old archive)](https://github.com/Mas0nShi/typoraCracker/tree/backup-raw)
|
||||||
- tested fine in Windows, Ubuntu
|
- Supports Version 1.2.+ [(Experimental archive)](https://github.com/Mas0nShi/typoraCracker/tree/master)
|
||||||
|
|
||||||
|
## Support List
|
||||||
|
2022.4.4: Experimental support for automatic binary analysis to generate scripts. (v1.2.+)
|
||||||
|
|
||||||
|
| OS / ARCH | x86 | x64 | arm64 |
|
||||||
|
|:---------:|:---:|:---:|:-----:|
|
||||||
|
| win | ✅ | ✅ | ❌ |
|
||||||
|
| linux | ⛔ | ✅ | ❌ |
|
||||||
|
| macOS | ❌ | ❌ | ❌ |
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
1. download in [Release Pages](https://github.com/Mas0nShi/typoraCracker/releases)
|
||||||
1. `pip install -r requirements.txt`
|
2. unzip
|
||||||
2. `python typora.py --help`
|
3. `pip install -r requirements.txt`
|
||||||
3. read and use.
|
4. `python typora.py --help`
|
||||||
4. do something.
|
5. read and use.
|
||||||
5. pack and replace app.asar.
|
6. do something.
|
||||||
6. enjoy it.
|
7. pack and replace app.asar.
|
||||||
|
8. enjoy it.
|
||||||
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|||||||
28
README_CN.md
28
README_CN.md
@@ -15,18 +15,30 @@
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
- 版本 1.0.0 - 1.2.0 [(使用旧的存档)](https://github.com/Mas0nShi/typoraCracker/tree/backup-raw)
|
||||||
|
- 版本 1.2.+ [(使用测试存档)](https://github.com/Mas0nShi/typoraCracker/tree/master)
|
||||||
|
|
||||||
|
|
||||||
|
## Support List
|
||||||
|
2022.4.4: 支持自动化分析二进制文件并生成脚本(测试性功能 v1.2.+)
|
||||||
|
|
||||||
|
| OS / ARCH | x86 | x64 | arm64 |
|
||||||
|
|:---------:|:---:|:---:|:-----:|
|
||||||
|
| win | ✅ | ✅ | ❌ |
|
||||||
|
| linux | ⛔ | ✅ | ❌ |
|
||||||
|
| macOS | ❌ | ❌ | ❌ |
|
||||||
|
|
||||||
- 支持版本1.0.0以上(至少现在是这样)
|
|
||||||
- 测试通过平台:Win/Ubuntu
|
|
||||||
|
|
||||||
## 食用方式
|
## 食用方式
|
||||||
|
|
||||||
1. `pip install -r requirements.txt`
|
1. 前往[Release Pages](https://github.com/Mas0nShi/typoraCracker/releases) 下载对应版本
|
||||||
2. `python typora.py --help`
|
2. 解压
|
||||||
3. 阅读帮助文档及使用。
|
3. 安装依赖:`pip install -r requirements.txt`
|
||||||
4. 做你想做的事。
|
4. 使用说明:`python typora.py --help`
|
||||||
5. 打包并替换原目录下的 app.asar。
|
5. 使用。
|
||||||
6. 享受成果。
|
6. 做你想做的事。
|
||||||
|
7. 打包并替换原目录下的 app.asar。
|
||||||
|
8. 享受成果。
|
||||||
|
|
||||||
|
|
||||||
## 示例
|
## 示例
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
from utils import get_version, download_file, extract_file, log, DOWNLOAD_LINK
|
from utils import get_version, download_file, extract_file, log
|
||||||
|
from config import DOWNLOAD_LINK
|
||||||
import os
|
import os
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(__file__)
|
BASE_DIR = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
def win_x64_version():
|
def run_version(download_os, download_arch):
|
||||||
url = DOWNLOAD_LINK["win"]["x64"]
|
from_url = DOWNLOAD_LINK[download_os][download_arch]
|
||||||
dir = os.path.join(BASE_DIR, "win/x64")
|
to_dir = os.path.join(BASE_DIR, f"{download_os}/{download_arch}")
|
||||||
|
|
||||||
download_path = os.path.join(dir, os.path.basename(url))
|
download_path = os.path.join(to_dir, os.path.basename(from_url))
|
||||||
download_file(url, download_path)
|
download_file(from_url, download_path)
|
||||||
extract_file(download_path, dir)
|
extract_file(download_path, to_dir)
|
||||||
version = get_version(dir)
|
version = get_version(to_dir)
|
||||||
|
open(os.path.join(to_dir, "LATEST_VERSION"), "w").write(version)
|
||||||
open(os.path.join(dir, "LATEST_VERSION"), "w").write(version)
|
log.success(f"{download_os}-{download_arch} the latest version is {version}")
|
||||||
log.success(version)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
win_x64_version()
|
run_version("win", "x64")
|
||||||
|
# run_version("win", "x86")
|
||||||
|
# run_version("linux", "x64")
|
||||||
|
|||||||
25
auto-analysis/config.py
Normal file
25
auto-analysis/config.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
"""
|
||||||
|
@Author: Mas0n
|
||||||
|
@File: config.py
|
||||||
|
@Time: 2022/4/4 19:50
|
||||||
|
@Desc: It's all about getting better.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
DOWNLOAD_LINK = {
|
||||||
|
"win": {
|
||||||
|
"x86": "https://typora.io/windows/typora-setup-ia32.exe",
|
||||||
|
"x64": "https://typora.io/windows/typora-setup-x64.exe",
|
||||||
|
"arm64": "https://typora.io/windows/typora-setup-arm64.exe",
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"x64": "https://download.typora.io/linux/Typora-linux-x64.tar.gz",
|
||||||
|
"arm64": "https://download.typora.io/linux/Typora-linux-arm64.tar.gz",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTRACT_ROOT_PATH = {
|
||||||
|
"win": "app",
|
||||||
|
"linux": "bin/Typora-linux-x64"
|
||||||
|
}
|
||||||
32
auto-analysis/linux/x64/analysis.py
Normal file
32
auto-analysis/linux/x64/analysis.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
"""
|
||||||
|
@Author: Mas0n
|
||||||
|
@Name: typora_linux_x64_analysis
|
||||||
|
@Time: 2022/4/4 19:48
|
||||||
|
@Desc: It's all about getting better.
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import r2pipe
|
||||||
|
|
||||||
|
|
||||||
|
def get_aes_key_and_iv(file_path):
|
||||||
|
r = r2pipe.open(file_path)
|
||||||
|
|
||||||
|
r.cmd("aaa")
|
||||||
|
regex = r.cmdj("axtj @@ str.base64")
|
||||||
|
assert len(regex) == 1
|
||||||
|
|
||||||
|
func = regex[0]["fcn_name"]
|
||||||
|
r.cmd(f"s {func}")
|
||||||
|
asm = r.cmdj("pdfj")['ops']
|
||||||
|
assert len(asm) != 0
|
||||||
|
|
||||||
|
if 'str.dip3' in json.dumps(asm):
|
||||||
|
r.cmd('s str.dip3 - 32')
|
||||||
|
data = r.cmdj('xj 48')
|
||||||
|
key = bytearray(data[0:32])
|
||||||
|
iv = bytearray(data[32:48])
|
||||||
|
else:
|
||||||
|
raise "need rewrite scripts for linux x64"
|
||||||
|
|
||||||
|
return key, iv
|
||||||
@@ -8,5 +8,7 @@
|
|||||||
import utils
|
import utils
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
utils.win_x86_run()
|
||||||
utils.win_x64_run()
|
utils.win_x64_run()
|
||||||
|
utils.linux_x64_run()
|
||||||
|
|
||||||
|
|||||||
@@ -6,27 +6,13 @@
|
|||||||
@Desc: It's all about getting better.
|
@Desc: It's all about getting better.
|
||||||
"""
|
"""
|
||||||
from loguru import logger as log
|
from loguru import logger as log
|
||||||
|
from config import DOWNLOAD_LINK, EXTRACT_ROOT_PATH
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Usage:
|
|
||||||
# innoextract
|
|
||||||
#
|
|
||||||
BASE_DIR = os.path.dirname(__file__)
|
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):
|
def get_version(to_path):
|
||||||
package_file_path = os.path.join(to_path, "app/resources/package.json")
|
package_file_path = os.path.join(to_path, "app/resources/package.json")
|
||||||
@@ -36,11 +22,14 @@ def get_version(to_path):
|
|||||||
|
|
||||||
|
|
||||||
def download_file(from_link, to_path):
|
def download_file(from_link, to_path):
|
||||||
subprocess.check_call(["wget", from_link, "-O", to_path])
|
subprocess.check_call(["wget", "-q", from_link, "-O", to_path])
|
||||||
|
|
||||||
|
|
||||||
def extract_file(from_path, 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", "-q", 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):
|
def patch_file(_key, _iv, to_dir):
|
||||||
@@ -57,11 +46,7 @@ def patch_file(_key, _iv, to_dir):
|
|||||||
open(patch_file_path, "w").write(content)
|
open(patch_file_path, "w").write(content)
|
||||||
|
|
||||||
|
|
||||||
def win_x64_run():
|
def scheduler(func, basedir, link, root_path):
|
||||||
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_path = os.path.join(basedir, os.path.basename(link))
|
||||||
log.info(f"downloading from {link}")
|
log.info(f"downloading from {link}")
|
||||||
download_file(link, download_path)
|
download_file(link, download_path)
|
||||||
@@ -69,26 +54,38 @@ def win_x64_run():
|
|||||||
|
|
||||||
extract_file(download_path, basedir)
|
extract_file(download_path, basedir)
|
||||||
log.info("preparation stage completed")
|
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")
|
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")
|
log.success("analysis done")
|
||||||
|
|
||||||
patch_file(key.hex(), iv.hex(), basedir)
|
patch_file(key.hex(), iv.hex(), basedir)
|
||||||
log.success("patch done")
|
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, root_path=EXTRACT_ROOT_PATH["win"])
|
||||||
|
|
||||||
|
|
||||||
|
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, root_path=EXTRACT_ROOT_PATH["win"])
|
||||||
|
|
||||||
|
|
||||||
|
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, root_path=EXTRACT_ROOT_PATH["linux"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
win_x86_run()
|
||||||
win_x64_run()
|
win_x64_run()
|
||||||
|
linux_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)
|
|
||||||
|
|||||||
@@ -9,29 +9,30 @@ import struct
|
|||||||
import r2pipe
|
import r2pipe
|
||||||
|
|
||||||
|
|
||||||
|
def regex_key_iv(asm_obj):
|
||||||
|
asm_regex = []
|
||||||
|
for body in asm_obj:
|
||||||
|
if "=[4]" in body["esil"] and body['type'] == 'mov':
|
||||||
|
opcode, value = body["disasm"].split(", ")
|
||||||
|
if "0x" in value:
|
||||||
|
asm_regex.append({"opcode": opcode, "value": value})
|
||||||
|
return asm_regex
|
||||||
|
|
||||||
|
|
||||||
def get_aes_key_and_iv(file_path):
|
def get_aes_key_and_iv(file_path):
|
||||||
r = r2pipe.open(file_path)
|
r = r2pipe.open(file_path)
|
||||||
# auto analysis
|
|
||||||
r.cmd("aaa")
|
r.cmd("aaa")
|
||||||
# string "base64" x-cross reference
|
|
||||||
regex = r.cmdj("axtj @@ str.base64")
|
regex = r.cmdj("axtj @@ str.base64")
|
||||||
assert len(regex) == 1
|
assert len(regex) == 1
|
||||||
|
|
||||||
func = regex[0]["fcn_name"]
|
func = regex[0]["fcn_name"]
|
||||||
# disasm func
|
|
||||||
r.cmd(f"s {func}")
|
r.cmd(f"s {func}")
|
||||||
asm = r.cmdj("pdfj")['ops']
|
asm = r.cmdj("pdfj")['ops']
|
||||||
assert len(asm) != 0
|
assert len(asm) != 0
|
||||||
|
|
||||||
asm_regex = []
|
asm_regex = regex_key_iv(asm)
|
||||||
for body in asm:
|
|
||||||
if "=[4]" in body["esil"] and body['type'] == 'mov':
|
|
||||||
opcode, value = body["disasm"].split(", ")
|
|
||||||
asm_regex.append({"opcode": opcode, "value": value})
|
|
||||||
|
|
||||||
assert len(asm_regex) == 12
|
assert len(asm_regex) == 12
|
||||||
|
|
||||||
iv = struct.pack("<4L", *[int(asm_regex[i]['value'], 16) for i in range(4)])
|
iv = struct.pack("<4L", *[int(asm_regex[i]['value'], 16) for i in range(4)])
|
||||||
key = struct.pack("<8L", *[int(asm_regex[i]['value'], 16) for i in range(4, 12)])
|
key = struct.pack("<8L", *[int(asm_regex[i]['value'], 16) for i in range(4, 12)])
|
||||||
# print(key, iv)
|
|
||||||
return key, iv
|
return key, iv
|
||||||
45
auto-analysis/win/x86/analysis.py
Normal file
45
auto-analysis/win/x86/analysis.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
"""
|
||||||
|
@Author: Mas0n
|
||||||
|
@Name: typora_win_x86_analysis
|
||||||
|
@Time: 2022/4/3 18:36
|
||||||
|
@Desc: It's all about getting better.
|
||||||
|
"""
|
||||||
|
import struct
|
||||||
|
import r2pipe
|
||||||
|
|
||||||
|
|
||||||
|
def regex_key_iv(asm_obj):
|
||||||
|
asm_regex = []
|
||||||
|
for body in asm_obj:
|
||||||
|
if "=[4]" in body["esil"] and body['type'] == 'mov':
|
||||||
|
opcode, value = body["disasm"].split(", ")
|
||||||
|
if "0x" in value:
|
||||||
|
asm_regex.append({"opcode": opcode, "value": value})
|
||||||
|
return asm_regex
|
||||||
|
|
||||||
|
|
||||||
|
def get_aes_key_and_iv(file_path):
|
||||||
|
r = r2pipe.open(file_path)
|
||||||
|
r.cmd("aaa")
|
||||||
|
regex = r.cmdj("axtj @@ str.base64")
|
||||||
|
assert len(regex) == 1
|
||||||
|
|
||||||
|
func = regex[0]["fcn_name"]
|
||||||
|
r.cmd(f"s {func}")
|
||||||
|
asm = r.cmdj("pdfj")['ops']
|
||||||
|
assert len(asm) != 0
|
||||||
|
|
||||||
|
asm_regex = regex_key_iv(asm)
|
||||||
|
|
||||||
|
iv = struct.pack("<4L", *[int(asm_regex[i]['value'], 16) for i in range(4)])
|
||||||
|
|
||||||
|
# find the set key func
|
||||||
|
call_regex = [i for i in asm if i['size'] == 5 and i['type'] == 'call']
|
||||||
|
r.cmd(f"s {call_regex[1]['jump']}")
|
||||||
|
asm = r.cmdj("pdfj")["ops"]
|
||||||
|
asm_regex = regex_key_iv(asm)
|
||||||
|
assert len(asm_regex) == 8
|
||||||
|
|
||||||
|
key = struct.pack("<8L", *[int(asm_regex[i]['value'], 16) for i in range(8)])
|
||||||
|
return key, iv
|
||||||
BIN
exports.tar.gz
BIN
exports.tar.gz
Binary file not shown.
Reference in New Issue
Block a user