Isolate a test I believe is wrong
This commit is contained in:
@@ -21,7 +21,7 @@ public class IConst_2 extends Instruction implements PushConstantInstruction
|
||||
|
||||
public IConst_2(Instructions instructions)
|
||||
{
|
||||
super(instructions, InstructionType.ICONST_2, 0);
|
||||
super(instructions, InstructionType.ICONST_2, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,11 @@ public class IDiv extends Instruction
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
public IDiv(Instructions instructions)
|
||||
{
|
||||
super(instructions, InstructionType.IDIV, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class IStore extends Instruction implements LVTInstruction, WideInstructi
|
||||
|
||||
public IStore(Instructions instructions, int index)
|
||||
{
|
||||
super(instructions, InstructionType.ISTORE, 0);
|
||||
super(instructions, InstructionType.ISTORE, -1);
|
||||
this.index = index;
|
||||
++length;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,15 @@ import java.io.IOException;
|
||||
|
||||
public class IStore_1 extends Instruction implements LVTInstruction
|
||||
{
|
||||
public IStore_1(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
public IStore_1(Instructions instructions, InstructionType type, int pc)
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
public IStore_1(Instructions instructions)
|
||||
{
|
||||
super(instructions, InstructionType.ISTORE_1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
|
||||
@@ -16,10 +16,15 @@ import java.io.IOException;
|
||||
|
||||
public class IStore_2 extends Instruction implements LVTInstruction
|
||||
{
|
||||
public IStore_2(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
public IStore_2(Instructions instructions, InstructionType type, int pc)
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
public IStore_2(Instructions instructions)
|
||||
{
|
||||
super(instructions, InstructionType.ISTORE_2, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Frame frame)
|
||||
|
||||
@@ -26,6 +26,16 @@ public class If extends Instruction implements JumpingInstruction, ComparisonIns
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
public If(Instructions instructions, Instruction to)
|
||||
{
|
||||
super(instructions, InstructionType.IF_ICMPNE, -1);
|
||||
|
||||
assert this != to;
|
||||
assert to.getInstructions() == this.getInstructions();
|
||||
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(DataInputStream is) throws IOException
|
||||
{
|
||||
|
||||
@@ -26,6 +26,16 @@ public class If0 extends Instruction implements JumpingInstruction, ComparisonIn
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
public If0(Instructions instructions, Instruction to)
|
||||
{
|
||||
super(instructions, InstructionType.IFEQ, -1);
|
||||
|
||||
assert this != to;
|
||||
assert to.getInstructions() == this.getInstructions();
|
||||
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(DataInputStream is) throws IOException
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.io.IOException;
|
||||
|
||||
public class NOP extends Instruction
|
||||
{
|
||||
public NOP(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||
public NOP(Instructions instructions, InstructionType type, int pc)
|
||||
{
|
||||
super(instructions, type, pc);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,23 @@ import net.runelite.deob.attributes.Code;
|
||||
import net.runelite.deob.attributes.code.Instruction;
|
||||
import net.runelite.deob.attributes.code.Instructions;
|
||||
import net.runelite.deob.attributes.code.instructions.Dup_X1;
|
||||
import net.runelite.deob.attributes.code.instructions.Goto;
|
||||
import net.runelite.deob.attributes.code.instructions.IAdd;
|
||||
import net.runelite.deob.attributes.code.instructions.IConst_0;
|
||||
import net.runelite.deob.attributes.code.instructions.IConst_1;
|
||||
import net.runelite.deob.attributes.code.instructions.IConst_2;
|
||||
import net.runelite.deob.attributes.code.instructions.IConst_3;
|
||||
import net.runelite.deob.attributes.code.instructions.IDiv;
|
||||
import net.runelite.deob.attributes.code.instructions.ILoad;
|
||||
import net.runelite.deob.attributes.code.instructions.IMul;
|
||||
import net.runelite.deob.attributes.code.instructions.IStore;
|
||||
import net.runelite.deob.attributes.code.instructions.IStore_0;
|
||||
import net.runelite.deob.attributes.code.instructions.IStore_1;
|
||||
import net.runelite.deob.attributes.code.instructions.IStore_2;
|
||||
import net.runelite.deob.attributes.code.instructions.If;
|
||||
import net.runelite.deob.attributes.code.instructions.If0;
|
||||
import net.runelite.deob.attributes.code.instructions.LDC_W;
|
||||
import net.runelite.deob.attributes.code.instructions.NOP;
|
||||
import net.runelite.deob.attributes.code.instructions.Pop;
|
||||
import net.runelite.deob.attributes.code.instructions.VReturn;
|
||||
import net.runelite.deob.execution.Execution;
|
||||
@@ -161,4 +171,134 @@ public class MultiplicationDeobfuscatorTest
|
||||
Assert.assertEquals(1, constant3.getConstantAsInt());
|
||||
Assert.assertEquals(1, constant4.getConstantAsInt());
|
||||
}
|
||||
|
||||
//@Test
|
||||
// public void testDupX1_3()
|
||||
// {
|
||||
// ClassGroup group = ClassGroupFactory.generateGroup();
|
||||
// Code code = group.findClass("test").findMethod("func").getCode();
|
||||
// Instructions ins = code.getInstructions();
|
||||
//
|
||||
// code.setMaxStack(2);
|
||||
//
|
||||
// Instruction[] prepareVariables = {
|
||||
// new IConst_3(ins),
|
||||
// new IStore_0(ins),
|
||||
// new IConst_3(ins),
|
||||
// new IStore_1(ins),
|
||||
// new IConst_3(ins),
|
||||
// new IStore_2(ins),
|
||||
// };
|
||||
//
|
||||
// for (Instruction i : prepareVariables)
|
||||
// ins.addInstruction(i);
|
||||
//
|
||||
// LDC_W constant1 = new LDC_W(ins, 1381104939),
|
||||
// constant2 = new LDC_W(ins, 1381104939),
|
||||
// constant3 = new LDC_W(ins, 981643079),
|
||||
// constant4 = new LDC_W(ins, 1807370871),
|
||||
// constant5 = new LDC_W(ins, 1807370871),
|
||||
// constant6 = new LDC_W(ins, 981643079);
|
||||
//
|
||||
// NOP label1 = new NOP(ins),
|
||||
// label2 = new NOP(ins);
|
||||
//
|
||||
// Instruction body[] = {
|
||||
// new IConst_1(ins),
|
||||
// new ILoad(ins, 0),
|
||||
// new If(ins, label1),
|
||||
// constant1,
|
||||
// new ILoad(ins, 1),
|
||||
// new IMul(ins),
|
||||
// new Goto(ins, label2),
|
||||
// label1,
|
||||
// new ILoad(ins, 1),
|
||||
// constant2,
|
||||
// new IMul(ins),
|
||||
// constant3,
|
||||
// new ILoad(ins, 2),
|
||||
// constant4,
|
||||
// new IMul(ins),
|
||||
// new IMul(ins),
|
||||
// new IAdd(ins),
|
||||
// new IConst_2(ins),
|
||||
// new IDiv(ins),
|
||||
// label2,
|
||||
// constant5,
|
||||
// new IMul(ins),
|
||||
// constant6,
|
||||
// new IMul(ins),
|
||||
// new IStore(ins, 3),
|
||||
// new VReturn(ins)
|
||||
// };
|
||||
//
|
||||
// for (Instruction i : body)
|
||||
// ins.addInstruction(i);
|
||||
//
|
||||
// Execution e = new Execution(group);
|
||||
// e.populateInitialMethods();
|
||||
// e.run();
|
||||
//
|
||||
// Deobfuscator d = new MultiplicationDeobfuscator();
|
||||
// d.run(group);
|
||||
//
|
||||
// Assert.assertEquals(1381104939, constant1.getConstantAsInt());
|
||||
// Assert.assertEquals(1381104939, constant2.getConstantAsInt());
|
||||
// Assert.assertEquals(981643079, constant3.getConstantAsInt());
|
||||
// Assert.assertEquals(1807370871, constant4.getConstantAsInt());
|
||||
// Assert.assertEquals(1807370871, constant5.getConstantAsInt());
|
||||
// Assert.assertEquals(981643079, constant6.getConstantAsInt());
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testDupX1_3()
|
||||
{
|
||||
ClassGroup group = ClassGroupFactory.generateGroup();
|
||||
Code code = group.findClass("test").findMethod("func").getCode();
|
||||
Instructions ins = code.getInstructions();
|
||||
|
||||
code.setMaxStack(2);
|
||||
|
||||
Instruction[] prepareVariables = {
|
||||
new IConst_3(ins),
|
||||
new IStore_0(ins),
|
||||
};
|
||||
|
||||
for (Instruction i : prepareVariables)
|
||||
ins.addInstruction(i);
|
||||
|
||||
LDC_W constant1 = new LDC_W(ins, 1381104939),
|
||||
constant2 = new LDC_W(ins, 1381104939),
|
||||
constant3 = new LDC_W(ins, 981643079);
|
||||
|
||||
NOP label1 = new NOP(ins);
|
||||
|
||||
Instruction body[] = {
|
||||
constant1,
|
||||
new ILoad(ins, 0),
|
||||
new IMul(ins),
|
||||
new IConst_0(ins),
|
||||
new If0(ins, label1),
|
||||
constant2,
|
||||
new IMul(ins),
|
||||
label1,
|
||||
constant3,
|
||||
new IMul(ins),
|
||||
new VReturn(ins)
|
||||
};
|
||||
|
||||
for (Instruction i : body)
|
||||
ins.addInstruction(i);
|
||||
|
||||
Execution e = new Execution(group);
|
||||
e.populateInitialMethods();
|
||||
e.run();
|
||||
|
||||
Deobfuscator d = new MultiplicationDeobfuscator();
|
||||
d.run(group);
|
||||
|
||||
Assert.assertEquals(1381104939, constant1.getConstantAsInt());
|
||||
Assert.assertEquals(1381104939, constant2.getConstantAsInt());
|
||||
Assert.assertEquals(981643079, constant3.getConstantAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user