Spring Boot怎麼使用Allatori讓程式碼混淆
這次帶給大家Spring Boot怎麼使用Allatori讓程式碼混淆,Spring Boot使用Allatori讓程式碼混淆的注意事項有哪些,下面就是實戰案例,一起來看一下。
Allatori混淆技術介紹
# Allatori是一個Java 混淆器,它屬於第二代混淆器,因此它能夠全方位地保護你的智慧財產權。 Allatori具有以下幾種保護方式:命名混淆,流混淆,調試資訊混淆,字串#混淆,以及水印技術。對於教育和非商業項目來說這個混淆器是免費的。支援war和jar檔案格式,並允許對需要混淆程式碼的應用程式新增有效日期。 有專案需要對程式碼保護,比較初級的方案就是對程式碼混淆,打包之後的檔案進行反編譯後,就可以看到效果。此外,使用Allatori打的包體積也會小一點。
一個很普通的maven工程,不同的是在根目錄下加入Allatori的jar包。
下面我們來看看pom.xml檔:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.lovnx</groupId> <artifactId>confusion</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- Allatori plugin start --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-and-filter-allatori-config</id> <phase>package</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target</outputDirectory> <resources> <resource> <directory>${basedir}/allatori</directory> <includes> <include>allatori.xml</include> </includes> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>run-allatori</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <arguments> <argument>-Xms128m</argument> <argument>-Xmx512m</argument> <argument>-jar</argument> <argument>${basedir}/lib/allatori.jar</argument> <argument>${basedir}/target/allatori.xml</argument> </arguments> </configuration> </plugin> <!-- Allatori plugin end --> </plugins> </build> <dependencies> <!-- Test Begin --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <!-- Test End --> <!-- springboot启动 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.8.RELEASE</version> </parent> </project>
使用maven打包插件,Spring Boot建置的工程,Allatori的配置在上面也有說明,Allatori配置裡面比較重要的是:
<argument>${basedir}/lib/allatori.jar</argument> <argument>${basedir}/target/allatori.xml</argument>
指定Allatori的allatori.jar檔路徑,如果你的工程是pom工程,可以在父工程放lib目錄,然後子工程只需要:
<argument>../lib/allatori.jar</argument>
即可。
allatori.xml這個檔案也很重要,看看其中的內容:
<config> <input> <jar in="confusion-0.0.1-SNAPSHOT.jar" out="confusion-0.0.1-SNAPSHOT-obfuscated.jar"/> </input> <keep-names> <class access="protected+"> <field access="protected+"/> <method access="protected+"/> </class> </keep-names> <property name="log-file" value="log.xml"/> </config>
也就是對Allatori混淆器的具體配置,這裡可以配置很多信息,很多種策略,也可以指定哪些類不被混淆,具體的各種方式可以在在文末附件裡面的文檔得到。
這裡要說明的是:
<input> <jar in="confusion-0.0.1-SNAPSHOT.jar" out="confusion-0.0.1-SNAPSHOT-obfuscated.jar"/> </input>
confusion-0.0.1-SNAPSHOT.jar這個是打包後的未被混淆的包,而confusion-0.0.1-SNAPSHOT-obfuscated.jar是混淆後的包,這個是我們需要的。
打包步驟
1、clean maven工程。
2、將resources下面的allatori.xml檔案複製到target目錄下面。
3、install maven工程,看到以下資訊後表示成功:
################################################ # # # ## # # ## ### ### ## ### # # # # # # # # # # # # # # # # ### # # ### # # # ## # # # # # ### ### # # # ### # # ### # # # # DEMO VERSION! # # NOT FOR COMMERCIAL USE! # # # # Demo version adds System.out's # # and gives 'ALLATORI_DEMO' name # # to some fields and methods. # # # # # # Obfuscation by Allatori Obfuscator v6.4 DEMO # # # # http://www.allatori.com # # # ################################################
4.成功後的工程:
# 箭頭所指處即是我們需要的包,此包代碼已被混淆。
效果查看
這裡使用反編譯工具對混淆後的套件進行查看,我用的是jd-gui這個軟體,小巧實用。
TestApplication.java混淆前:
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class TestApplication { public static void main(String[] args) { SpringApplication.run(TestApplication.class, args); } }
TestApplication.java混淆後:
import java.io.PrintStream; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class TestApplication { public static String ALLATORIxDEMO(String a) { int tmp4_3 = 4; int tmp7_6 = 1; int tmp21_18 = a.length(); int tmp25_24 = 1; tmp25_24; int j; int ? = tmp25_24; int k = tmp21_18; int tmp35_31 = (j = new char[tmp21_18] - 1); tmp35_31; int i = 5 << 4 ^ (0x2 ^ 0x5); (tmp4_3 << tmp4_3 ^ tmp7_6 << tmp7_6); if (tmp35_31 >= 0) { int tmp45_44 = j; j--; ?[tmp45_44] = ((char)(a.charAt(tmp45_44) ^ i)); int tmp66_63 = (j--); ?[tmp66_63] = ((char)(a.charAt(tmp66_63) ^ k)); } return new String(?); } public static void main(String[] a) { System.out.println("\n################################################\n# #\n# ## # # ## ### ### ## ### #\n# # # # # # # # # # # # # #\n# ### # # ### # # # ## # #\n# # # ### ### # # # ### # # ### #\n# #\n# Obfuscation by Allatori Obfuscator v6.4 DEMO #\n# #\n# http://www.allatori.com #\n# #\n################################################\n"); SpringApplication.run(TestApplication.class, a); } }
TestController.java混淆前:
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @GetMapping("/test") public String test(){ return "88888888888888888"; } }
TestController.java混淆後:
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @GetMapping({"/test"}) public String test() { return ALLATORIxDEMO("*]*]*]*]*]*]*]*]*"); } public static String ALLATORIxDEMO(String a) { int tmp27_24 = a.length(); int tmp31_30 = 1; tmp31_30; int j; int ? = tmp31_30; int k = tmp27_24; int tmp41_37 = (j = new char[tmp27_24] - 1); tmp41_37; int i = (0x3 ^ 0x5) << 4 ^ 0x5; (2 << 3 ^ 0x2); if (tmp41_37 >= 0) { int tmp51_50 = j; j--; ?[tmp51_50] = ((char)(a.charAt(tmp51_50) ^ i)); int tmp72_69 = (j--); ?[tmp72_69] = ((char)(a.charAt(tmp72_69) ^ k)); } return new String(?); } }
相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!
推薦閱讀:
#以上是Spring Boot怎麼使用Allatori讓程式碼混淆的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)
![Windows ISO檔太大BootCamp錯誤[修復]](https://img.php.cn/upload/article/000/887/227/170831702395455.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
如果在Mac電腦上使用BootCampAssistant時出現"TheWindowsISO檔案太大"的錯誤訊息,這可能是由於ISO檔案大小超過BootCampAssistant所支援的限制。解決這個問題的方法是使用其他工具來壓縮ISO檔案大小,以確保其在BootCampAssistant中能夠被處理。 BootCampAssistant是蘋果提供的一種方便的工具,用於在Mac電腦上安裝並運行Windows作業系統。它可以幫助使用者設定雙重開機系統,讓他們可以輕鬆地在啟動時選擇使用MacOS還是Wind

2023年,AI技術已成為熱門話題,對各行業產生了巨大影響,程式設計領域尤其如此。人們越來越認識到AI技術的重要性,Spring社群也不例外。隨著GenAI(GeneralArtificialIntelligence)技術的不斷進步,簡化具備AI功能的應用程式的創建變得至關重要和迫切。在這個背景下,"SpringAI"應運而生,旨在簡化開發AI功能應用程式的過程,使其變得簡單直觀,避免不必要的複雜性。透過"SpringAI",開發者可以更輕鬆地建立具備AI功能的應用程序,將其變得更加易於使用和操作

Spring+AI作為行業領導者,透過其強大、靈活的API和先進的功能,為各種行業提供了領先性的解決方案。在本專題中,我們將深入探討Spring+AI在各領域的應用範例,每個案例都將展示Spring+AI如何滿足特定需求,實現目標,並將這些LESSONSLEARNED擴展到更廣泛的應用。希望這個專題能對你有所啟發,更深入地理解和利用Spring+AI的無限可能。 Spring框架在軟體開發領域已經有超過20年的歷史,自SpringBoot1.0版本發布以來已有10年。現在,無人會質疑,Spring

java實作定時任務Jdk自帶的函式庫中,有兩種方式可以實作定時任務,一種是Timer,另一種是ScheduledThreadPoolExecutor。 Timer+TimerTask建立一個Timer就建立了一個線程,可以用來調度TimerTask任務Timer有四個建構方法,可以指定Timer線程的名字以及是否設定為守護線程。預設名字Timer-編號,預設不是守護線程。主要有三種比較重要的方法:cancel():終止任務調度,取消目前調度的所有任務,正在運行的任務不受影響purge():從任務團隊

spring編程式事務的實作方式:1、使用TransactionTemplate;2、使用TransactionCallback和TransactionCallbackWithoutResult;3、使用Transactional註解;4、使用TransactionTemplate和@Transactional結合使用;5、自訂事務管理器。

SpringBoot和SpringCloud都是SpringFramework的擴展,它們可以幫助開發人員更快地建置和部署微服務應用程序,但它們各自有不同的用途和功能。 SpringBoot是一個快速建立Java應用程式的框架,讓開發人員可以更快地建立和部署基於Spring的應用程式。它提供了一個簡單、易於理解的方式來建立獨立的、可執行的Spring應用

Spring設定事務隔離等級的方法:1、使用@Transactional註解;2、在Spring設定檔中設定;3、使用PlatformTransactionManager;4、在Java配置類別中設定。詳細介紹:1、使用@Transactional註解,在需要進行事務管理的類別或方法上加入@Transactional註解,並在屬性中設定隔離等級;2、在Spring設定檔等等。

作為一名Java開發者,學習和使用Spring框架已經是一項必不可少的技能。而隨著雲端運算和微服務的盛行,學習和使用SpringCloud成為了另一個必須掌握的技能。 SpringCloud是一個基於SpringBoot的用於快速建立分散式系統的開發工具集。它為開發者提供了一系列的元件,包括服務註冊與發現、配置中心、負載平衡和斷路器等,使得開發者在建構微
