Allatori:代码混淆器的使用

1. 声明

当前内容主要为学习和使用Allatori这个代码混淆器的使用,主要为了混淆java代码

下载demo版的:官方版本

2. 基本demo

1. 解压后并在lib中找到这个
在这里插入图片描述

2.创建一个maven项目(本人使用eclipse)

3.将需要的jar导入到项目中的lib文件中
在这里插入图片描述
4.创建一个allatori文件夹和在这个文件夹下面创建一个allatori.xml
在这里插入图片描述
5.开始编写主要的混淆配置信息:allatori.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
	<input>
	<!-- 这里的in表示需要混淆的jar(springboot打包后的jar),out表示输出混淆后的jar(混淆器修改springboot打包后的jar) -->
		<jar in="Allatori-Code-Mixed-0.0.1-SNAPSHOT.jar" out="Allatori-Code-Mixed-0.0.1-SNAPSHOT-obfuscated.jar" />
	</input>
	<keep-names>
		<class access="protected+">
			<field access="protected+" />
			<method access="protected+" />
		</class>
	</keep-names>
	<!-- 	忽略springBoot的启动项(防止启动报错)	 -->
	<ignore-classes>
		<class template="class *springframework*" />
	</ignore-classes>
	<property name="log-file" value="log.xml" />
	<!--	添加水印密匙,主要用来保护版权	 -->
	 <!-- <watermark key="secure-key-to-extract-watermark" value="Customer: John Smith; Date: xx.yy.zzzz"/> -->
	 <!-- 	配置过期时间	 -->
	 <!-- <expiry date="2000/01/01" string="EXPIRED!"/> -->
</config>

6.创建入口main方法

package com.hy.test;

/**
 * 
 * @author hy
 * @createTime 2021-06-19 15:53:37
 * @description 当前内容主要为测试和使用代码混淆器
 *
 */
public class MixTest {
	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			System.out.println("当前的数值为:" + (i + 1));
		}
	}
}

7.最后编写pom.xml(打包后使用混淆器)

<groupId>Allatori-Code-Mixed</groupId>
	<artifactId>Allatori-Code-Mixed</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>Allatori-Code-Mixed</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.18.RELEASE</version>
	</parent>


	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<mainClass>com.hy.test.MixTest</mainClass>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!-- 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>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>
						<argument>${basedir}/lib/allatori.jar</argument>
						<argument>${basedir}/target/allatori.xml</argument>
					</arguments>
				</configuration>
			</plugin>
			<!-- Allatori plugin end -->
		</plugins>
	</build>

此时项目构建完毕

3.开始打包和运行

在这里插入图片描述
在这里插入图片描述
执行顺序:springboot打包–>allatori混淆打包

执行:java -jar XXX.jar
在这里插入图片描述

唯一缺点,有水印,代码混淆后根本不能看,这说明开源项目给源码是多么友好的事情,其他的一般都是代码混淆了的

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值