代码混淆工具-Allatori-8.1使用

在工作中,我们写的代码需要开源和需要给团队中的人使用,为了防止代码被轻松反编译,可以通过混淆工具,降低代码的可读性。


前言

本文主要讲解allatori在Java maven工程中的使用方法。


一、Allatori介绍

官方地址: http://www.allatori.com

  • Allatori 是第二代 Java 混淆器,可为您的知识产权提供全方位的保护。

  • 尽管大多数第二代混淆器都提供了有价值的保护,但在 Allatori 中开发了许多附加功能,以使逆向工程代码几乎是不可能的。

  • Allatori 不只是混淆,它还最小化了应用程序的大小,并提高了速度。Allatori,作为每个现代 Java 混淆器,具有完整的水印功能,允许软件获得适当的许可。

二、使用步骤

1.引入jar和配置文件

从官网上下载最新的jar,在工程中创建文件夹lib和allatori。

在这里插入图片描述

2.配置allatori文件

allatori.xml内容如下:

<config>
    <input>
        <!--in表示需要混淆的jar包, out表示混淆后的jar包, 名称相同时会覆盖原来的jar包-->
<!--        <jar in="test.jar" out="obf-test.jar"/>-->
        <jar in="common-util.jar" out="allatori_common-util.jar"/>

    </input>

    <keep-names>
        <class template="class * instanceof java.io.Serializable"/>
        <!--设置混淆级别,protected+ 表示访问权限在protected(包含)之上的名称不会被混淆-->
        <class access="protected+">
            <field access="protected+"/>
            <method access="protected+"/>
        </class>
    </keep-names>

    <!--用于排除某些不需要混淆的类-->
    <ignore-classes>
        <!--    以com.code1开头的类不进行混淆    -->
<!--        <class template="class regex:^(?!com.code1).*"/>-->
<!--        <class template="class org.springframework.*"/>-->
    </ignore-classes>

    <!--名称混淆方式-->
<!--    <property name="classes-naming" value="iii"/>-->
<!--    <property name="methods-naming" value="iii"/>-->
    <property name="fields-naming" value="abc"/>
    <property name="line-numbers" value="keep"/>
    <property name="log-file" value="log.xml"/>

    <!-- 用于为混淆的应用程序设置类路径-->
    <!--<classpath basedir="../lib">-->
    <!-- Adding library.jar to the classpath -->
    <!-- Adding all jars in the lib directory to the classpath -->
    <!--<jar name="*.jar"/>-->
    <!-- Adding all jars in the lib2 directory and its subdirectories to the classpath -->
    <!--</classpath>-->

</config>

标签说明文档:https://allatori.com/doc.html

3.配置pom.xml

<build>
        <finalName>common-util</finalName>

        <plugins>
            <!-- Allatori plugin start -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <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>3.0.0</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>
                        <argument>${basedir}/lib/allatori.jar</argument>
                        <argument>${basedir}/target/allatori.xml</argument>
                    </arguments>
                </configuration>
            </plugin>

        </plugins>
    </build>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

blackoon88

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值