Java字节码混淆-利用Obfuscator进行混淆加密
Obfuscator是什么?
Obfuscator 是一个专门为Java字节码混淆的开源工具,本工具是一款专为Java字节码保护设计的开源混淆解决方案,支持以下核心混淆技术:
一、代码结构混淆
1.控制流混淆(Flow Obfuscation) 通过重构条件分支与循环结构,生成非线性的执行路径,显著增加逆向工程难度
2.行号信息清除(Line Number Removal) 彻底删除调试信息中的行号标记,阻断基于堆栈追踪的代码定位能力
二、数据混淆体系
1. 数值混淆(Number Obfuscation)对常量数值进行动态计算与加密存储,运行时还原真实值
2. 字符串加密(String Encryption)采用AES-256等算法对硬编码字符串进行分层加密,提供运行时动态解密机制
三、符号混淆模块
1. 命名混淆([实验阶段] Name Obfuscation)支持类/方法/字段的三级重命名,提供自定义混淆词典功能,可生成符合特定行业规范的混淆名称
2. 成员随机化与隐藏(Member Shuffling & Hiding)通过随机排列类成员顺序,结合访问权限重构实现代码隐藏
四、反制防护技术
1. 反混淆器崩溃防护(Deobfuscator Crasher)植入特殊字节码结构,致使主流反编译工具(JAD、FernFlower等)发生解析异常
2. 引用代理(Reference Proxy)创建多层方法调用代理链,阻断API调用关系的静态分析
五、高级保护功能
1. 内部类消除(Inner Class Removal)解构嵌套类结构并重构为独立类,破坏代码组织结构
2. 硬件指纹锁定(HWID Locking)集成物理设备指纹绑定机制,支持CPU序列号/MAC地址等多维度硬件认证
3. 动态调用混淆(Invoke Dynamic)利用Java7+的invokedynamic指令实现动态方法绑定,干扰反编译结果的可读性直接看看基本效果吧 (加密前后对比如下)
//加密前
public class HelloWorld {
public HelloWorld() {
super();
}
public static void main(final String[] args) {
System.out.println("Hello World");
for (int i = 0; i < 10; ++i) {
System.out.println(i);
}
}
}
//加密后
public class HelloWorld {
public static void main(final String[] array) {
// invokedynamic(1:(Ljava/io/PrintStream;Ljava/lang/String;)V, invokedynamic(0:()Ljava/io/PrintStream;), HelloWorld.llII[HelloWorld.lllI[0]])
float lllllllIlIllIII = HelloWorld.lllI[0];
while (llIll((int)lllllllIlIllIII, HelloWorld.lllI[1])) {
// invokedynamic(2:(Ljava/io/PrintStream;I)V, invokedynamic(0:()Ljava/io/PrintStream;), lllllllIlIllIII)
++lllllllIlIllIII;
"".length();
if (" ".length() == (" ".length() << (" ".length() << " ".length()) & ~(" ".length() << (" ".length() << " ".length())))) {
throw null;
}
}
}
}
Obfuscator下载
github:点我跳转
下载地址:点我跳转
百度云:点我跳转(5.47M)
提取码:
此处内容已隐藏,评论后刷新即可查看!
使用教程
下载后有两种方式运行
1.直接双击运行jar 打开GUI界面
根据需求勾选然后点击底部的Obfuscate按钮 进行加密处理
2.利用命令行的形式进行混淆加密 可以参考如下规则
--help Prints the help page on the screen--version Shows the version of the obfuscator--jarIn <input> Input JAR--jarOut <output> Output JAR--config <configFile> Config File--cp <classPath> Class Path--scriptFile <scriptFile> A JS file to script certain parts of the obfuscation--threads Sets the number of threads the obfuscator should use--verbose Sets logging to verbose mode
-- 示例命令
java -jar obfuscator.jar --jarIn helloWorld.jar --jarOut helloWorld-obf.jar
java -jar obfuscator.jar --jarIn helloWorld.jar --jarOut helloWorld-obf.jar --config obfConfig
配置文件可以不写 可参考如下配置文件
{
"input": "D:\\Computing\\HelloWorld\\out\\artifacts\\HelloWorld_jar\\HelloWorld.jar",
"output": "D:\\Computing\\HelloWorld\\out\\artifacts\\HelloWorld_jar\\HelloWorld-obf.jar",
"script": "function isRemappingEnabledForClass(node) {\n return true;\n}\nfunction isObfuscatorEnabledForClass(node) {\n return true;\n}",
"libraries": [
"C:\\Program Files\\Java\\jre1.8.0_211\\lib",
"D:\\Computing\\backdoored_old\\dependencies",
"D:\\Computing\\backdoored\\libs"
],
"Crasher": {
"Enabled": false,
"Invalid Signatures": true,
"Empty annotation spam": true
},
"InvokeDynamic": {
"Enabled": true
},
"HWIDPRotection": {
"Enabled": false,
"HWID": ""
},
"Optimizer": {
"Enabled": true,
"Replace String.equals()": true,
"Replace String.equalsIgnoreCase()": true,
"Optimize static string calls": true
},
"LineNumberRemover": {
"Enabled": true,
"Rename local variables": true,
"Remove Line Numbers": true,
"Remove Debug Names": true,
"Add Local Variables": true,
"New SourceFile Name": ""
},
"StringEncryption": {
"Enabled": true,
"HideStrings": true,
"AES": true
},
"NumberObfuscation": {
"Enabled": true,
"Extract to Array": true,
"Obfuscate Zero": true,
"Shift": false,
"And": false,
"Multiple Instructions": true
},
"ReferenceProxy": {
"Enabled": false
},
"ShuffleMembers": {
"Enabled": true
},
"InnerClassRemover": {
"Enabled": true,
"Remap": true,
"Remove Metadata": true
},
"NameObfuscation": {
"Enabled": true,
"Excluded classes": "HelloWorld",
"Excluded methods": "",
"Excluded fields": ""
},
"General Settings": {
"Custom dictionary": true,
"Name dictionary": "hello,world"
},
"Packager": {
"Enabled": false,
"Use MainClass from the JAR manifest": true,
"Main class": "HelloWorld"
},
"FlowObfuscator": {
"Enabled": true,
"Mangle Comparisons": true,
"Replace GOTO": true,
"Replace If": true,
"Bad POP": true,
"Bad Concat": true,
"Mangle Switches": false,
"Mangle Return": false,
"Mangle Local Variables": false
},
"HideMembers": {
"Enabled": true
},
"Inlining": {
"Enabled": false
}
}
感谢您能看到这里~ 希望本篇文章对您的开发有所帮助~
by gityyge
发表评论