Java 8. This finally settles down by leaves many fields still obfuscated.

This commit is contained in:
Adam
2015-10-19 21:14:21 -04:00
parent 19cd153e37
commit c2e1da7125
3 changed files with 71 additions and 39 deletions

View File

@@ -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]);

View File

@@ -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<Integer> 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;
}