Added failing negative mul test
This commit is contained in:
@@ -31,47 +31,47 @@ public class Deob
|
|||||||
|
|
||||||
ClassGroup group = JarUtil.loadJar(new File(args[0]));
|
ClassGroup group = JarUtil.loadJar(new File(args[0]));
|
||||||
|
|
||||||
run(group, new RenameUnique());
|
// run(group, new RenameUnique());
|
||||||
|
//
|
||||||
// remove except RuntimeException
|
// // remove except RuntimeException
|
||||||
run(group, new RuntimeExceptions());
|
// run(group, new RuntimeExceptions());
|
||||||
|
//
|
||||||
// remove unused methods
|
// // remove unused methods
|
||||||
run(group, new UnreachedCode());
|
// run(group, new UnreachedCode());
|
||||||
run(group, new UnusedMethods());
|
// run(group, new UnusedMethods());
|
||||||
|
//
|
||||||
// remove illegal state exceptions, frees up some parameters
|
// // remove illegal state exceptions, frees up some parameters
|
||||||
run(group, new IllegalStateExceptions());
|
// run(group, new IllegalStateExceptions());
|
||||||
|
//
|
||||||
// remove constant logically dead parameters
|
// // remove constant logically dead parameters
|
||||||
run(group, new ConstantParameter());
|
// run(group, new ConstantParameter());
|
||||||
|
//
|
||||||
// remove unhit blocks
|
// // remove unhit blocks
|
||||||
run(group, new UnreachedCode());
|
// run(group, new UnreachedCode());
|
||||||
run(group, new UnusedMethods());
|
// run(group, new UnusedMethods());
|
||||||
|
//
|
||||||
// remove unused parameters
|
// // remove unused parameters
|
||||||
run(group, new UnusedParameters());
|
// run(group, new UnusedParameters());
|
||||||
|
//
|
||||||
// remove unused fields
|
// // remove unused fields
|
||||||
run(group, new UnusedFields());
|
// run(group, new UnusedFields());
|
||||||
|
//
|
||||||
// remove unused methods, again?
|
// // remove unused methods, again?
|
||||||
run(group, new UnusedMethods());
|
// run(group, new UnusedMethods());
|
||||||
|
//
|
||||||
// run(group, new MethodInliner());
|
//// run(group, new MethodInliner());
|
||||||
// run(group, new UnusedMethods()); // inliner might leave unused methods
|
//// run(group, new UnusedMethods()); // inliner might leave unused methods
|
||||||
|
//
|
||||||
// // broken because rename was removed
|
//// // broken because rename was removed
|
||||||
// //run(group, new MethodMover());
|
//// //run(group, new MethodMover());
|
||||||
|
//
|
||||||
run(group, new FieldInliner());
|
// run(group, new FieldInliner());
|
||||||
|
//
|
||||||
// // XXX this is broken because when moving clinit around, some fields can depend on other fields
|
//// // XXX this is broken because when moving clinit around, some fields can depend on other fields
|
||||||
// // (like multianewarray)
|
//// // (like multianewarray)
|
||||||
// //new FieldMover().run(group);
|
//// //new FieldMover().run(group);
|
||||||
|
//
|
||||||
run(group, new UnusedClass());
|
// run(group, new UnusedClass());
|
||||||
|
|
||||||
ModArith mod = new ModArith();
|
ModArith mod = new ModArith();
|
||||||
mod.run(group);
|
mod.run(group);
|
||||||
|
|||||||
@@ -695,4 +695,9 @@ public class ModArith implements Deobfuscator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Encryption getEncryption()
|
||||||
|
{
|
||||||
|
return encryption;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,15 +124,7 @@ public class Execution
|
|||||||
|
|
||||||
methods.add(frame.getMethod());
|
methods.add(frame.getMethod());
|
||||||
|
|
||||||
if (!frame.isExecuting())
|
|
||||||
{
|
|
||||||
frames.remove(0);
|
|
||||||
processedFrames.add(frame);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
++fcount;
|
++fcount;
|
||||||
assert frame.isExecuting();
|
|
||||||
frame.execute();
|
frame.execute();
|
||||||
|
|
||||||
assert frames.get(0) == frame;
|
assert frames.get(0) == frame;
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ import org.junit.Test;
|
|||||||
|
|
||||||
class TestClass
|
class TestClass
|
||||||
{
|
{
|
||||||
private static int dummy(Object... args) { return 0; }
|
private static int dummy(Object... args)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private int field1051 = -1611704481;
|
private int field1051 = -1611704481;
|
||||||
private int field2701;
|
private int field2701;
|
||||||
@@ -26,7 +29,7 @@ class TestClass
|
|||||||
{
|
{
|
||||||
TestClass tc = new TestClass(); // to trick executor to call the constructor
|
TestClass tc = new TestClass(); // to trick executor to call the constructor
|
||||||
int var = 42;
|
int var = 42;
|
||||||
|
|
||||||
if (-1 != this.field1051 * 1928543073)
|
if (-1 != this.field1051 * 1928543073)
|
||||||
{
|
{
|
||||||
dummy(this.field1051 * 1928543073);
|
dummy(this.field1051 * 1928543073);
|
||||||
@@ -37,7 +40,7 @@ class TestClass
|
|||||||
{
|
{
|
||||||
field2701 += -1868498967 * var;
|
field2701 += -1868498967 * var;
|
||||||
}
|
}
|
||||||
|
|
||||||
field2138 = tc.dummy() * 1510226873;
|
field2138 = tc.dummy() * 1510226873;
|
||||||
field2130 = 572701809 * tc.field2138;
|
field2130 = 572701809 * tc.field2138;
|
||||||
if (-1722291303 * field2130 >= var)
|
if (-1722291303 * field2130 >= var)
|
||||||
@@ -47,6 +50,27 @@ class TestClass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestClass2
|
||||||
|
{
|
||||||
|
int field2863;
|
||||||
|
int array[];
|
||||||
|
|
||||||
|
public void test()
|
||||||
|
{
|
||||||
|
TestClass2 tc = new TestClass2();
|
||||||
|
|
||||||
|
field2863 = -1446933277;
|
||||||
|
|
||||||
|
array[378529589 * tc.field2863] = 1;
|
||||||
|
|
||||||
|
int var = 32;
|
||||||
|
|
||||||
|
tc.field2863 = var * 1446933277;
|
||||||
|
|
||||||
|
array[378529589 * tc.field2863] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ModArithTest
|
public class ModArithTest
|
||||||
{
|
{
|
||||||
private void checkConstants(ClassFile cf)
|
private void checkConstants(ClassFile cf)
|
||||||
@@ -56,31 +80,71 @@ public class ModArithTest
|
|||||||
Code code = m.getCode();
|
Code code = m.getCode();
|
||||||
Instructions instructions = code.getInstructions();
|
Instructions instructions = code.getInstructions();
|
||||||
for (Instruction i : instructions.getInstructions())
|
for (Instruction i : instructions.getInstructions())
|
||||||
|
{
|
||||||
if (i instanceof LDC_W)
|
if (i instanceof LDC_W)
|
||||||
{
|
{
|
||||||
LDC_W ldc = (LDC_W) i;
|
LDC_W ldc = (LDC_W) i;
|
||||||
Assert.assertFalse(DMath.isBig(ldc.getConstantAsInt()));
|
Assert.assertFalse(DMath.isBig(ldc.getConstantAsInt()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws IOException
|
public void test() throws IOException
|
||||||
{
|
{
|
||||||
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/deobfuscators/arithmetic/TestClass.class");
|
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/deobfuscators/arithmetic/TestClass.class");
|
||||||
Assert.assertNotNull(in);
|
Assert.assertNotNull(in);
|
||||||
|
|
||||||
ClassGroup group = new ClassGroup();
|
ClassGroup group = new ClassGroup();
|
||||||
|
|
||||||
ClassFile cf = new ClassFile(group, new DataInputStream(in));
|
ClassFile cf = new ClassFile(group, new DataInputStream(in));
|
||||||
group.addClass(cf);
|
group.addClass(cf);
|
||||||
|
|
||||||
ModArith d1 = new ModArith();
|
ModArith d1 = new ModArith();
|
||||||
d1.run(group);
|
d1.run(group);
|
||||||
d1.runOnce();
|
d1.runOnce();
|
||||||
|
|
||||||
Deobfuscator d2 = new MultiplicationDeobfuscator();
|
Deobfuscator d2 = new MultiplicationDeobfuscator();
|
||||||
d2.run(group);
|
d2.run(group);
|
||||||
|
|
||||||
this.checkConstants(cf);
|
this.checkConstants(cf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test2() throws IOException
|
||||||
|
{
|
||||||
|
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/deobfuscators/arithmetic/TestClass2.class");
|
||||||
|
Assert.assertNotNull(in);
|
||||||
|
|
||||||
|
ClassGroup group = new ClassGroup();
|
||||||
|
|
||||||
|
ClassFile cf = new ClassFile(group, new DataInputStream(in));
|
||||||
|
group.addClass(cf);
|
||||||
|
|
||||||
|
ModArith d1 = new ModArith();
|
||||||
|
d1.run(group);
|
||||||
|
|
||||||
|
int last = -1, cur;
|
||||||
|
while ((cur = d1.runOnce()) > 0)
|
||||||
|
{
|
||||||
|
Deobfuscator d2 = new MultiplicationDeobfuscator();
|
||||||
|
d2.run(group);
|
||||||
|
|
||||||
|
new MultiplyOneDeobfuscator().run(group);
|
||||||
|
|
||||||
|
new MultiplyZeroDeobfuscator().run(group);
|
||||||
|
|
||||||
|
if (last == cur)
|
||||||
|
break;
|
||||||
|
|
||||||
|
last = cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
Encryption e = d1.getEncryption();
|
||||||
|
|
||||||
|
Pair pair = e.getField(cf.findField("field2863").getPoolField());
|
||||||
|
|
||||||
|
Assert.assertEquals(378529589, (int) pair.getter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user