From 2dc38e45d8a3db9b1621de8998c970035d3d70e4 Mon Sep 17 00:00:00 2001 From: scrash Date: Sat, 21 Sep 2024 01:24:43 +0200 Subject: [PATCH 1/2] fix JSR inlining --- .../other/impl/clean/peephole/JsrInlinerTransformer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/impl/clean/peephole/JsrInlinerTransformer.java b/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/impl/clean/peephole/JsrInlinerTransformer.java index 2350c64..f9015b6 100644 --- a/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/impl/clean/peephole/JsrInlinerTransformer.java +++ b/deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/impl/clean/peephole/JsrInlinerTransformer.java @@ -22,14 +22,17 @@ protected void transform(ClassWrapper scope, Context context) throws Exception { if (isJsr) { // Inline JSR instructions - methodNode.accept(new JSRInlinerAdapter( + final JSRInlinerAdapter adapter = new JSRInlinerAdapter( methodNode, methodNode.access, methodNode.name, methodNode.desc, methodNode.signature, methodNode.exceptions.toArray(new String[0]) - )); + ); + + methodNode.accept(adapter); + classWrapper.methods().set(i, adapter); markChange(); } From 95208f1561be07911ffd7ef200ab98cfeeb89337 Mon Sep 17 00:00:00 2001 From: scrash Date: Sat, 21 Sep 2024 02:22:59 +0200 Subject: [PATCH 2/2] add test for JSR inlining --- .../narumi/deobfuscator/TestDeobfuscation.java | 4 ++++ testData/compiled/custom-classes/JSR.class | Bin 0 -> 368 bytes testData/results/custom-classes/JSR.dec | 13 +++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 testData/compiled/custom-classes/JSR.class create mode 100644 testData/results/custom-classes/JSR.dec 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 1831c00..42184dc 100644 --- a/deobfuscator-impl/src/test/java/uwu/narumi/deobfuscator/TestDeobfuscation.java +++ b/deobfuscator-impl/src/test/java/uwu/narumi/deobfuscator/TestDeobfuscation.java @@ -3,6 +3,7 @@ import uwu.narumi.deobfuscator.core.other.composed.ComposedZelixTransformer; import uwu.narumi.deobfuscator.core.other.composed.general.ComposedGeneralFlowTransformer; import uwu.narumi.deobfuscator.core.other.impl.clean.PeepholeCleanTransformer; +import uwu.narumi.deobfuscator.core.other.impl.clean.peephole.JsrInlinerTransformer; import uwu.narumi.deobfuscator.core.other.impl.pool.InlineLocalVariablesTransformer; import uwu.narumi.deobfuscator.core.other.impl.pool.InlineStaticFieldTransformer; import uwu.narumi.deobfuscator.core.other.impl.universal.UniversalNumberTransformer; @@ -29,6 +30,9 @@ protected void registerAll() { // Test sandbox security (e.g. not allowing dangerous calls) register("Sandbox security", InputType.JAVA_CODE, List.of(TestSandboxSecurityTransformer::new), Source.of("sandbox/TestSandboxSecurity", false)); + // JSR Inlining + register("JSR Inlining", InputType.CUSTOM_CLASS, List.of(JsrInlinerTransformer::new), Source.of("JSR")); + // Samples register("Some flow obf sample", InputType.CUSTOM_CLASS, List.of(ComposedGeneralFlowTransformer::new), Source.of("FlowObfSample")); diff --git a/testData/compiled/custom-classes/JSR.class b/testData/compiled/custom-classes/JSR.class new file mode 100644 index 0000000000000000000000000000000000000000..e4058002b7b6372bd70b69186809a2f01fd4ddac GIT binary patch literal 368 zcmZvY%}T>S6h_Y^)k$L1nwVODK-|@Cf@_zqltRUd8&^?7Nof+X(}HiL%eoM8;RE?cx)bb=N6phwxXOK*ic$gIZxM!ZSqJMgP zBlENJA$1Aa_OJ=0VbYONG+T2%E8|OnjjW_eE-N1EY-qN8HmNK0<7_$