appears to work
This commit is contained in:
@@ -45,19 +45,19 @@ public class Deob
|
|||||||
ClassGroup group = loadJar(args[0]);
|
ClassGroup group = loadJar(args[0]);
|
||||||
long bstart, bdur;
|
long bstart, bdur;
|
||||||
|
|
||||||
// bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
// new RenameUnique().run(group);
|
new RenameUnique().run(group);
|
||||||
// bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
// System.out.println("rename unique took " + bdur/1000L + " seconds");
|
System.out.println("rename unique took " + bdur/1000L + " seconds");
|
||||||
|
|
||||||
// // remove except RuntimeException
|
// remove except RuntimeException
|
||||||
// bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
// new RuntimeExceptions().run(group);
|
new RuntimeExceptions().run(group);
|
||||||
// // the blocks of runtime exceptions may contain interesting things like other obfuscations we identify later, but now that
|
// the blocks of runtime exceptions may contain interesting things like other obfuscations we identify later, but now that
|
||||||
// // it can't be reached by the execution phase, those things become confused. so remove blocks here.
|
// it can't be reached by the execution phase, those things become confused. so remove blocks here.
|
||||||
// new UnusedBlocks().run(group);
|
new UnusedBlocks().run(group);
|
||||||
// bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
// System.out.println("runtime exception took " + bdur/1000L + " seconds");
|
System.out.println("runtime exception took " + bdur/1000L + " seconds");
|
||||||
|
|
||||||
// remove unused methods
|
// remove unused methods
|
||||||
bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
@@ -65,35 +65,38 @@ public class Deob
|
|||||||
bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
System.out.println("unused methods took " + bdur/1000L + " seconds");
|
System.out.println("unused methods took " + bdur/1000L + " seconds");
|
||||||
|
|
||||||
// // remove illegal state exceptions, frees up some parameters
|
// remove illegal state exceptions, frees up some parameters
|
||||||
// bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
// new IllegalStateExceptions().run(group);
|
new IllegalStateExceptions().run(group);
|
||||||
// bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
// System.out.println("illegal state exception took " + bdur/1000L + " seconds");
|
System.out.println("illegal state exception took " + bdur/1000L + " seconds");
|
||||||
|
|
||||||
// remove constant logically dead parameters
|
// remove constant logically dead parameters
|
||||||
|
bstart = System.currentTimeMillis();
|
||||||
new ConstantParameter().run(group);
|
new ConstantParameter().run(group);
|
||||||
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
|
System.out.println("constant param took " + bdur/1000L + " seconds");
|
||||||
//
|
//
|
||||||
// // remove unhit blocks
|
// // remove unhit blocks
|
||||||
// bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
// new UnusedBlocks().run(group);
|
new UnusedBlocks().run(group);
|
||||||
// bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
// System.out.println("unused blocks took " + bdur/1000L + " seconds");
|
System.out.println("unused blocks took " + bdur/1000L + " seconds");
|
||||||
//
|
|
||||||
// // remove unused parameters
|
// remove unused parameters
|
||||||
// bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
// new UnusedParameters().run(group);
|
new UnusedParameters().run(group);
|
||||||
// bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
// System.out.println("unused blocks took " + bdur/1000L + " seconds");
|
System.out.println("unused blocks took " + bdur/1000L + " seconds");
|
||||||
|
|
||||||
// remove jump obfuscation
|
// remove jump obfuscation
|
||||||
//new Jumps().run(group);
|
//new Jumps().run(group);
|
||||||
|
|
||||||
// remove unused fields
|
// remove unused fields
|
||||||
// bstart = System.currentTimeMillis();
|
bstart = System.currentTimeMillis();
|
||||||
// new UnusedFields().run(group);
|
new UnusedFields().run(group);
|
||||||
// bdur = System.currentTimeMillis() - bstart;
|
bdur = System.currentTimeMillis() - bstart;
|
||||||
// System.out.println("unused fields took " + bdur/1000L + " seconds");
|
System.out.println("unused fields took " + bdur/1000L + " seconds");
|
||||||
|
|
||||||
//new ModularArithmeticDeobfuscation().run(group);
|
//new ModularArithmeticDeobfuscation().run(group);
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,18 @@ package info.sigterm.deob.attributes.code.instructions;
|
|||||||
import info.sigterm.deob.attributes.code.Instruction;
|
import info.sigterm.deob.attributes.code.Instruction;
|
||||||
import info.sigterm.deob.attributes.code.InstructionType;
|
import info.sigterm.deob.attributes.code.InstructionType;
|
||||||
import info.sigterm.deob.attributes.code.Instructions;
|
import info.sigterm.deob.attributes.code.Instructions;
|
||||||
|
import info.sigterm.deob.attributes.code.instruction.types.PushConstantInstruction;
|
||||||
import info.sigterm.deob.execution.Frame;
|
import info.sigterm.deob.execution.Frame;
|
||||||
import info.sigterm.deob.execution.InstructionContext;
|
import info.sigterm.deob.execution.InstructionContext;
|
||||||
import info.sigterm.deob.execution.Stack;
|
import info.sigterm.deob.execution.Stack;
|
||||||
import info.sigterm.deob.execution.StackContext;
|
import info.sigterm.deob.execution.StackContext;
|
||||||
|
import info.sigterm.deob.pool.PoolEntry;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BiPush extends Instruction
|
public class BiPush extends Instruction implements PushConstantInstruction
|
||||||
{
|
{
|
||||||
private byte b;
|
private byte b;
|
||||||
|
|
||||||
@@ -45,4 +47,16 @@ public class BiPush extends Instruction
|
|||||||
|
|
||||||
frame.addInstructionContext(ins);
|
frame.addInstructionContext(ins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolEntry getConstant()
|
||||||
|
{
|
||||||
|
return new info.sigterm.deob.pool.Integer(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setConstant(PoolEntry entry)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,18 @@ package info.sigterm.deob.attributes.code.instructions;
|
|||||||
import info.sigterm.deob.attributes.code.Instruction;
|
import info.sigterm.deob.attributes.code.Instruction;
|
||||||
import info.sigterm.deob.attributes.code.InstructionType;
|
import info.sigterm.deob.attributes.code.InstructionType;
|
||||||
import info.sigterm.deob.attributes.code.Instructions;
|
import info.sigterm.deob.attributes.code.Instructions;
|
||||||
|
import info.sigterm.deob.attributes.code.instruction.types.PushConstantInstruction;
|
||||||
import info.sigterm.deob.execution.Frame;
|
import info.sigterm.deob.execution.Frame;
|
||||||
import info.sigterm.deob.execution.InstructionContext;
|
import info.sigterm.deob.execution.InstructionContext;
|
||||||
import info.sigterm.deob.execution.Stack;
|
import info.sigterm.deob.execution.Stack;
|
||||||
import info.sigterm.deob.execution.StackContext;
|
import info.sigterm.deob.execution.StackContext;
|
||||||
|
import info.sigterm.deob.pool.PoolEntry;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class SiPush extends Instruction
|
public class SiPush extends Instruction implements PushConstantInstruction
|
||||||
{
|
{
|
||||||
private short s;
|
private short s;
|
||||||
|
|
||||||
@@ -45,4 +47,16 @@ public class SiPush extends Instruction
|
|||||||
|
|
||||||
frame.addInstructionContext(ins);
|
frame.addInstructionContext(ins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolEntry getConstant()
|
||||||
|
{
|
||||||
|
return new info.sigterm.deob.pool.Integer(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setConstant(PoolEntry entry)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -516,7 +516,6 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
InstructionContext ctx = op.compCtx; // comparison
|
InstructionContext ctx = op.compCtx; // comparison
|
||||||
Instruction ins = ctx.getInstruction();
|
Instruction ins = ctx.getInstruction();
|
||||||
boolean branch = op.branch;
|
boolean branch = op.branch;
|
||||||
assert branch;
|
|
||||||
|
|
||||||
Instructions instructions = ins.getInstructions();
|
Instructions instructions = ins.getInstructions();
|
||||||
|
|
||||||
@@ -528,23 +527,34 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
int idx = instructions.getInstructions().indexOf(ins);
|
int idx = instructions.getInstructions().indexOf(ins);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
continue; // already removed?
|
continue; // already removed?
|
||||||
|
|
||||||
JumpingInstruction jumpIns = (JumpingInstruction) ins;
|
Instruction to;
|
||||||
assert jumpIns.getJumps().size() == 1;
|
if (branch)
|
||||||
Instruction to = jumpIns.getJumps().get(0);
|
{
|
||||||
|
JumpingInstruction jumpIns = (JumpingInstruction) ins;
|
||||||
|
assert jumpIns.getJumps().size() == 1;
|
||||||
|
to = jumpIns.getJumps().get(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// just go to next instruction
|
||||||
|
to = instructions.getInstructions().get(idx + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// move things that jump here to instead jump to 'to'
|
// move things that jump here to instead jump to 'to'
|
||||||
for (Instruction fromI : ins.from)
|
for (Instruction fromI : ins.from)
|
||||||
{
|
{
|
||||||
|
assert fromI.jump.contains(ins);
|
||||||
|
|
||||||
|
fromI.jump.remove(ins);
|
||||||
|
fromI.replace(ins, to);
|
||||||
}
|
}
|
||||||
|
ins.from.clear();
|
||||||
|
|
||||||
instructions.remove(ctx.getInstruction());
|
instructions.remove(ins);
|
||||||
|
|
||||||
//assert branch;
|
if (branch)
|
||||||
|
{
|
||||||
//if (branch)
|
|
||||||
{
|
|
||||||
// insert goto
|
// insert goto
|
||||||
instructions.getInstructions().add(idx, new Goto(instructions, to));
|
instructions.getInstructions().add(idx, new Goto(instructions, to));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user