diff --git a/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/helper/AsmHelper.java b/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/helper/AsmHelper.java index 65e3b00..29fb9f1 100644 --- a/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/helper/AsmHelper.java +++ b/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/helper/AsmHelper.java @@ -124,6 +124,7 @@ public static Type getTypeFromPrimitiveCast(MethodInsnNode insn) { if (insn.owner.equals("java/lang/Long") && insn.name.equals("longValue")) return Type.LONG_TYPE; if (insn.owner.equals("java/lang/Double") && insn.name.equals("doubleValue")) return Type.DOUBLE_TYPE; if (insn.owner.equals("java/lang/Float") && insn.name.equals("floatValue")) return Type.FLOAT_TYPE; + if (insn.owner.equals("java/lang/Boolean") && insn.name.equals("booleanValue")) return Type.BOOLEAN_TYPE; throw new IllegalStateException("Unexpected value: " + insn.owner+"."+insn.name+insn.desc); } diff --git a/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/ComposedTransformer.java b/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/ComposedTransformer.java index ca840a4..9065541 100644 --- a/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/ComposedTransformer.java +++ b/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/ComposedTransformer.java @@ -3,15 +3,16 @@ import java.util.List; import java.util.function.Supplier; +import org.jetbrains.annotations.Nullable; import uwu.narumi.deobfuscator.api.asm.ClassWrapper; import uwu.narumi.deobfuscator.api.context.Context; public class ComposedTransformer extends Transformer { - private final List> transformers; + private final List> transformers; @SafeVarargs - public ComposedTransformer(Supplier... transformers) { + public ComposedTransformer(Supplier<@Nullable Transformer>... transformers) { this.transformers = List.of(transformers); } diff --git a/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/Transformer.java b/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/Transformer.java index 6cfe4dc..b7249c3 100644 --- a/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/Transformer.java +++ b/deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/transformer/Transformer.java @@ -72,17 +72,22 @@ public String name() { * @param context The context * @return If the transformation changed something */ - public static boolean transform(Supplier transformerSupplier, @Nullable ClassWrapper scope, Context context) { + public static boolean transform(Supplier<@Nullable Transformer> transformerSupplier, @Nullable ClassWrapper scope, Context context) { return transform(transformerSupplier, scope, context, false); } private static boolean transform( - Supplier transformerSupplier, + Supplier<@Nullable Transformer> transformerSupplier, @Nullable ClassWrapper scope, Context context, boolean reran ) { Transformer transformer = transformerSupplier.get(); + if (transformer == null) { + // Null means that transformer is disabled. Skip it + return false; + } + if (transformer.hasRan) { throw new IllegalArgumentException("transformerSupplier tried to reuse transformer instance. You must pass a new instance of transformer"); } diff --git a/deobfuscator-impl/src/test/java/uwu/narumi/deobfuscator/TestDeobfuscation.java b/deobfuscator-impl/src/test/java/uwu/narumi/deobfuscator/TestDeobfuscation.java index faf9013..4bb1cfe 100644 --- a/deobfuscator-impl/src/test/java/uwu/narumi/deobfuscator/TestDeobfuscation.java +++ b/deobfuscator-impl/src/test/java/uwu/narumi/deobfuscator/TestDeobfuscation.java @@ -39,7 +39,7 @@ protected void registerAll() { register("Some flow obf sample", InputType.CUSTOM_CLASS, List.of(ComposedGeneralFlowTransformer::new), Source.of("FlowObfSample")); // Zelix - register("Zelix (22.0.3) Sample 1", InputType.CUSTOM_CLASS, List.of(ComposedZelixTransformer::new), + register("Zelix (22.0.3) Sample 1", InputType.CUSTOM_CLASS, List.of(() -> new ComposedZelixTransformer(true)), Source.of("zkm/sample1/ExampleClass"), Source.of("zkm/sample1/ILongDecrypter", false), Source.of("zkm/sample1/LongDecrypter1", false), @@ -69,7 +69,7 @@ protected void registerAll() { */ register("Zelix (22.0.3) Sample 2 - Class initialization order", InputType.CUSTOM_CLASS, List.of( - () -> new ComposedZelixTransformer( + () -> new ComposedZelixTransformer(true, // During obfuscation was specified classInitializationOrder option, // so we need to also pass it here for correct decrypted values Map.of("a.a.a.a.a4", "a.a.a.a.bc") @@ -103,7 +103,7 @@ protected void registerAll() { obfuscateParameters=normal; */ register("Zelix (21) Snake Game", InputType.CUSTOM_JAR, - List.of(ComposedZelixTransformer::new), + List.of(() -> new ComposedZelixTransformer(true)), Source.of("SnakeGame-obf-zkm") ); diff --git a/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/composed/ComposedZelixTransformer.java b/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/composed/ComposedZelixTransformer.java index 0e04ac7..a4d56bb 100644 --- a/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/composed/ComposedZelixTransformer.java +++ b/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/composed/ComposedZelixTransformer.java @@ -18,10 +18,14 @@ */ public class ComposedZelixTransformer extends ComposedTransformer { public ComposedZelixTransformer() { - this(new HashMap<>()); + this(false); } - public ComposedZelixTransformer(Map classInitializationOrder) { + public ComposedZelixTransformer(boolean experimental) { + this(experimental, new HashMap<>()); + } + + public ComposedZelixTransformer(boolean experimental, Map classInitializationOrder) { super( // Initial cleanup JsrInlinerTransformer::new, @@ -31,7 +35,7 @@ public ComposedZelixTransformer(Map classInitializationOrder) { ZelixUselessTryCatchRemoverTransformer::new, // Decompose method parameters - ZelixParametersTransformer::new, + () -> experimental ? new ZelixParametersTransformer() : null, // Decrypt longs () -> new ZelixLongEncryptionMPCTransformer(classInitializationOrder),