对Springboot的jar加密:防止反编译

记录如下……

 

 

XJar

对Springboot打包后的jar加密处理后,jd-gui已不能反编译成功

github地址:https://github.com/core-lib/xjar

 

1 pom


        
            com.github.core-lib
            xjar
            4.0.0
        

        
            org.apache.commons
            commons-compress
            1.20
        


    
        
            jitpack
            https://jitpack.io
        
    

2 通过main方法运行

    import io.xjar.XCryptos;

    public static void main(String[] args) throws Exception {
        produce();
    }

    public static void produce() throws Exception {
        XCryptos.encryption()
                // 项目生成的jar
                .from("D:\\projects\\test\\target\\test.jar")
                // 加密的密码
                .use("testaa1111122222")
                // 要加密的资源
                .include("/**/*.class")
                .include("/**/*.xml")
                .include("/**/*.yml")
                // 加密后的jar,此时:通过jd-gui反编译失败
                .to("D:\\temp\\test.jar");
    }

 

 

详细步骤说明:

1、对Springboot项目maven打包后生成的jar,以上述代码运行,可得到加密后的jar(此时加密的jar经jd-gui反编译报错)

2、生成加密jar的同时,目录下会生成xjar.go的GO启动器文件

3、对xjar.go编译(需要安装go环境,区分windows和linux),生成对应的go执行器。命令:

go build xjar.go

4、编译之后,得到执行器:

window:xjar.exe

linux:xjar

5、项目启动运行:

window:

xjar.exe java -jar test.jar

linux:

nohup ./xjar java -jar test.jar

6、此时jar通过xjar可正常运行

 

 

 

记录……

原文:https://blog.csdn.net/ChangeYoung1921/article/details/84621787

 

 

 

 

你可能感兴趣的:(Java服务端,java,反编译,Springboot)