From c2e1da7125e4f71bc14a3cbbb3d2cd1dac2e6181 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 19 Oct 2015 21:14:21 -0400 Subject: [PATCH] Java 8. This finally settles down by leaves many fields still obfuscated. --- pom.xml | 4 +- src/main/java/net/runelite/deob/Deob.java | 71 ++++++++++--------- .../deobfuscators/arithmetic/ModArith.java | 35 ++++++++- 3 files changed, 71 insertions(+), 39 deletions(-) diff --git a/pom.xml b/pom.xml index 37d2b7d668..85ee2ae471 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ - 1.7 - 1.7 + 1.8 + 1.8 \ No newline at end of file diff --git a/src/main/java/net/runelite/deob/Deob.java b/src/main/java/net/runelite/deob/Deob.java index 3c1c14ca3d..9449813a8f 100644 --- a/src/main/java/net/runelite/deob/Deob.java +++ b/src/main/java/net/runelite/deob/Deob.java @@ -54,25 +54,26 @@ public class Deob // // // remove constant logically dead parameters // run(group, new ConstantParameter()); - - // remove unhit blocks +// +// // remove unhit blocks // run(group, new UnreachedCode()); // run(group, new UnusedMethods()); - - // remove unused parameters - run(group, new UnusedParameters()); - - // remove jump obfuscation - //new Jumps().run(group); - - // remove unused fields - //run(group, new UnusedFields()); - - // remove unused methods, again? - //run(group, new UnusedMethods()); +// +// // remove unused parameters +// run(group, new UnusedParameters()); +// +// // remove jump obfuscation +// //new Jumps().run(group); +// +// // remove unused fields +// run(group, new UnusedFields()); +// +// // remove unused methods, again? +// run(group, new UnusedMethods()); // // run(group, new MethodInliner()); // +// // broken because rename was removed // //run(group, new MethodMover()); // // run(group, new FieldInliner()); @@ -83,27 +84,27 @@ public class Deob // // run(group, new UnusedClass()); -// ModArith mod = new ModArith(); -// mod.run(group); -// -// int last = -1, cur; -// while ((cur = mod.runOnce()) > 0) -// { -// new MultiplicationDeobfuscator().run(group); -// -// new MultiplyOneDeobfuscator().run(group); -// -// new MultiplyZeroDeobfuscator().run(group); -// -// if (last == cur) -// { -// System.out.println("break"); -// break; -// } -// -// last = cur; -// //break; -// } + ModArith mod = new ModArith(); + mod.run(group); + + int last = -1, cur; + while ((cur = mod.runOnce()) > 0) + { + new MultiplicationDeobfuscator().run(group); + + new MultiplyOneDeobfuscator().run(group); + + new MultiplyZeroDeobfuscator().run(group); + + if (last == cur) + { + System.out.println("break"); + break; + } + + last = cur; + break; + } saveJar(group, args[1]); diff --git a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java index 7be0b2f06a..73533058fb 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import net.runelite.deob.ClassFile; import net.runelite.deob.ClassGroup; import net.runelite.deob.Deobfuscator; @@ -17,6 +18,7 @@ import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.instruction.types.FieldInstruction; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; +import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction; import net.runelite.deob.attributes.code.instructions.IMul; @@ -88,6 +90,7 @@ public class ModArith implements Deobfuscator } // find big constant + boolean big = false; for (InstructionContext i : ins) { if (i.getInstruction() instanceof LDC_W) @@ -98,10 +101,25 @@ public class ModArith implements Deobfuscator int value = ldc.getConstantAsInt(); if (DMath.isBig(value)) - return true; + big = true; } } } + +// for (InstructionContext i : ins) +// { +// if (i.getInstruction() instanceof InvokeInstruction) +// { +// if (!big) +// { +// // if no ob is detected and its passed to an invoke, it must be deobbed +// return false; +// } +// } +// } + + if (big) + return true; } return false; @@ -367,7 +385,20 @@ public class ModArith implements Deobfuscator Collection getters = constantGetters.getCollection(f), setters = constantSetters.getCollection(f); - if (f.getName().equals("field2976")) + if (getters != null) + { + getters = getters.stream().filter(c -> DMath.isBig(c)).collect(Collectors.toList()); + if (getters.isEmpty()) + getters = null; + } + if (setters != null) + { + setters = setters.stream().filter(c -> DMath.isBig(c)).collect(Collectors.toList()); + if (setters.isEmpty()) + setters = null; + } + + if (f.getName().equals("field347")) { int k=5; }