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

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

Java代碼混淆的實現方法

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

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包,可以直接給客戶使用。

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

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 色播在线永久免费视频 | 天天操一操 | 中文字幕亚洲国产 | 偷偷要色偷偷 | www.天天操.com | 小雪婷的性欢日记h全文 | 国产亚洲精品国产福利在线观看 | 日韩一区二区中文字幕 | 国产欧美精品一区二区三区 | 亚洲综合影视 | 国产精品久久久久久久久鸭 | 国产精品免费视频网站 | bl高h肉边走边做 | 92国产福利午夜757小视频 | np饥渴放荡总受高hbl皇帝攻 | 午夜激情影视 | 欧美精品三级在线 | 天天干天天天天 | 欧美一区二区三区成人看不卡 | 青青草综合在线 | 波多野结中文字幕在线69视频 | 国产欧美日韩精品第二区 | 国产在线精品一区二区中文 | 日韩中文在线播放 | 天天色一色 | 韩国在线看| 免费黄色一级毛片 | 国产精品一区二区久久不卡 | 日日摸夜夜添夜夜添人人爽 | 日本黄色小说网站 | 成人免费xxx色视频 成人免费xxxxx在线视频 | 性生大片一级毛片免费观看 | 黄色一级毛片免费 | 欧美激情精品久久久久久大尺度 | 一个人看的www的视频免费 | 亚洲国产成人久久一区www | 欧美精品亚洲精品日韩 | 亚洲性片| 免费在线观看h片 | 狠狠色欧美亚洲狠狠色五 | 日韩二区 |