zoukankan      html  css  js  c++  java
  • ant打包和jar包混淆

    Ant是一种基于Java的build工具。相似于c语言中的makefile,这里做一记录。方便后面查看。

    <?xml version="1.0" encoding="UTF-8"?>  
    <project name="vailidategame" default="yguard" basedir=".">  
        <property name="src" value="${basedir}/src" />  
        <property name="lib" value="${basedir}/lib" /> 
        <property name="build" value="${basedir}/build" />  
        <property name="build.class" value="${build}/classes" />
    	<property name="app.name" value="FrameWork" />  
        <property name="app.jar" value="${app.name}.jar" /> 
        <property name="obfuscationlog" value="${build}"/>
        <property name="obf.jar" value="${app.name}_obf.jar" />
        <property name="obfjarpath" value="${basedir}/lib"/>
        <property name="shrinklog" value="${project_name}_shrinklog.xml"/>
        <property name="renamelog" value="${project_name}_renamelog.xml"/>
        <!--请将以下的路径改为你本地的路径-->  
        <property name="webserver" value="D:uild-tomcatwebapps" /> 
          
        <!--定义CLASSPACH,编译时用到你外部增加的包-->  
       <!--  <path id="classpath">  
            <pathelement location="${src}" /> 
            <fileset dir="${lib}" includes="***.jar" />  
        </path> -->
        
        <!--删除任务-->  
        <target name="clean" description="删除">  
            <echo message="删除文件夹" />  
            <delete dir="${build}" />  
        </target>  
      
        <!--创建一个暂时文件夹-->  
        <target name="init" description="创建文件夹" depends="clean">  
            <echo message="创建文件夹--以运行" />  
            <mkdir dir="${build.class}" />  
        </target>  
      
        <!-- 编译 -->
        <target name="compile" description="開始编译" depends="init">
               <echo message="生成jar開始……" />  
        	   <javac srcdir="src" destdir="${build.class}">
    		    	 <!-- <classpath> 
    		             <fileset dir="lib"> 
    		                 <include name="**/*.jar"/> 
    		             </fileset>
    		         </classpath>  -->
    		   </javac>  
        </target>
        <!-- 打成jar包 -->
        <target name="generjar" description="打包" depends="compile">
             <echo message="打成jar包"/>
              <jar jarfile="${build}/${app.jar}" basedir="${build.class}">
    			<!-- <manifest>
    	   			<attribute name="Main-Class" value="bean.ant.TestAnt" />
    			</manifest> -->
    	   	  </jar>
        </target>
        
        <!-- 混淆任务 -->
       <!--  <target name="yguard" depends="generjar">
           <echo message="開始混淆"/>
           <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="yguard.jar" />
           <echo message="产生混淆文件"/>
           <yguard>
               <inoutpair in="${build}/${app.jar}" out="${build}/${obf.jar}"/>
           </yguard>
        </target> -->
       
        <target depends="generjar" name="yguard">
          <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask"
          classpath="yguard.jar"/>
          <!-- the following can be adjusted to your needs -->
          <yguard>
            <inoutpair in="${build}/${app.jar}" out="${build}/${obf.jar}"/>
            <shrink logfile="${shrinklog}">
              <keep>
                <class classes="protected"
                methods="protected" fields="protected">
                  <patternset>
                    <include name="com.subao.validate.**.*"/>
                    <!-- <exclude name="com.subao.validate.http.**.*"/> -->
                  </patternset>
                </class>
              </keep>
            </shrink>
            <rename logfile="${renamelog}">
              <property name="error-checking" value="pedantic"/>
              <keep>
                <class classes="protected"
                methods="protected" fields="protected">
                  <patternset>
                    <include name="com.subao.validate.**.*"/>
                    <!-- <exclude name="com.subao.validate.http.**.*"/> -->
                    <exclude name="com.subao.validate.entity.**.*"/>
                  </patternset>
                </class>
              </keep>
            </rename>
          </yguard>
        </target>
    </project>  
    大概解释一下:

    1、上面project标签中的default代表默认运行的入口, basedir代表基准路径。

    2、property标签定义变量。

    3、target标签中就各自是对应的操作。

    相关资源:

    yguard混淆:http://download.csdn.net/detail/lxq_xsyu/8149559

    jar包混淆工具:http://download.csdn.net/detail/lxq_xsyu/8149539

    jar包反编译工具:http://download.csdn.net/detail/lxq_xsyu/8149513
    这些工具用起来都特别简单,相关界面截图例如以下:





  • 相关阅读:
    【DWM1000】 code 解密2一 工程初始化代码分析
    【DWM1000】 code 解密1一 去掉Main 函数多余内容
    Integration between SharePoint 2013 and CRM 2013 (On-Premise)
    Windows Server2012R2 添加Microsoft .NET Framework 3.5 功能失败的解决方法
    Windows Server2012R2 安装 SharePoint 2013 的必备组件
    SSRS: How to Display Checkbox on Report
    ADFS部署过程中设置network service对证书的读取权限
    Dynamics CRM2013 ScLib::AccessCheckEx failed
    ADFS3.0 Customizing the AD FS Sign-in Pages
    Dynamics CRM2013 picklist下拉项行数控制
  • 原文地址:https://www.cnblogs.com/yxysuanfa/p/7043829.html
Copyright © 2011-2022 走看看