Allatori代码混淆

Allatori代码混淆

*在项目(模块)中添加代码混淆,采用allatori官网提供的allatori.jar,本案例采用SpringBoot搭建,maven私服搭建引入allatori依赖

一、采用pom方式引入

1、pom.xml中引入依赖

在dependencies标签中添加

<!-- 私服allatori -->
<dependency>
    <groupId>com.cs.allatori</groupId>
    <artifactId>allatori</artifactId>
    <version>1.0</version>
    <scope>provided</scope>
</dependency>

在plugins标签中添加

<!-- Allatori plugin start -->
<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>
			<!-- allatori混淆的jar文件目录 -->
			<argument>${settings.localRepository}/cs/xxx/xxxx/allatori/allatori/1.0/allatori-1.0.jar</argument>
			<!-- allatori混淆的配置文件-->
			<argument>${basedir}/src/main/resources/allatori.xml</argument>
		</arguments>
	</configuration>
</plugin>
<!-- Allatori plugin end -->

二、直接引入allatori.jar方式

TODO

三、添加代码混淆配置文件allatori.xml

官配详细配置
项目的resources目录中添加allatori.xml配置文件,写入以下配置,按自己的项目做配置调整

<config>
    <!-- cs-xxxxxx-compile 原编译的jar文件,cs-xxxxxx 混淆后的输出的jar文件 -->
    <input>
        <jar in="../../../target/cs-xxxxxx-compile.jar" out="../../../target/cs-xxxxxx.jar"/>
    </input>
    <!-- 不替换类名、方法名、属性名 -->
    <keep-names>
        <class access="protected+">
            <field access="private+"/>
            <method access="protected+"/>
        </class>
    </keep-names>
    <!-- 接口形参名保持不变 -->
    <property name="local-variables-naming" value="keep-parameters"/>
    <!-- 排除(不做代码混淆)-->
    <ignore-classes>
        <!-- 排除指定路径 -->
        <class template="class com.cs.biz.pojo.*"/>
        <class template="class  com.cs.biz.vo.*"/>
        <class template="class  com.cs.biz.config.*"/>
        <class template="class  com.cs.biz.mapper.*"/>
		<!-- 排除启动类 -->
        <class template="class  com.cs.biz.xxxxxxBootstrap"/>
        <!-- 排除springboot依赖文件(springboot构建的项目需要排除,否则业务程序会报错) -->
        <class template ="class  org.springframework.boot.*"/>
    </ignore-classes>
    <!-- 广泛流混淆 最大级别混淆-->
    <property name="extensive-flow-obfuscation" value="maximum" apply2class="class com.cs.biz.*"/>
    <property name="extensive-flow-obfuscation" value="maximum" apply2class="class com.cs.rest.*"/>
    <!-- 其他路径正常混淆 -->
    <property name="extensive-flow-obfuscation" value="normal"/>
    <!-- 到期时间(到期后无法启动jar) 格式:yyyy/mm/dd-->
    <expiry date="2019/09/09" string="EXPIRED!"/>
    <!-- 随机命名混淆字符-->
    <property name="random-seed" value="cshxzf jrncbd hh"/>
</config>
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值