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

Commit 4951e92

Browse files
committed
english doc
1 parent 6dcf5df commit 4951e92

File tree

4 files changed

+117
-29
lines changed

4 files changed

+117
-29
lines changed

CHANGELOG.MD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ GUI 版本的使用和 CLI 版本基本一致,具体参考 README 文件
3636

3737
## 0.3
3838

39-
todo
39+
更新日志:
40+
- 加入了英文版本文档

README.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
## 介绍
77

8+
[English Doc](doc/README.md)
9+
810
使用`JNI`加密字节码,通过`JVMTI`解密字节码以保护代码
911

1012
提供两份`DLL`文件,一份加密一份解密,实际运行只需使用解密`DLL`文件,支持自定义密钥和包名
@@ -17,34 +19,6 @@
1719

1820
![hex](img/003.png)
1921

20-
## 更新日志
21-
22-
### 0.2
23-
24-
更新日志:
25-
- 基于`gcc``nasm`支持`linux x86_64 (amd64)`
26-
- 支持`Windows``Linux`任意密钥加密解密
27-
- 使用`execstack``so`库修改堆栈可执行属性
28-
- 汇编中部分寄存器忘记恢复状态导致某些`JVM`崩溃
29-
- 修复`linux`中字符串处理函数的缓冲区溢出问题
30-
- 修改`README`部分应该使用`-agentpath`启动
31-
- 优化重构`Java`层代码,抽出工具类等
32-
- 避免重复宏定义的问题
33-
34-
## 特点
35-
36-
本项目相比于网上公开的文章/代码,优势和特点有以下几条:
37-
- 原文章固定了包名,用户想加密自己的包名需要重新编译`DLL`
38-
- 原文章加密和解密`DLL`是同一个,这样只用`JNI`调用下加密即可破解
39-
- 原文章的代码仅是`Demo`级别,无法直接上手测试和使用
40-
- 原文章没有加入具体的加密算法,仅是简单的运算,需要加强
41-
- 原文章的代码存在一些`BUG`和优化空间
42-
43-
目前的加密解密算法:
44-
- 汇编实现的多层位运算,交换字节等
45-
- 三次`XXTEA`算法,抽取`10-34`位字节
46-
- 支持自定义密钥
47-
4822
## 快速开始
4923

5024
加密解密部分使用`C`做一层加密,使用`汇编`二层加密,已提供编译好的`Release`版本`DLL/SO`文件嵌入`Jar`包中
@@ -81,6 +55,20 @@ java -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-ke
8155

8256
![screenshot](img/001.png)
8357

58+
## 特点
59+
60+
本项目相比于网上公开的文章/代码,优势和特点有以下几条:
61+
- 原文章固定了包名,用户想加密自己的包名需要重新编译`DLL`
62+
- 原文章加密和解密`DLL`是同一个,这样只用`JNI`调用下加密即可破解
63+
- 原文章的代码仅是`Demo`级别,无法直接上手测试和使用
64+
- 原文章没有加入具体的加密算法,仅是简单的运算,需要加强
65+
- 原文章的代码存在一些`BUG`和优化空间
66+
67+
目前的加密解密算法:
68+
- 汇编实现的多次位运算,交换字节等
69+
- 基于`XXTEA`算法,多轮加密
70+
- 支持自定义密钥,进一步保护
71+
8472
## 构建
8573

8674
编译环境:

doc/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# code-encryptor-plus
2+
3+
[![](https://img.shields.io/github/v/release/Y4Sec-Team/code-encryptor-plus)](https://github.com/Y4Sec-Team/code-encryptor-plus/releases/latest)
4+
![](https://img.shields.io/github/downloads/Y4Sec-Team/code-encryptor-plus/total)
5+
6+
## Introduce
7+
8+
This project uses `JNI` to encrypt bytecode and `JVMTI` to decrypt bytecode in order to protect code.
9+
10+
It provides two `DLL` files: one for encryption and one for decryption. During actual execution, only the decryption `DLL` file is used. It supports custom keys and package names.
11+
12+
The encrypted `Class` files become malformed and cannot be parsed.
13+
14+
![jd-gui](../img/002.png)
15+
16+
Apart from retaining the `Magic` part at the beginning, the rest becomes unrecognizable bytes.
17+
18+
![hex](../img/003.png)
19+
20+
## Quick Start
21+
22+
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.
23+
24+
Built-in support is for `JDK-8`, but other versions of `JDK` only require replacing the `JNI.h` header file and recompiling. The new version also supports both `Windows` and `Linux`.
25+
26+
To encrypt your `Jar` package (specify the `Jar` package, the package name to encrypt, and the encryption key):
27+
28+
```shell
29+
java -jar code-encryptor-plus.jar patch --jar your-jar.jar --package com.your.pack --key your-key
30+
```
31+
32+
![](../img/004.png)
33+
34+
When exporting the decryption `DLL/SO` files, they will be placed in the default export directory, which is `code-encryptor-plus-temp`. It is not recommended to modify this directory.
35+
36+
```shell
37+
java -jar code-encryptor-plus.jar export
38+
```
39+
40+
![](../img/005.png)
41+
42+
Launching the Jar Package with Decryption DLL/SO: (Using the `-agentpath` Parameter)
43+
44+
Please note that you must provide two parameters: `PACKAGE_NAME` and `KEY`.
45+
```shell
46+
java -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NAME=com.your.pack,KEY=your-key --jar your-jar.jar
47+
```
48+
49+
![](../img/006.png)
50+
51+
We also offer a straightforward GUI version that allows you to encrypt your chosen `Jar` file with a single click. (Available for Windows only)
52+
53+
![screenshot](../img/001.png)
54+
55+
## Features
56+
57+
Compared to publicly available articles/code online, this project has several advantages and features:
58+
59+
- The original article had a fixed package name, and users who want to encrypt their own package names need to recompile the `DLL`.
60+
- The original article used the same encryption and decryption `DLL`, making it easier to crack by simply calling encryption using `JNI`.
61+
- The original article's code was only at a demo level, making it difficult for users to test and use directly.
62+
- The original article did not include specific encryption algorithms; it only involved simple operations and needed enhancement.
63+
- The original article's code had some bugs and room for optimization.
64+
65+
The current encryption and decryption algorithm includes:
66+
67+
- Multiple bitwise operations implemented in assembly, byte swapping, and more.
68+
- Based on the `XXTEA` algorithm with multiple rounds of encryption.
69+
- Supports custom keys for further protection.
70+
71+
## Building
72+
73+
Compilation Environment:
74+
- Windows 11 / Ubuntu 22.04
75+
- JDK 8 / Maven
76+
- MSVC + ml64 (Windows) / gcc + nasm (Linux)
77+
- CMake 3.x
78+
- Python 3.x
79+
80+
The `native` directory is built using `cmake`, generating `dll` and `so` files that are then moved to the `resources` directory for Maven to build.
81+
82+
## Notes
83+
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:
89+
90+
Reference: https://zhuanlan.zhihu.com/p/545268749
91+
92+
Similarly, this encryption method cannot be used with code that scans `class` files during startup.
93+
94+
## References
95+
96+
Thanks to the following projects or articles for providing insights:
97+
- https://juejin.cn/post/6844903487784894477
98+
- https://github.com/sea-boat/ByteCodeEncrypt
99+

img.png

-48.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)