hcrdso/Decrypton
GitHub: hcrdso/Decrypton
Decrypton 是一款 Windows x64 PE 内存转储与分析工具,提供捕获、导入重建、结构验证、差异比对和离线密钥转换等功能,服务于授权的逆向工程与二进制分析场景。
Stars: 1 | Forks: 0
# Decrypton
**Windows PE 捕获、重建、验证、差异比对和显式密钥离线转换套件。**





## 范围
Decrypton 使用文档化的 Windows API 在用户模式下运行。capture 命令仅读取 Windows 报告为可访问的内存。不可读取的字节仍从原始磁盘映像中获取,并且覆盖率记录在 JSON 报告中。
transform 命令不是自动的密码分析。它需要操作员提供确切的算法、密钥和 IV。
## 要求
- Windows 10 或 Windows 11 x64。
- Visual Studio 2022 及 **Desktop development with C++**。
- Windows SDK。
- CMake 3.21 或更高版本。
## 构建
在 x64 Developer Command Prompt 中,最简单的方法是:
```
cmake --preset vs2022-x64
cmake --build --preset release
ctest --preset release
```
不使用预设:
```
cmake -S . -B build -A x64
cmake --build build --config Release
ctest --test-dir build -C Release --output-on-failure
```
可执行文件生成于:
```
build\Release\decrypton.exe
```
## 命令
### 捕获
```
decrypton capture --process Example.exe --output Example-dumped.exe
```
转储选定的 DLL:
```
decrypton capture --process Example.exe --module ExampleCore.dll --output ExampleCore-dumped.dll
```
生成覆盖率 JSON 和 Windows minidump:
```
decrypton capture --process Example.exe ^
--output Example-dumped.exe ^
--report Example-report.json ^
--minidump Example.dmp
```
不重建导入的保守捕获:
```
decrypton capture --process Example.exe --output Example-raw.exe --no-imports
```
旧的 0.3 语法仍然有效:
```
decrypton --process Example.exe --output Example-dumped.exe
```
运行 `decrypton capture --help` 以查看所有 capture 选项。
### Inspect
```
decrypton inspect Example-dumped.exe
```
保存机器可读的报告:
```
decrypton inspect Example-dumped.exe --json inspect.json
```
输出包括:
- SHA-256。
- PE32 或 PE32+ 格式和机器类型。
- Image base 和 entry point。
- Section 的 RVA、原始范围、特征和 Shannon 熵。
- 已填充的 PE 数据目录。
### Verify
```
decrypton verify Example-dumped.exe
```
严格模式将警告视为失败:
```
decrypton verify Example-dumped.exe --strict --json verify.json
```
验证器检查:
- DOS、NT 和 optional 头。
- 文件和 section 对齐。
- 原始和虚拟 section 边界及重叠。
- `SizeOfHeaders` 和 `SizeOfImage`。
- Entry-point 放置。
- 数据目录边界。
- 导入描述符、thunk 数组和导入名称。
- 导出表。
- Base-relocation 块。
- x64 异常目录大小。
- TLS 目录边界。
只有在所选模式下验证成功时,退出状态才为零。
### Diff
```
decrypton diff Original.exe Candidate.exe
```
使用 JSON 和自定义块大小:
```
decrypton diff Original.exe Candidate.exe --block 4096 --json diff.json
```
该命令报告:
- 两个文件的 SHA-256 哈希值和大小。
- 总更改字节数。
- 连续的更改范围。
- 更改的固定大小块。
- 同名 PE section 的更改字节。
非零退出状态表示文件不同。
### 离线转换
重复密钥 XOR:
```
decrypton transform encrypted.bin ^
--algorithm xor ^
--key-hex A55A10FF ^
--output decoded.bin
```
带有 PKCS#7 padding 的 AES-256-CBC 解密:
```
decrypton transform encrypted.bin ^
--algorithm aes-256-cbc ^
--mode decrypt ^
--key-hex 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F ^
--iv-hex 0F0E0D0C0B0A09080706050403020100 ^
--output decoded.bin
```
AES 加密使用带有 `--mode encrypt` 的相同命令。
## 推荐工作流
```
decrypton capture --process LabTarget.exe --output capture.exe --report capture.json
decrypton verify capture.exe --json verification.json
decrypton inspect capture.exe --json inspection.json
decrypton diff LabTarget-original.exe capture.exe --json differences.json
```
这将获取与分析分离开来,并使每个决策都可审计。
## 测试
CTest 目前涵盖:
- 版本和帮助调度。
- 构建可执行文件的结构验证。
- AES-256-CBC 加密/解密往返测试。
- XOR 往返测试。
GitHub Actions 在 `windows-2022` 上构建并测试该项目。
## 限制
- Capture 支持 x64 PE32+ 模块。
- 离线 inspect 和 verify 支持 PE32 和 PE32+。
- Capture 无法读取不可访问、受保护或受保护的内存。
- 导入重建是启发式的,之后应始终进行验证。
- AES-CBC 转换需要兼容 PKCS#7 的 padding。
- 验证器有意保持保守,可能会报告异常但可加载的映像。
- Decrypton 不会恢复未知的加密密钥或自动识别每个自定义转换。
## 负责任地使用
仅在合法的逆向工程、事件响应、互操作性、软件保存、受控的恶意软件研究、教育和授权竞赛中使用 Decrypton。您有责任遵守适用的法律、许可证、规则和范围限制。
## 作者
由 **hcrdso** 创建。