前言
自从Java诞生以来,其字节码容易被反编译的问题就为程序员所诟病。由此也诞生了不少Java混淆工具和加壳软件。
Java应用的打包
- exe4j
- launch4j
- JSmooth: 已经过时了
- jpackage:JDK自带的打包工具
- Installer工具:Inno Setup、NSIS(https://sourceforge.net/projects/nsis/)
混淆器
下面是一些常见的开源的和商业的混淆工具:
- ProGuard is a popular open-source GPL-licenced bytecode optimizer and file shrinker for Java and Kotlin. It claims to make these applications up to 90% smaller and 20% faster. It also provides some minimal obfuscation by renaming classes, fields and methods. Android Studio uses ProGuard automatically. ProGuard,一款shrinker(压缩:检测和删除没有使用的类,字段,方法和属性), optimizer(优化:对字节码进行优化,并且移除无用指令), obfuscator(混淆:使用a,b,c等无意义的名称,对类,字段和方法进行重命名), and preverifier(审核:在Java平台上对处理后的代码进行预检)工具。缩短进程检测并删去未运用的类、字段、办法和特点。优化器 进程优化字节码并删去未运用的指令。混杂进程运用简短无意义的称号重命名剩余的类、字段和办法。最后的预验证进程将预验证信息增加到类中,这是 Java Micro Edition 和 Java 6 及更高版别所必需的。
- yGuard is another commonly used open-source obfuscator.
- ZKM(Zelix KlassMaster) is a full featured commercial Java obfuscator. It shrinks and obfuscates both code and string constants.
- Allatori is a commercial second generation Java obfuscator. 第二代Java混淆器。所谓第二代混淆器,不仅仅能进行字段混淆,还能实现流混淆。
- DashO Java and Android Obfuscator is a commercial second generation Java obfuscator. DashO-Pro是第三代的Java混淆器(obfuscator)、压缩机(compactor)、优化工具和水印工具(watermarker)。它能有效保护和防止Java程序被反编译和篡改,是Java代码保护的理想选择。DashO-Pro除了为Java代码提供领先的代码保护外,它还将应用程序的大小缩减到原文件的70%。如果您正在找寻为您的Java程序提供反编译保护、提高运行速度和减少程序体积的办法,那么我们推荐您使用DashO。DashO是一个Java和Android的混用程序,它提供企业级应用的加固和屏蔽,大大降低了知识产权盗窃、数据盗窃、盗版和篡改的风险。分层混淆,加密,水印,自动失效,反调试,反篡改,反仿真器,反挂钩,反根设备解决方案,为世界各地的应用程序提供保护。
- Stringer Java Obfuscation Toolkit is a commercial Java obfuscator supporting up to Java 13.
There is an easy-to-read introductory article with extra links on bytecode obfuscation on the OWASP Foundation’s website. Another good introductory article on obfuscation techniques is on the DashO website.
名称 | License | 地址 |
---|---|---|
yGuard | LGPL | http://www.yworks.com/products/yguard |
ProGuard | GPLv2 | https://www.guardsquare.com/en/proguard |
Facebook ProGuard分支 | GPLv2 | https://github.com/facebook/proguard |
DashO | Commercial | https://www.preemptive.com/products/dasho |
Allatori | Commercial | http://www.allatori.com |
Stringer | Commercial | https://jfxstore.com |
Java Antidecompiler | Commercial | http://www.bisguard.com/help/java/ |
Zelix KlassMaster | Commercial | http://www.zelix.com |
加壳
https://gitee.com/chejiangyi/jar-protect
采用Golang打包Java程序
Golang
binary-go就是其中一个合适的选择
go get -u github.com/samuelngs/binary-go
安装完之后,我们执行
binary -dir ./[静态文件位置] -out binary
就会产生出许多的go文件,默认它是以20M为一个进行分拆的。
package main
import (
_ "embed"
"fmt"
"os"
"os/exec"
)
//go:embed binary
var f []byte
func main() {
_ = os.WriteFile("foobar", f, 0755)
out, _ := exec.Command("./foobar").Output()
fmt.Printf("Output: %s\n", out)
}
cmd := exec.Command("java", "-jar", "Astro.jar", "1924 12 12 23 23 23 74.34 34.67")
fmt.Println(cmd.Start())
xjar
xjar的原理是将jar包加密,然后执行的时候再加密,而密钥存放在外部的go可执行文件中。加密和解密都是由java程序完成。
参考链接
- https://github.com/segator/jbinary
- go-jdk:Run JVM-based code in Go efficiently
- https://github.com/core-lib/xjar
- https://github.com/lqs1848/AllatoriCrack.git
- https://yworks.github.io/yGuard/