大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節(jié)點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 學習攻略 Java學習 Java代碼混淆的實現(xiàn)方法

Java代碼混淆的實現(xiàn)方法

更新時間:2022-12-28 13:15:24 來源:動力節(jié)點 瀏覽2400次

Proguard 是一個用純 Java 編寫的混淆工具,有兩種使用 JAR 客戶端的方法。可以將程序打包成JAR,然后用工具進行混淆,或者導入PROGUARD插件進行代碼混淆。在這種情況下,代碼對于普通的 JavaWeb 項目來說是混淆的。Maven配置插件如下:

<! - Proguard Confused Plug ->
<plugin>
   <groupId>com.github.wvengen</groupId>
   <artifactId>proguard-maven-plugin</artifactId>
   <version>2.0.11</version>
   <executions>
      <execution>
         <! - Confused moments, here is confusing when packaging ->
         <phase>package</phase>
         <goals>
            <! - What is the function of using a plugin, of course confused ->
            <goal>proguard</goal>
         </goals>
      </execution>
   </executions>
   <configuration>
      <! - Whether to install the generated PG file ->
      <attach>true</attach>
      <! - Confusion ->
      <obfuscate>true</obfuscate>
      <! - Specify the generated file classification ->
      <attachArtifactClassifier>pg</attachArtifactClassifier>
      <options>
         <! - JDK Target Version 1.8 ->
         <option>-target 1.8</option>
         <! - Do not contraction (delete comments, not referenced code) ->
         <option>-dontshrink</option>
         <! - Not optimization (change code implementation logic) ->
         <option>-dontoptimize</option>
         <! - Do not pass the non-public class files and members ->
         <option>-dontskipnonpubliclibraryclasses</option>
         <option>-dontskipnonpubliclibraryclassmembers</option>
         <! - No casement of hybrid class mechanism ->
         <option>-dontusemixedcaseclassnames</option> 
         <! - Allow access to and modify the members of the modifier and class members ->
         <option>-allowaccessmodification</option>
         <! - Determine a unified confusing member name to increase confusion ->
         <option>-useuniqueclassmembernames</option>
         <! - Not confused all the package name ->
         <!--<option>-keeppackagenames</option>--> 
         <! - Requires the properties: unusual, annotation, etc. ->
         <option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod</option>
         <! - Uncommixed SET / GET Method ->
         <!--<option>-keepclassmembers public class * {void set*(***);*** get*();}</option>--> 
         <! - Unconducted all kinds of names under the package, and the method in the class is not confusing ->
         <option>-keep class com.xxx.xxx.bboss.SystemConfig { <methods>; }</option>
         <option>-keep class com.xxx.xxx.framework.** { *; }</option>
         <option>-keep class com.xxx.xxx.xxx.controller.** { <methods>; }</option>
         <option>-keep class com.xxx.xxx.xxx.dao.** { <methods>; }</option>
         <option>-keep class com.xxx.xxx.xxx.exception { <methods>; }</option>
         <option>-keep class com.xxx.xxx.xxx.model.** { <methods>; }</option> 
      </options>
      <! - Class is confused after the JAR package output ->
      <outjar>classes-autotest.jar</outjar>
      <! - Add dependencies, here you can modify it, here you can test only a JRE Runtime package is available ->
      <libs>
         <lib>${java.home}/lib/rt.jar</lib>
      </libs>
      <! - What to load, only Classes succeed here, after all, you can't confuse the configuration file and JSP ->
      <injar>classes</injar>
      <! - Output Directory ->
      <outputDirectory>${project.build.directory}</outputDirectory>
   </configuration>
</plugin>

運行 MVN Clean Package -dskiptests

混淆結(jié)果如圖:

Classes-pg.jar 很混亂,包含了完整的項目結(jié)構。

ProGuard_map.txt 混淆內(nèi)容映射

ProGuard_seed.txt 參與混淆類

經(jīng)過混淆,反編譯代碼如下:

可以看出,部分包名已經(jīng)改為簡單的字母,不再具有業(yè)務意義,變量名也進行了修改,增加了讀取代碼。

運行服務,項目運行正常。

需要注意:

1.有時有時會配置包名或類名,所以需要更改一些相關的配置文件,所以在ProGuard中并不是隨機生成類名,而是先將相同的包按照原來的名字排序,混淆了類名是A .Class, B.Class, C.class .....

那么,當包中的類超過26個時,默認命名為A.Class、B.Class、C.Class,在某些操作系統(tǒng)下,會不區(qū)分case case case case,會導致錯誤(水平限制,沒有深入的紀律是相關的;因此

<! - 沒有混合類機制的案例 - >
  <option>-dontusemixedcaseclassnames</option>

配置極其關鍵,分別命名為aa.class、ab.class、ac.class,而不是原來的大寫類,而不是原來的大寫類名,避免出錯。

2.包部署問題。這個profile中打包的WAR中的classes文件還是正常的代碼。需要手動解壓,替換Classes-Pg.jar,在工程管理的情況下,可以在Jenkins中配置腳本,自動混淆Classes替換WAR包:

# Change the contents of the WAR package classes as confusing packages
cd /root/.jenkins/workspace/mytest_master/target
jar -xvf classes-pg.jar
rm -rf mytest
mkdir mytest
mv mytest.war mytest
cd mytest/
jar -xvf mytest.war
rm -rf WEB-INF/classes/com/
cd ../
cp -rf com mytest/WEB-INF/classes/
cd mytest
jar -cvfM0 mytest.war ./
mv mytest.war ../

這樣Jenkins就是混淆了WAR包,可以直接給客戶使用。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 欧美精品成人一区二区视频一 | 国产亚洲精品久久久久久小说 | 精品一区二区三区在线观看视频 | 狠狠色噜噜狠狠狠狠91 | 国产精品自在自线免费观看 | 欧美色黄毛片 | 亚洲精品中文字幕久久久久久 | 中文字幕久久久 | 中文字幕影院 | 国产99r视频精品免费观看 | 国产精品久久天天影视 | 青草久久网 | 国产成人综合久久亚洲精品 | 伊人久久影院 | 日日干夜夜操s8 | aaa级片 | 午夜 福利 | 99久久免费国产香蕉麻豆 | 奇米色影视 | 一级在线毛片 | 毛片站| 在线看福利影 | 成人免费视频日本 | 国产成人91高清精品免费 | 91福利在线看| 99999久久久久久亚洲 | 亚洲午夜一区二区三区 | 四虎影视永久免费观看网址 | 呦女www | 日韩女同视频 | 视频二区精品中文字幕 | 2021最新久久久视精品爱 | 亚洲欧美中文在线观看4 | 天天看天天干 | 亚洲欧洲精品国产区 | 99国产在线视频 | 日韩精品一区二区三区中文字幕 | 国内精品美女久久久久 | 九草在线免费观看 | 日本不卡在线视频 | 国产成人一区二区三区影院免费 |