黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

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

Java代碼混淆的實現方法

更新時間:2022-12-28 13:15:24 來源:動力節點 瀏覽2416次

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

混淆結果如圖:

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

ProGuard_map.txt 混淆內容映射

ProGuard_seed.txt 參與混淆類

經過混淆,反編譯代碼如下:

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

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

需要注意:

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

那么,當包中的類超過26個時,默認命名為A.Class、B.Class、C.Class,在某些操作系統下,會不區分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麻豆最新在线人成免费观看 | 色天天综合网 | 日本网站在线 | 亚洲国产成人精品一区91 | 欧美亚洲91 | 免费观看视频成人国产 | 亚洲视频在线精品 | 国产99在线观看 | 在线免费观看亚洲 | 秋霞午夜一级理论片久久 | 2o2o天天看夜夜看狠狠看 | 亚洲七七久久精品中文国产 | 九九热香蕉视频 | 一区二区三区亚洲 | 久久亚洲免费视频 | 一区二区三区欧美在线 | 欧美色图欧美色图 | 日韩福利一区 | 黄色天堂网站 | 亚洲美女爱做色禁图无遮 | 国产在线精品一区二区三区 | 丝袜无内写真福利视频 | 在线欧美视频免费观看国产 | 色综合久久精品中文字幕 | 韩国日本三级在线播放 | 欧美一区日韩精品 | 国产高清第一页 | 日韩精品福利视频一区二区三区 |