混淆工具之Allatori的使用

 

Allatori简介:

Allatori是一个Java 混淆器,它属于第二代混淆器,因此它能够全方位地保护你的知识产权。 Allatori具有以下几种保护方式:命名混淆,流混淆,调试信息混淆,字符串混淆,以及水印技术。对于教育和非商业项目来说这个混淆器是免费的。支持war和jar文件格式,并且允许对需要混淆代码的应用程序添加有效日期。官网地址:http://www.allatori.com

Allatori的使用:

官网(http://www.allatori.com)提供了多种混淆方式,如下图所示:

一、开发工具中集成

     A.idea集成:

       我们选择以maven的方式进行整合,笔者就以自己本次使用的war文件混淆为例:

  1. 我们将混淆的需要的配置抽离在一个文件夹中放入项目的根目录(也可以自己定义放在其他路径):

2.maven配置: 里面的路径要对应第一步文件存放的位置。(切记)

<build>
    <!--该配置是设置打出war的名称,也可以不加-->
    <finalName>/new</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <!--跳过测试,避免出现符号找不到等问题-->
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <id>copy-and-filter-allatori-config</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/allatori</directory>
                                <includes>
                                    <include>allatori.xml</include>
                                </includes>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>run-allatori</id>
                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>java</executable>
                <arguments>
                    <argument>-Xms128m</argument>
                    <argument>-Xmx512m</argument>
                    <argument>-jar</argument>
                    <!--该设置 “${basedir}/lib/allatori.jar“对应allatori提供的jar包路径-->
                    <argument>${basedir}/allatori/allatori.jar</argument>
                    <!--该设置 “${basedir}/target/allatori.xml“对应allatori.xml文件的路径-->
                    <argument>${basedir}/target/allatori.xml</argument>
                </arguments>
            </configuration>
        </plugin>
    </plugins>
    <!--如果是eclipse可不要此resources-->
    <resources>
        <resource>
            <directory>${basedir}src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>
</build>

 说明:<argument>${basedir}/target/allatori.xml</argument>,将allatori.xml打入target目录。

3.配置混淆配置allator.xml文件(重点)

混淆参数说明:

in:输入文件

out:输出文件

classpath:需要的环境lib目录

keep-names :保留配置项

class:标记不重名的类

field:标记指定不重名的字段

method:标记指定不重名的方法

其他参数详情见官网:http://www.allatori.com/doc.html

 

B.eclipse集成:

步骤2截图:

 

二、做成桌面工具(便于团队使用)

1.工具提炼:

2.工具目录说明

             a.lib 目录存放的是Allatori核心jar,在官网软件包lib目录下。

             b.ROOT目录,笔者自定义目录,存放未混淆的xxx.war包。

             c.config-jar(war),混淆的配置文件(见3配置说明),详情配置见官网:http://www.allatori.com/doc.html

             d.ReadMe.txt是笔者写的该工具的教程(见4使用步骤)。

             e.RunAllatori-jar(war).bat 执行命令。

      3.配置说明

config-war(jar参考官方教程)

<config>
    <input>
         <!--目标文件-->
        <jar in="ROOT/new.war" out="ROOT.war"/>
    </input>
	<!--必须配置-->
    <classpath>
        <jar name="ROOT/WEB-INF/lib/*.jar"/>
    </classpath>
    <keep-names>
        <class access="protected+">
            <field access="protected+"/>
            <method access="protected+"/>
        </class>
    </keep-names>
    <property name="log-file" value="log.xml"/>
	<!--参数名称不变-->
	<property name="local-variables-naming" value="keep-parameters"/>
</config>

 

      4.工具使用步骤

            a.将要混淆的xxx.war改名为new.war复制到ROOT目录,然后用解压工具解压到ROOT目录。

            b.然后点击RunAllatori-war.bat,等待混淆完成,完成在当前目录生成ROOT.war.

            c.混淆已完成,将ROOT.war部署在tomcat完成。

            d.其他混淆方式参考官网教程。

            e.Clean.bat,清除混淆生成的所有文件。(二次生成,推荐使用。)

结尾:Allatori是一块非开源的收费软件,非商业用途使用可以,若商用请购买授权。笔者觉得这款工具虽然强大,但是配置确很繁琐,还有美中不足就是收费,价格相对来说还算比较便宜,这也无可厚非,知识就是财富呀。

 

 

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值