[优化] 优化 AES KEY 提到全局变量并支持配置
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
更新日志:
|
||||
|
||||
- [BUG] 修复之前版本参数混淆功能实际没有生效
|
||||
- [优化] 优化 `AES KEY` 提到全局变量并支持配置
|
||||
- [优化] 配置文件支持关闭某些 `ASM` 选项提高兼容性
|
||||
|
||||
感谢以下用户的贡献:
|
||||
|
||||
@@ -192,6 +192,8 @@ enableAES: true
|
||||
aesKey: OBF_DEFAULT_KEYS
|
||||
# AES 解密方法名
|
||||
aesDecName: iiLLiLi
|
||||
# AES KEY 字段名
|
||||
aesKeyField: iiiLLLi1i
|
||||
|
||||
# 是否启用全局字符串提取混淆
|
||||
enableAdvanceString: true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.n1ar4.clazz.obfuscator.asm;
|
||||
|
||||
import me.n1ar4.clazz.obfuscator.Const;
|
||||
import me.n1ar4.clazz.obfuscator.core.ObfEnv;
|
||||
import me.n1ar4.clazz.obfuscator.utils.AESUtil;
|
||||
import me.n1ar4.templates.AESTemplates;
|
||||
import org.objectweb.asm.*;
|
||||
@@ -20,6 +21,14 @@ public class StringEncryptChanger extends ClassVisitor {
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
this.className = name;
|
||||
super.visit(version, access, name, signature, superName, interfaces);
|
||||
FieldVisitor fieldVisitor = this.cv.visitField(
|
||||
// private static final String [AES KEY] = "AES KEY";
|
||||
Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL,
|
||||
ObfEnv.config.getAesKeyField(),
|
||||
"Ljava/lang/String;",
|
||||
null,
|
||||
ObfEnv.config.getAesKey());
|
||||
fieldVisitor.visitEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,7 +170,8 @@ public class StringEncryptChanger extends ClassVisitor {
|
||||
if (value instanceof String) {
|
||||
try {
|
||||
mv.visitLdcInsn(AESTemplates.encrypt((String) value, this.aesKey));
|
||||
mv.visitLdcInsn(this.aesKey);
|
||||
mv.visitFieldInsn(Opcodes.GETSTATIC, className,
|
||||
ObfEnv.config.getAesKeyField(), "Ljava/lang/String;");
|
||||
mv.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
className,
|
||||
|
||||
@@ -28,6 +28,7 @@ public class BaseConfig {
|
||||
|
||||
private String aesKey;
|
||||
private String aesDecName;
|
||||
private String aesKeyField;
|
||||
private String[] obfuscateChars;
|
||||
private String[] methodBlackList;
|
||||
|
||||
@@ -44,6 +45,7 @@ public class BaseConfig {
|
||||
config.setEnableXOR(true);
|
||||
config.setEnableAES(true);
|
||||
config.setAesKey("OBF_DEFAULT_KEYS");
|
||||
config.setAesKeyField("iiiLLLi1i");
|
||||
config.setAesDecName("iiLLiLi");
|
||||
config.setEnableDeleteCompileInfo(true);
|
||||
config.setEnableParamName(true);
|
||||
@@ -86,6 +88,8 @@ public class BaseConfig {
|
||||
ColorUtil.green(String.valueOf(enableAES)));
|
||||
System.out.println(ColorUtil.yellow("AES Decrypt KEY-> ") +
|
||||
ColorUtil.green(String.valueOf(aesKey)));
|
||||
System.out.println(ColorUtil.yellow("AES KEY Field-> ") +
|
||||
ColorUtil.green(String.valueOf(aesKeyField)));
|
||||
System.out.println(ColorUtil.yellow("AES Decrypt Method-> ") +
|
||||
ColorUtil.green(String.valueOf(aesDecName)));
|
||||
System.out.println(ColorUtil.yellow("Enable Advance String Obfuscate -> ") +
|
||||
@@ -100,6 +104,14 @@ public class BaseConfig {
|
||||
ColorUtil.green(String.valueOf(maxJunkOneClass)));
|
||||
}
|
||||
|
||||
public String getAesKeyField() {
|
||||
return aesKeyField;
|
||||
}
|
||||
|
||||
public void setAesKeyField(String aesKeyField) {
|
||||
this.aesKeyField = aesKeyField;
|
||||
}
|
||||
|
||||
public boolean isAsmAutoCompute() {
|
||||
return asmAutoCompute;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public class Manager {
|
||||
// field / method 都不应该包含这个字符串
|
||||
NameUtil.exclude(config.getAdvanceStringName());
|
||||
NameUtil.exclude(config.getAesDecName());
|
||||
NameUtil.exclude(config.getAesKeyField());
|
||||
ObfEnv.ADVANCE_STRING_NAME = config.getAdvanceStringName();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -39,6 +39,8 @@ enableAES: true
|
||||
aesKey: OBF_DEFAULT_KEYS
|
||||
# AES 解密方法名
|
||||
aesDecName: iiLLiLi
|
||||
# AES KEY 字段名
|
||||
aesKeyField: iiiLLLi1i
|
||||
|
||||
# 是否启用全局字符串提取混淆
|
||||
enableAdvanceString: true
|
||||
|
||||
Reference in New Issue
Block a user