Allatori:代码混淆器的使用(Eclipse&IDEA)

1. 声明

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

下载demo版的:

2. 基本demo

1. 解压后并在lib中找到这个

2.创建一个maven项目

3.在项目目录下创建lib目录,将jar包复制进去,并导入依赖(idea一样,只是导入依赖的方式不一样,下文中会说明)

在这里插入图片描述


4.在项目目录下创建一个allatori文件夹和在这个文件夹下面创建一个allatori.xml

在这里插入图片描述


5.开始编写主要的混淆配置信息:allatori.xml,该文件需要修改的就是config-input-jar的in和out

<?xml version="1.0" encoding="UTF-8"?>
<config>
	<input>
	<!-- 这里的in表示需要混淆的jar(springboot打包后的jar),out表示输出混淆后的jar(混淆器修改springboot打包后的jar) -->
		<jar in="test.jar" out="test-output.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.最后编写pom.xml(打包后使用混淆器)

如果使用idea需要先添加allatori.jar的依赖

<dependency>
			<groupId>com.allatori</groupId>     <!-- 自定义即可 -->
			<artifactId>allatori</artifactId>    <!-- jar名称 -->
			<version>7.9</version>          <!-- 如果jar包未指定自定义即可-->
			<type>jar</type>
			<scope>system</scope>
			<systemPath>${project.basedir}/lib/allatori.jar</systemPath>    <!-- 使用jar所在的绝对路径 -->
		</dependency>

配置打包信息

<build>
        <plugins>
            <!-- springboot打包 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <fork>true</fork>
                </configuration>
            </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.开始打包和运行

用maven命令打包

打包完成之后在项目的target目录即可找到对应混淆的jar,名字就是在5中设置的out的名字

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值