Files
verify/docker/dogprotect/README.md
T
admin 752ec713c0
Docker Build / Build and Push Docker Image (push) Failing after 8s
Docker Build / Deploy to Server (push) Skipped
feat(protect): 加壳流程默认串上 DogProtect,先保护代码再注入验证壳
需求:打出来的产物默认带 DogProtect 保护,不要每次手动两步。

## 顺序(关键)

必须 **先 DogProtect、后注入验证壳**,反过来不行:

  src → dogprotect_con → PatchAutoSignedThemed(追加 .load)→ [可选重签]

DogProtect 会把要保护的节打包、把 SizeOfRawData/PointerToRawData 清零。
若先注入 .load 再跑 DogProtect,.load 的内容被搬进打包节、磁盘上只剩一个
raw size = 0 的空节,验证壳运行时读不到自己的配置 —— 整个验证静默失效。
实测过这个反向顺序,vfyfix 只会报「节区间异常: off=0 raw=...」,
它重算的是 CRC,救不回被搬走的内容。

## 实现

- :封装 dogprotect_con 调用
  (DOGPROTECT_DIR 定位、180s 超时、退出码和产物双重校验、
  从输出里捞 Output file size 做备注、尾部报错带回任务 message)
-  加壳主流程:KindPE 且加壳器可用时先跑 DogProtect,
  产物再进 Patch。失败直接让任务失败 —— 保护是默认承诺,
  不能悄悄降级成「只打了验证壳」
- 只对 PE 生效;APK/IPA/ELF/Mach-O 走各自原分支

## 镜像

dogprotect_con 是 glibc 程序且要求 GLIBC_2.38+ / GLIBCXX_3.4.32+:
alpine 的 gcompat 跑不起来,bookworm 的 glibc 2.36 也差一截。
runtime 基础镜像 alpine → debian:trixie-slim(glibc 2.41),实测能跑。

配套改动:
- apk → apt;openjdk17 → trixie 的 openjdk-21(apktool 兼容)
- osslsigncode 用 trixie 现成包,删掉源码编译的 signer-builder 阶段
- entrypoint 的 su-exec(alpine 专有)→ util-linux 的 setpriv
- 加壳器三个文件拷到 /app/tools/dogprotect/(必须同目录,-rpath,$ORIGIN)

## 实测

- Linux 直接调用:310784 → 6140928 字节,4.3 秒,输出
  「Output file size is 6140928 bytes (1975%)」
- 完整链路(先 dog 后 verify):7195136 字节,wine 跑起来验证界面正常、
  tab 是「登录/我的设备/卡密充值/找回绑定」、输入框「卡密」、无黑块错位

注意:随源码带的是 TestLicense(TestUser),换正式授权替换
docker/dogprotect/DogProtectLicense.ini 即可,代码不用动。
2026-11-29 12:44:32 +08:00

39 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DogProtect 加壳器(Linux 版)
`dogprotect_con` 是 DogProtect Ultimate v3.5.1 的命令行加壳器,由 DogProtect 仓库
(`/root/work/vmprotect`)用 `lin_console64.mak` 构建:
```bash
cd /root/work/vmprotect/DogProtectCon
make -f lin_console64.mak # 产物在 ../bin/64/release/dogprotect_con
```
三个文件必须放在同一个目录里(加壳器链接时是 `-Wl,-rpath,$ORIGIN`):
| 文件 | 作用 |
|---|---|
| `dogprotect_con` | 加壳器本体(42M,glibc 动态链接) |
| `libDogProtectSDK64.so` | SDK 运行时库,缺了会报 `DaveProtectSetSerialNumber: symbol not found` |
| `DogProtectLicense.ini` | 授权文件。当前是随源码带的 TestLicense(TestUser),换正式授权直接替换这个文件 |
**glibc 要求 2.38+ / GLIBCXX 3.4.32+** —— 这是容器基础镜像从 alpine 换成
`debian:trixie-slim` 的原因。alpine 的 gcompat 跑不起来,bookworm(glibc 2.36)也差一截。
## 加壳顺序:必须先 DogProtect、后注入验证壳
DogProtect 会把要保护的节打包、把 `SizeOfRawData`/`PointerToRawData` 清零。
如果先注入验证壳的 `.load` 节、再跑 DogProtect,`.load` 的内容会被搬进打包节,
磁盘上只剩一个 raw size = 0 的空节 —— 验证壳运行时读不到自己的配置,
整个验证静默失效(`vfyfix` 只能重算 CRC,救不回被搬走的内容)。
反过来是可行的,`protect.go` 里就是这么串的:
```
源程序 → dogprotect_con → PatchAutoSignedThemed(追加 .load)→ [可选 Authenticode 重签]
```
运行时顺序:`.load` 壳先跑(显示验证界面、校验授权)→ 通过后跳回原入口
→ DogProtect 启动代码解包 → 原程序执行。
实测(wine):先 dog 后 verify 的产物能正常出验证界面、卡密模式正确、无黑块错位。