I guess this is right?
This commit is contained in:
@@ -39,72 +39,76 @@ public class Deob
|
|||||||
|
|
||||||
ClassGroup group = loadJar(args[0]);
|
ClassGroup group = loadJar(args[0]);
|
||||||
|
|
||||||
// run(group, new RenameUnique());
|
run(group, new RenameUnique());
|
||||||
//
|
|
||||||
// // remove except RuntimeException
|
|
||||||
// run(group, new RuntimeExceptions());
|
|
||||||
//
|
|
||||||
// // remove unused methods
|
|
||||||
// run(group, new UnusedMethods());
|
|
||||||
//
|
|
||||||
// run(group, new UnreachedCode());
|
|
||||||
//
|
|
||||||
// // remove illegal state exceptions, frees up some parameters
|
|
||||||
// run(group, new IllegalStateExceptions());
|
|
||||||
//
|
|
||||||
// // remove constant logically dead parameters
|
|
||||||
// run(group, new ConstantParameter());
|
|
||||||
//
|
|
||||||
// // 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());
|
|
||||||
//
|
|
||||||
// run(group, new MethodInliner());
|
|
||||||
//
|
|
||||||
// // broken because rename was removed
|
|
||||||
// //run(group, new MethodMover());
|
|
||||||
//
|
|
||||||
// run(group, new FieldInliner());
|
|
||||||
//
|
|
||||||
// // XXX this is broken because when moving clinit around, some fields can depend on other fields
|
|
||||||
// // (like multianewarray)
|
|
||||||
// //new FieldMover().run(group);
|
|
||||||
//
|
|
||||||
// run(group, new UnusedClass());
|
|
||||||
|
|
||||||
ModArith mod = new ModArith();
|
// remove except RuntimeException
|
||||||
mod.run(group);
|
run(group, new RuntimeExceptions());
|
||||||
|
|
||||||
int last = -1, cur;
|
// remove unused methods
|
||||||
while ((cur = mod.runOnce()) > 0)
|
run(group, new UnusedMethods());
|
||||||
{
|
|
||||||
new MultiplicationDeobfuscator().run(group);
|
|
||||||
|
|
||||||
new MultiplyOneDeobfuscator().run(group);
|
run(group, new UnreachedCode());
|
||||||
|
|
||||||
new MultiplyZeroDeobfuscator().run(group);
|
// remove illegal state exceptions, frees up some parameters
|
||||||
|
run(group, new IllegalStateExceptions());
|
||||||
|
|
||||||
if (last == cur)
|
// remove constant logically dead parameters
|
||||||
{
|
run(group, new ConstantParameter());
|
||||||
System.out.println("break");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
last = cur;
|
// remove unhit blocks
|
||||||
//break;
|
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());
|
||||||
|
|
||||||
|
run(group, new MethodInliner());
|
||||||
|
|
||||||
|
// broken because rename was removed
|
||||||
|
//run(group, new MethodMover());
|
||||||
|
|
||||||
|
run(group, new FieldInliner());
|
||||||
|
|
||||||
|
// XXX this is broken because when moving clinit around, some fields can depend on other fields
|
||||||
|
// (like multianewarray)
|
||||||
|
//new FieldMover().run(group);
|
||||||
|
|
||||||
|
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;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// eval constant fields (only set once to a constant in ctor) maybe just inline them
|
||||||
|
|
||||||
|
// make fields private
|
||||||
|
|
||||||
saveJar(group, args[1]);
|
saveJar(group, args[1]);
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public abstract class Instruction
|
|||||||
public boolean removeStack()
|
public boolean removeStack()
|
||||||
{
|
{
|
||||||
block = null;
|
block = null;
|
||||||
|
assert instructions != null;
|
||||||
|
|
||||||
// update instructions which jump here to jump to the next instruction
|
// update instructions which jump here to jump to the next instruction
|
||||||
List<Instruction> ins = instructions.getInstructions();
|
List<Instruction> ins = instructions.getInstructions();
|
||||||
|
|||||||
@@ -449,6 +449,9 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
Instruction ins = ctx.getInstruction();
|
Instruction ins = ctx.getInstruction();
|
||||||
boolean branch = op.branch; // branch that is always taken
|
boolean branch = op.branch; // branch that is always taken
|
||||||
|
|
||||||
|
if (ins.getInstructions() == null)
|
||||||
|
continue; // ins already removed?
|
||||||
|
|
||||||
Instructions instructions = ins.getInstructions();
|
Instructions instructions = ins.getInstructions();
|
||||||
instructions.buildJumpGraph();
|
instructions.buildJumpGraph();
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class IllegalStateExceptions implements Deobfuscator
|
|||||||
|
|
||||||
// remove stack of if.
|
// remove stack of if.
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
outer:
|
||||||
for (Frame f : execution.processedFrames)
|
for (Frame f : execution.processedFrames)
|
||||||
if (f.getMethod() == m)
|
if (f.getMethod() == m)
|
||||||
{
|
{
|
||||||
@@ -75,6 +76,7 @@ public class IllegalStateExceptions implements Deobfuscator
|
|||||||
if (ins instanceof If)
|
if (ins instanceof If)
|
||||||
ic.removeStack(1);
|
ic.removeStack(1);
|
||||||
ic.removeStack(0);
|
ic.removeStack(0);
|
||||||
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
@@ -128,6 +130,7 @@ public class IllegalStateExceptions implements Deobfuscator
|
|||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
{
|
{
|
||||||
group.buildClassGraph();
|
group.buildClassGraph();
|
||||||
|
|
||||||
Execution execution = new Execution(group);
|
Execution execution = new Execution(group);
|
||||||
execution.populateInitialMethods();
|
execution.populateInitialMethods();
|
||||||
execution.run();
|
execution.run();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import net.runelite.deob.execution.StackContext;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
@@ -117,6 +118,11 @@ public class UnusedParameters implements Deobfuscator
|
|||||||
if (!ins.getInvokes().isEmpty() && methods.containsAll(ins.getInvokes()))
|
if (!ins.getInvokes().isEmpty() && methods.containsAll(ins.getInvokes()))
|
||||||
{
|
{
|
||||||
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter
|
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter
|
||||||
|
|
||||||
|
StackContext sctx = ins.getPops().get(pops);
|
||||||
|
if (sctx.getPushed().getInstruction().getInstructions() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
ins.removeStack(pops); // remove parameter from stack
|
ins.removeStack(pops); // remove parameter from stack
|
||||||
|
|
||||||
if (done.contains(ins.getInstruction()))
|
if (done.contains(ins.getInstruction()))
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public class Execution
|
|||||||
|
|
||||||
public void populateInitialMethods()
|
public void populateInitialMethods()
|
||||||
{
|
{
|
||||||
|
group.buildClassGraph(); // required when looking up methods
|
||||||
|
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
{
|
{
|
||||||
for (Method m : cf.getMethods().getMethods())
|
for (Method m : cf.getMethods().getMethods())
|
||||||
|
|||||||
Reference in New Issue
Block a user