欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring Boot使用Allatori代碼混淆的方法

 更新時間:2018年03月02日 15:17:50   作者:Lovnx  
這篇文章主要介紹了Spring Boot使用Allatori代碼混淆的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

Allatori混淆技術(shù)介紹

Allatori是一個Java 混淆器,它屬于第二代混淆器,因此它能夠全方位地保護(hù)你的知識產(chǎn)權(quán)。 Allatori具有以下幾種保護(hù)方式:命名混淆,流混淆,調(diào)試信息混淆,字符串混淆,以及水印技術(shù)。對于教育和非商業(yè)項目來說這個混淆器是免費的。支持war和jar文件格式,并且允許對需要混淆代碼的應(yīng)用程序添加有效日期。 有項目需要對代碼進(jìn)行保護(hù),比較初級的方案就是對代碼進(jìn)行混淆,打包之后的文件進(jìn)行反編譯后,就可以看到效果。此外,使用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構(gòu)建的工程,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這個文件也很重要,看看其中的內(nèi)容:

<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文件復(fù)制到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、成功后的工程:

箭頭所指處即是我們需要的包,此包代碼已被混淆。

效果查看

這里使用反編譯工具對混淆后的包進(jìn)行查看,我用的是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(?);
 }
}

哈哈哈,怎么樣,是不是看不懂?并且混淆包照常運行,沒有任何問題。

-------》github 源碼與文檔地址《-------

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 探究實現(xiàn)Aware接口的原理及使用

    探究實現(xiàn)Aware接口的原理及使用

    這篇文章主要為大家介紹了探究實現(xiàn)Aware接口的原理及使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-04-04
  • Java中的反射機(jī)制詳解

    Java中的反射機(jī)制詳解

    這篇文章主要介紹了JAVA 反射機(jī)制的相關(guān)知識,文中講解的非常細(xì)致,代碼幫助大家更好的理解學(xué)習(xí),感興趣的朋友可以了解下
    2021-09-09
  • java搭建一個Socket服務(wù)器響應(yīng)多用戶訪問

    java搭建一個Socket服務(wù)器響應(yīng)多用戶訪問

    本篇文章主要介紹了java搭建一個Socket服務(wù)器響應(yīng)多用戶訪問,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • Java實現(xiàn)Excel批量導(dǎo)入數(shù)據(jù)

    Java實現(xiàn)Excel批量導(dǎo)入數(shù)據(jù)

    這篇文章主要為大家詳細(xì)介紹了Java實現(xiàn)Excel批量導(dǎo)入數(shù)據(jù),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111

    Caused by: java.io.IOException: DerInputStrea

    這篇文章主要介紹了Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111, too big,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-10-10
  • 大廠面試常考:快速排序冒泡排序算法

    大廠面試常考:快速排序冒泡排序算法

    快速排序由于排序效率在同為O(N*logN)的幾種排序方法中效率較高,因此經(jīng)常被采用,再加上快速排序思想----分治法也確實實用,因此很多軟件公司的筆試面試,包括像BAT、字節(jié)、美團(tuán)等知名IT公司都喜歡考查快速排序原理和手寫源碼
    2021-08-08
  • Java并發(fā)編程:volatile關(guān)鍵字詳細(xì)解析

    Java并發(fā)編程:volatile關(guān)鍵字詳細(xì)解析

    這篇文章主要介紹了Java并發(fā)編程:volatile關(guān)鍵字詳細(xì)解析,對學(xué)習(xí)volatile關(guān)鍵字有一定的認(rèn)識,有需要的可以了解一下。
    2016-11-11
  • springboot如何讀取配置文件(application.yml)中的屬性值

    springboot如何讀取配置文件(application.yml)中的屬性值

    本篇文章主要介紹了springboot如何讀取配置文件(application.yml)中的屬性值,具有一定的參考價值,有興趣的小伙伴可以了解一下
    2017-04-04
  • 使用Lombok子類繼承父類,父類屬性不生效問題及解決

    使用Lombok子類繼承父類,父類屬性不生效問題及解決

    在使用Lombok庫時,若子類繼承父類,父類的屬性可能不會自動生效,為解決此問題,可通過在父類上添加@Getter和@Setter注解,或使用@SuperBuilder注解來確保父類屬性在子類中有效,同時,需注意確保Lombok版本一致且正確配置了相關(guān)插件
    2024-10-10
  • ExecutorService實現(xiàn)獲取線程返回值

    ExecutorService實現(xiàn)獲取線程返回值

    這篇文章主要介紹了ExecutorService實現(xiàn)獲取線程返回值,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-08-08

最新評論