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

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

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

更新時(shí)間:2022-12-28 13:15:24 來源:動力節(jié)點(diǎn) 瀏覽2576次

Proguard 是一個(gè)用純 Java 編寫的混淆工具,有兩種使用 JAR 客戶端的方法。可以將程序打包成JAR,然后用工具進(jìn)行混淆,或者導(dǎo)入PROGUARD插件進(jìn)行代碼混淆。在這種情況下,代碼對于普通的 JavaWeb 項(xiàng)目來說是混淆的。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>

運(yùn)行 MVN Clean Package -dskiptests

混淆結(jié)果如圖:

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

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

ProGuard_seed.txt 參與混淆類

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

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

運(yùn)行服務(wù),項(xiàng)目運(yùn)行正常。

需要注意:

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

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

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

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

2.包部署問題。這個(gè)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包,可以直接給客戶使用。

提交申請后,顧問老師會電話與您溝通安排學(xué)習(xí)

免費(fèi)課程推薦 >>
技術(shù)文檔推薦 >>
主站蜘蛛池模板: 亚洲欧美日韩国产综合高清 | 一级毛片免费 | 久久精品亚洲一区二区 | 国产成人精品一区二区三在线观看 | 精品视频在线观看免费 | 色播99| 国产成+人欧美+综合在线观看 | 精品久久香蕉国产线看观看亚洲 | 老司机午夜免费影院 | 涩涩免费播放观看在线视频 | 日本中文字幕在线看 | 欧美综合精品一区二区三区 | 乱在线伦视频免费 | 综合网在线视频 | 国产福利一区视频 | 国产精品福利资源在线 | 女人一级一级毛片 | 亚洲成人在线视频播放 | 国产成人久久精品麻豆二区 | 欧美大片在线观看成人 | 91亚洲精品国产第一区 | 97在线观看免费 | 国产女主播在线视频 | 亚洲精品国产综合一线久久 | 日本欧美另类 | 久久久久欧美精品观看 | 日韩三级久久 | dyav午夜片| 欧美精品专区第1页 | 欧美综合社区 | 成人私人影院在线版 | 亚洲天天做夜夜做天天欢 | www.四虎影院.con | 97影院九七理论片男女高清 | 毛片免费观看 | 国产精品福利尤物youwu | 亚洲欧美国产精品专区久久 | 一区在线播放 | 欧美性生活在线 | 手机在线看片国产日韩生活片 | 香蕉免费一级视频在线观看 |