日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringBoot2 集成xJar插件 动态解密jar包,避免源码泄露或反编译

發布時間:2024/9/27 javascript 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot2 集成xJar插件 动态解密jar包,避免源码泄露或反编译 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、集成
1. 官方介紹地址

手動加密:https://github.com/core-lib/xjar
maven插件集成:https://github.com/core-lib/xjar-maven-plugin

2. 添加倉庫和插件

第一種(不推薦使用)

<project><!-- 設置 jitpack.io 插件倉庫 --><pluginRepositories><pluginRepository><id>jitpack.io</id><url>https://jitpack.io</url></pluginRepository></pluginRepositories><!-- 添加 XJar Maven 插件 --><build><plugins><plugin><groupId>com.github.core-lib</groupId><artifactId>xjar-maven-plugin</artifactId><version>4.0.2</version><executions><execution><goals><goal>build</goal></goals><!--可以改成 install--><phase>package</phase><configuration><password>xxxx</password><!-- 需要加密的資源路徑表達式 --><includes>         <include>com/zsplat/**</include><include>mapper/*Mapper.xml</include><include>config/**</include></includes><!-- 無需加密的資源路徑表達式 --><excludes><exclude>static/**</exclude><exclude>META-INF/**</exclude></excludes><!-- 目標jar存放目錄 --><targetDir>${project.build.directory}\xJarDir\</targetDir><!-- 目標jar名稱,也可以用表達式(參考官網) --><targetJar>zsplat.jar</targetJar></configuration></execution></executions></plugin></plugins></build> </project>

第二種(推薦使用):就是把密碼配置刪除,采用編譯打包添加密碼會安全些
https://jitpack.io Maven倉庫

<!-- 設置 jitpack.io 插件倉庫 --><pluginRepositories><pluginRepository><id>jitpack.io</id><url>https://jitpack.io</url></pluginRepository></pluginRepositories><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><!--開源官網:https://github.com/core-lib/xjar-maven-plugin--><plugin><groupId>com.github.core-lib</groupId><artifactId>xjar-maven-plugin</artifactId><version>4.0.2</version><executions><execution><goals><goal>build</goal></goals><phase>package</phase><!-- 或使用<phase>install</phase>--><configuration><excludes><exclude>static/**</exclude><exclude>templates/**</exclude><exclude>resources/**</exclude><exclude>META-INF/resources/**</exclude></excludes><!-- 目標jar存放目錄 --><targetDir>${project.build.directory}\xJarDir\</targetDir><!-- 目標jar名稱,也可以用表達式(參考官網) --><targetJar>unified-access-center-passwd.jar</targetJar></configuration></execution></executions></plugin></plugins></build>
3. 編譯打包

上面xJar插件綁定到指定的 package ,因此每次執行 mvn clean package -Dxjar.password=io.xjar即可自動構建出加密的包,

mvn clean install -Dxjar.password=io.xjar

如下圖:

根目錄中 unified-access-center-0.0.1-SNAPSHOT.jar 是未加密的,而 xJarDir 文件夾下的 unified-access-center-passwd.jar 就是加密后的。

注釋:
jar包名稱可以一樣,前提是不在同一個目錄中即可,這里jar名稱不一樣只是為了讓大家看得清楚些而已

二、安裝go環境和編譯

在對應的 xJarDir 文件夾目錄編譯腳本(go build xjar.go)。在不同的平臺進行編譯即可得到不同平臺的啟動器可執行文件,其中Windows下文件名為 xjar.exe 而Linux下為 xjar

2.1. 安裝go

用于編譯的機器需要安裝 Go 環境,用于運行的機器則可不必安裝 Go 環境
https://blog.csdn.net/weixin_40816738/article/details/120386291

2.2. 編譯

演示編譯環境linux,由于windows有一些bug
上傳linux

go build xjar.go

三、運行
3.1. 正常運行
./xjar java -Dfile.encoding=utf-8 -jar unified-access-center-passwd.jar
3.2. 二次加密運行

聲明:如果小伙伴們不需要二次加密,請跳過3.2. 步驟

我的運行方式是這樣的,因為我單獨對yml文件中的敏感信息進行了二次加密,因此需要添加-Djasypt.encryptor.password=gblfy.com這一段,特別注意點,建議按照我的命令的前后順序

./xjar java -Dfile.encoding=utf-8 -Djasypt.encryptor.password=gblfy.com -jar unified-access-center-passwd.jar

如果小伙伴們,也想和我一樣對敏感信息二次加密,請移步:
Spring Boot2 集成 jasypt 3.0.4 配置文件敏感信息加密

3.3. 測試結果

目的:這里是先運行保證正常功能無影響,下面會對jar進行反編譯測試

四、IntelliJ IDE 反編譯測試
4.1. 將加密的jar進行解壓

4.2. 打開解壓后的文件夾

4.3. class文件查看

4.4. 配置文件反編譯

4.5. xml文件反編譯

五、jd-gui 反編譯測試
5.1. 沒加密的jar效果
  • 沒加密的jar效果
5.2. 加密jar的效果
  • 加密jar的效果
    說明一下:這里不是我沒把文件打開,這是我選中文件雙擊打開后的效果,小伙伴們可以試試
六、XJad反編譯測試
6.1. 沒加密的jar效果

6.2. 加密的jar效果

七、XJad反編譯測試
7.1. 沒加密的jar效果

7.2. 加密的jar效果

八、反編譯工具集合分享

java 反編譯工具

總結

以上是生活随笔為你收集整理的SpringBoot2 集成xJar插件 动态解密jar包,避免源码泄露或反编译的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。