Search in sources :

Example 61 with Instruction

use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.

the class MultiplicationDeobfuscatorTest method test9.

// aload                 0
// aload                 0
// aload                 1
// invokevirtual         class226/method4078()J
// ldc2_w                -81013729583719545
// lmul
// dup2_x1
// ldc2_w                -6236978337732675017
// lmul
// putfield              class227/field3204 J
// ldc2_w                -6236978337732675017
// lmul
// putfield              class227/field3196 J
@Test
public void test9() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(3);
    Instruction[] prepareVariables = { new LDC(ins, 1L), new LStore(ins, 0) };
    for (Instruction i : prepareVariables) {
        ins.addInstruction(i);
    }
    LDC constant1 = new LDC(ins, -81013729583719545L), constant2 = new LDC(ins, -6236978337732675017L), constant3 = new LDC(ins, -6236978337732675017L);
    Instruction[] body = { new LDC(ins, 0), new LLoad(ins, 0), constant1, new LMul(ins), // lmul, 0, lmul
    new Dup2_X1(ins), constant2, new LMul(ins), new Pop(ins), new Pop(ins), constant3, new LMul(ins), new Pop(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    Execution e = new Execution(group);
    e.populateInitialMethods();
    e.run();
    assert constant1.getConstantAsLong() * constant2.getConstantAsLong() == 1L;
    Deobfuscator d = new MultiplicationDeobfuscator();
    d.run(group);
    Assert.assertEquals(1L, constant1.getConstantAsLong());
    Assert.assertEquals(1L, constant2.getConstantAsLong());
    Assert.assertEquals(1L, constant3.getConstantAsLong());
}
Also used : LLoad(net.runelite.asm.attributes.code.instructions.LLoad) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) LStore(net.runelite.asm.attributes.code.instructions.LStore) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Deobfuscator(net.runelite.deob.Deobfuscator) Pop(net.runelite.asm.attributes.code.instructions.Pop) Execution(net.runelite.asm.execution.Execution) Dup2_X1(net.runelite.asm.attributes.code.instructions.Dup2_X1) ClassGroup(net.runelite.asm.ClassGroup) LMul(net.runelite.asm.attributes.code.instructions.LMul) Test(org.junit.Test)

Example 62 with Instruction

use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.

the class MultiplicationDeobfuscatorTest method test6.

@Test
public void test6() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(2);
    Instruction[] prepareVariables = { new LDC(ins, 3), new IStore(ins, 0), new LDC(ins, 2), new IStore(ins, 1) };
    for (Instruction i : prepareVariables) {
        ins.addInstruction(i);
    }
    LDC constant1 = new LDC(ins, 575391417);
    LDC constant2 = new LDC(ins, -497786999);
    Instruction[] body = { new ILoad(ins, 0), new ILoad(ins, 1), new Dup_X1(ins), new Pop(ins), new Pop(ins), constant1, new IMul(ins), constant2, new IMul(ins), new Pop(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    Execution e = new Execution(group);
    e.populateInitialMethods();
    e.run();
    assert constant1.getConstantAsInt() * constant2.getConstantAsInt() == 1;
    Deobfuscator d = new MultiplicationDeobfuscator();
    d.run(group);
    Assert.assertEquals(1, constant1.getConstantAsInt());
    Assert.assertEquals(1, constant2.getConstantAsInt());
}
Also used : IStore(net.runelite.asm.attributes.code.instructions.IStore) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Deobfuscator(net.runelite.deob.Deobfuscator) Pop(net.runelite.asm.attributes.code.instructions.Pop) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) Dup_X1(net.runelite.asm.attributes.code.instructions.Dup_X1) IMul(net.runelite.asm.attributes.code.instructions.IMul) Test(org.junit.Test)

Example 63 with Instruction

use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.

the class MultiplicationDeobfuscatorTest method test10.

@Test
public void test10() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(5);
    // vars[0] = 3
    Instruction[] prepareVariables = { new LDC(ins, 3), new IStore(ins, 0) };
    for (Instruction i : prepareVariables) {
        ins.addInstruction(i);
    }
    LDC constant1 = new LDC(ins, -1729723287);
    LDC constant2 = new LDC(ins, -143176743);
    Instruction[] body = { new ILoad(ins, 0), constant1, new IMul(ins), constant2, new IMul(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    // check execution runs ok
    Execution e = new Execution(group);
    e.populateInitialMethods();
    e.run();
    assert constant1.getConstantAsInt() * constant2.getConstantAsInt() == 1;
    Deobfuscator d = new MultiplicationDeobfuscator();
    d.run(group);
    Assert.assertEquals(1, constant1.getConstantAsInt());
    Assert.assertEquals(1, constant2.getConstantAsInt());
}
Also used : IStore(net.runelite.asm.attributes.code.instructions.IStore) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Deobfuscator(net.runelite.deob.Deobfuscator) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) IMul(net.runelite.asm.attributes.code.instructions.IMul) Test(org.junit.Test)

Example 64 with Instruction

use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.

the class MultiplicationDeobfuscatorTest method test12.

// 020   aload_0
// 021   aload_0
// 022   iload_1
// 023   ldc                   1129258489
// 024   imul						// this, this, mul
// 025   swap						// this, mul s, this
// 026   iload_1
// 027   iconst_1
// 028   imul						// this, mul s, this, mul
// 029   iconst_1
// 030   imul
// 031   putfield              class81/field1351 I       // this, mul
// 032   iconst_1
// 033   imul
// 034   ldc                   -1692330935
// 035   imul
// 036   putfield              class81/field1326 I
@Test
public void test12() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(5);
    Instruction[] prepareVariables = { new LDC(ins, 1), new IStore(ins, 0) };
    for (Instruction i : prepareVariables) {
        ins.addInstruction(i);
    }
    LDC constant1 = new LDC(ins, 1129258489);
    LDC constant2 = new LDC(ins, -1692330935);
    Instruction[] body = { // this
    new AConstNull(ins), // this
    new AConstNull(ins), new ILoad(ins, 0), constant1, new IMul(ins), // null, mul, null
    new Swap(ins), new ILoad(ins, 0), // putfield
    new Pop2(ins), constant2, new IMul(ins), // putfield
    new Pop2(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    Execution e = new Execution(group);
    e.populateInitialMethods();
    e.run();
    assert constant1.getConstantAsInt() * constant2.getConstantAsInt() == 1;
    Deobfuscator d = new MultiplicationDeobfuscator();
    d.run(group);
    Assert.assertEquals(1, constant1.getConstantAsInt());
    Assert.assertEquals(1, constant2.getConstantAsInt());
}
Also used : IStore(net.runelite.asm.attributes.code.instructions.IStore) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) Pop2(net.runelite.asm.attributes.code.instructions.Pop2) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) AConstNull(net.runelite.asm.attributes.code.instructions.AConstNull) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Deobfuscator(net.runelite.deob.Deobfuscator) Execution(net.runelite.asm.execution.Execution) Swap(net.runelite.asm.attributes.code.instructions.Swap) ClassGroup(net.runelite.asm.ClassGroup) IMul(net.runelite.asm.attributes.code.instructions.IMul) Test(org.junit.Test)

Example 65 with Instruction

use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.

the class MultiplicationDeobfuscatorTest method test7.

@Test
public void test7() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(2);
    Instruction[] prepareVariables = { new LDC(ins, 3), new IStore(ins, 0), new LDC(ins, 2), new IStore(ins, 1) };
    for (Instruction i : prepareVariables) {
        ins.addInstruction(i);
    }
    LDC constant1 = new LDC(ins, 2131037801), constant2 = new LDC(ins, -1306959399), constant3 = new LDC(ins, -1);
    Instruction[] body = { constant3, constant1, new IMul(ins), constant2, new IMul(ins), new Pop(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    Execution e = new Execution(group);
    e.populateInitialMethods();
    e.run();
    assert constant1.getConstantAsInt() * constant2.getConstantAsInt() == 1;
    Deobfuscator d = new MultiplicationDeobfuscator();
    d.run(group);
    Assert.assertEquals(1, constant1.getConstantAsInt());
    Assert.assertEquals(-1, constant2.getConstantAsInt());
    Assert.assertEquals(1, constant3.getConstantAsInt());
}
Also used : IStore(net.runelite.asm.attributes.code.instructions.IStore) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Deobfuscator(net.runelite.deob.Deobfuscator) Pop(net.runelite.asm.attributes.code.instructions.Pop) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) IMul(net.runelite.asm.attributes.code.instructions.IMul) Test(org.junit.Test)

Aggregations

Instruction (net.runelite.asm.attributes.code.Instruction)109 Instructions (net.runelite.asm.attributes.code.Instructions)69 Code (net.runelite.asm.attributes.Code)48 LDC (net.runelite.asm.attributes.code.instructions.LDC)39 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)32 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)32 ClassGroup (net.runelite.asm.ClassGroup)31 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)29 IMul (net.runelite.asm.attributes.code.instructions.IMul)28 VReturn (net.runelite.asm.attributes.code.instructions.VReturn)28 Test (org.junit.Test)27 ILoad (net.runelite.asm.attributes.code.instructions.ILoad)25 Method (net.runelite.asm.Method)24 IStore (net.runelite.asm.attributes.code.instructions.IStore)24 Execution (net.runelite.asm.execution.Execution)23 Deobfuscator (net.runelite.deob.Deobfuscator)22 Label (net.runelite.asm.attributes.code.Label)19 ArrayList (java.util.ArrayList)17 InstructionContext (net.runelite.asm.execution.InstructionContext)17 Field (net.runelite.asm.Field)16