當前位置:
首頁 > 知識 > XJar: Spring-Boot JAR 包加密運行工具,避免源碼泄露以及反編譯

XJar: Spring-Boot JAR 包加密運行工具,避免源碼泄露以及反編譯

GitHub: https://github.com/core-lib/xjar

Spring Boot JAR 安全加密運行工具,同時支持的原生JAR。

基於對JAR包內資源的加密以及拓展ClassLoader來構建的一套程序加密啟動,動態解密運行的方案,避免源碼泄露或反編譯。

功能特性

無需侵入代碼,只需要把編譯好的JAR包通過工具加密即可。

完全內存解密,杜絕源碼以及位元組碼泄露以及反編譯。

支持所有JDK內置加解密演算法。

可選擇需要加解密的位元組碼或其他資源文件,避免計算資源浪費。

環境依賴

JDK 1.7 +

使用步驟

<project>

<!-- 設置 jitpack.io 倉庫 -->

<repositories>

<repository>

<id>jitpack.io</id>

<url>https://www.jitpack.io</url>

</repository>

</repositories>

<!-- 添加 XJar 依賴 -->

<dependencies>

<dependency>

<groupId>com.github.core-lib</groupId>

<artifactId>xjar</artifactId>

<version>LATEST_VERSION</version>

</dependency>

</dependencies>

</project>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

// Spring-Boot Jar包加密

public static void main(String[] args) {

String password = "io.xjar";

File plaintext = new File("/path/to/read/plaintext.jar");

File encrypted = new File("/path/to/save/encrypted.jar");

XBoot.encrypt(plaintext, encrypted, password);

}

1

2

3

4

5

6

7

// Spring-Boot Jar包解密

public static void main(String[] args) {

String password = "io.xjar";

File encrypted = new File("/path/to/read/encrypted.jar");

File decrypted = new File("/path/to/save/decrypted.jar");

XBoot.decrypt(encrypted, decrypted, password);

}

1

2

3

4

5

6

7

// Jar包加密

public static void main(String[] args) {

String password = "io.xjar";

File plaintext = new File("/path/to/read/plaintext.jar");

File encrypted = new File("/path/to/save/encrypted.jar");

XJar.encrypt(plaintext, encrypted, password);

}

1

2

3

4

5

6

7

// Jar包解密

public static void main(String[] args) {

String password = "io.xjar";

File encrypted = new File("/path/to/read/encrypted.jar");

File decrypted = new File("/path/to/save/decrypted.jar");

XJar.decrypt(encrypted, decrypted, password);

}

1

2

3

4

5

6

7

// 命令行運行JAR

java -jar /path/to/encrypted.jar

// 在提示輸入密碼的時候輸入密碼後按回車即可正常啟動,也可以通過傳參的方式直接啟動

java -jar /path/to/encrypted.jar --xjar.password=PASSWORD

1

2

3

4

參數說明

–xjar.algorithm 加解密演算法名稱,預設為AES,支持JDK所有內置演算法,如AES / DES …

–xjar.keysize 密鑰長度,預設為128,根據不同的演算法選取不同的密鑰長度。

–xjar.ivsize 向量長度,預設為128,根據不同的演算法選取不同的向量長度。

–xjar.password 密碼

進階用法

// 只加密自身項目及相關模塊的源碼不加密第三方依賴,可以通過XJarArchiveEntryFilter來定製需要加密的JAR包內資源

public static void main(String[] args) {

String password = "io.xjar";

File plaintext = new File("/path/to/read/plaintext.jar");

File encrypted = new File("/path/to/save/encrypted.jar");

XBoot.encrypt(plaintext, encrypted, password, new XJarArchiveEntryFilter() {

@Override

public boolean filter(JarArchiveEntry entry) {

return entry.getName().startsWith("/BOOT-INF/classes/")

|| entry.getName().startsWith("/BOOT-INF/lib/jar-need-encrypted");

}

});

}

1

2

3

4

5

6

7

8

9

10

11

12

13

變更記錄

v1.0.5

支持並行類載入,需要JDK1.7+的支持,可提升多線程環境類載入的效率

Spring-Boot JAR 包加解密增加一個安全過濾器,避免無關資源被加密造成無法運行

XBoot / XJar 工具類中增加多個按文件路徑加解密的方法,提升使用便捷性

v1.0.4 小優化

v1.0.3 增加Spring-Boot的FatJar加解密時的預設過濾器,避免由於沒有提供過濾器時加密後的JAR包不能正常運行。

v1.0.2 修復中文及空格路徑的問題

v1.0.1 升級detector框架

v1.0.0 第一個正式版發布

協議聲明

Apache-2.0

---------------------

作者:不會釣魚的兔子

原文:https://blog.csdn.net/ChangeYoung1921/article/details/84621787

XJar: Spring-Boot JAR 包加密運行工具,避免源碼泄露以及反編譯

打開今日頭條,查看更多圖片
喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 程序員小新人學習 的精彩文章:

nmap埠檢測命令總結&kali自帶wafw00f工具
Class.getResource和ClassLoader.getResource的區別分析

TAG:程序員小新人學習 |