Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 38f5535

Browse files
committed
new readme me
1 parent 0734389 commit 38f5535

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919

2020
![hex](img/003.png)
2121

22+
使用指定参数启动即可禁止 `Java Agent` 动态 `dump` 字节码
23+
24+
![](img/007.png)
25+
26+
对于更资深的黑客,他们会想到 `sa-jdi``HSDB``dump` 字节码
27+
28+
我参考 `Beichen` 师傅议题的思路,从 `JVM` 里禁用了 `gHotSpotVMStructs` 函数
29+
30+
![](img/008.png)
31+
2232
## 快速开始
2333

2434
加密解密部分使用`C`做一层加密,使用`汇编`二层加密,已提供编译好的`Release`版本`DLL/SO`文件嵌入`Jar`包中
@@ -46,7 +56,7 @@ java -jar code-encryptor-plus.jar export
4656
注意必须有两个参数`PACKAGE_NAME``KEY`
4757

4858
```shell
49-
java -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-key --jar your-jar.jar
59+
java -XX:+DisableAttachMechanism -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-key --jar your-jar.jar
5060
```
5161

5262
![](img/006.png)
@@ -63,6 +73,7 @@ java -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-ke
6373
- 原文章的代码仅是`Demo`级别,无法直接上手测试和使用
6474
- 原文章没有加入具体的加密算法,仅是简单的运算,需要加强
6575
- 原文章的代码存在一些`BUG`和优化空间
76+
- 使用某些魔法操作,使字节码无法被 `dump` 进一步保证安全
6677

6778
目前的加密解密算法:
6879
- 汇编实现的多次位运算,交换字节等
@@ -82,18 +93,15 @@ java -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-ke
8293

8394
## 其他
8495

85-
不适用于`SpringBoot`场景,存在两个问题:
86-
- `SpringBoot`不允许压缩`lib`依赖(这个有解决办法)
87-
- `SpringBoot`启动扫描会分析`class`由于加密报错
88-
89-
网上提供了两种办法,可以参考
96+
不适用于启动扫描 `class` 的项目
9097

91-
参考:https://zhuanlan.zhihu.com/p/545268749
92-
93-
类似地,启动扫描`class`的代码是无法使用这种加密的
98+
防止 `sa-jdi` 的思路仅在 `windows` 中测试
9499

95100
## 参考
96101

102+
特别感谢 `BeichenDream` 师傅
103+
97104
感谢以下项目或文章提供的思路:
105+
- https://mp.weixin.qq.com/s/89Bmvy_uY97TZm3vR9lyWw
98106
- https://juejin.cn/post/6844903487784894477
99107
- https://github.com/sea-boat/ByteCodeEncrypt

doc/README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ Apart from retaining the `Magic` part at the beginning, the rest becomes unrecog
1717

1818
![hex](../img/003.png)
1919

20+
Use some param to prevent `Java Agent` to `dump` byte code.
21+
22+
![](../img/007.png)
23+
24+
Some hackers may found `sa-jdi` and `HSDB` to `dump` byte code.
25+
26+
Refer to `Beichen` articles, prevent `gHotSpotVMStructs` function of `JVM`.
27+
28+
![](../img/008.png)
29+
2030
## Quick Start
2131

2232
The encryption and decryption process involves two layers of encryption: the first layer in `C` and the second layer in `assembly`. Precompiled `Release` versions of `DLL/SO` files are included in the `Jar` package.
@@ -43,7 +53,7 @@ Launching the Jar Package with Decryption DLL/SO: (Using the `-agentpath` Parame
4353

4454
Please note that you must provide two parameters: `PACKAGE_NAME` and `KEY`.
4555
```shell
46-
java -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-key --jar your-jar.jar
56+
java -XX:+DisableAttachMechanism -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-key --jar your-jar.jar
4757
```
4858

4959
![](../img/006.png)
@@ -61,6 +71,7 @@ Compared to publicly available articles/code online, this project has several ad
6171
- The original article's code was only at a demo level, making it difficult for users to test and use directly.
6272
- The original article did not include specific encryption algorithms; it only involved simple operations and needed enhancement.
6373
- The original article's code had some bugs and room for optimization.
74+
- Use some magic that hackers can not dump any byte code.
6475

6576
The current encryption and decryption algorithm includes:
6677

@@ -81,19 +92,16 @@ The `native` directory is built using `cmake`, generating `dll` and `so` files t
8192

8293
## Notes
8394

84-
This solution is not suitable for `SpringBoot` scenarios due to two issues:
85-
- `SpringBoot` does not allow the compression of `lib` dependencies (there are workarounds).
86-
- `SpringBoot` startup scanning will analyze `class` files, leading to errors when encrypted.
87-
88-
Two solutions are available online, which you can refer to:
95+
This approach is not suitable for scanning projects that involve launching the scanning of `class` files.
8996

90-
Reference: https://zhuanlan.zhihu.com/p/545268749
97+
The prevention strategy using `sa-jdi` is only tested on `Windows`.
9198

92-
Similarly, this encryption method cannot be used with code that scans `class` files during startup.
99+
## Refer
93100

94-
## References
101+
Thanks to `BeichenDream`
95102

96-
Thanks to the following projects or articles for providing insights:
103+
Thanks for these articles:
104+
- https://mp.weixin.qq.com/s/89Bmvy_uY97TZm3vR9lyWw
97105
- https://juejin.cn/post/6844903487784894477
98106
- https://github.com/sea-boat/ByteCodeEncrypt
99107

img/007.png

59.9 KB
Loading

img/008.png

43.9 KB
Loading

src/main/resources/decrypter.dll

0 Bytes
Binary file not shown.

src/main/resources/encryptor.dll

0 Bytes
Binary file not shown.

tools.jar

17.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)