Small fixups i guess
This commit is contained in:
@@ -97,6 +97,11 @@ public class ModArith implements Deobfuscator
|
|||||||
if (field == null)
|
if (field == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (field.getName().equals("field2201"))
|
||||||
|
{
|
||||||
|
int k=7;
|
||||||
|
}
|
||||||
|
|
||||||
int value = (int) pc.getConstant().getObject();
|
int value = (int) pc.getConstant().getObject();
|
||||||
|
|
||||||
if (value == 1 || value == 0)
|
if (value == 1 || value == 0)
|
||||||
@@ -112,17 +117,17 @@ public class ModArith implements Deobfuscator
|
|||||||
if (field == null)
|
if (field == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
List<Integer> constants = null;
|
// List<Integer> constants = null;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
constants = findAssocConstants(field, ctx);
|
// constants = findAssocConstants(field, ctx);
|
||||||
for (int i : constants)
|
// for (int i : constants)
|
||||||
if (i != 1 && i != 0)
|
// if (i != 1 && i != 0)
|
||||||
constantSetters.put(field, i);
|
// constantSetters.put(field, i);
|
||||||
}
|
// }
|
||||||
catch (OtherFieldException ex) { }
|
// catch (OtherFieldException ex) { }
|
||||||
|
|
||||||
StackContext value = ctx.getPops().get(0); // the first thing poppe from both putfield and putstatic is the value
|
StackContext value = ctx.getPops().get(0); // the first thing popped from both putfield and putstatic is the value
|
||||||
if (!(value.getPushed().getInstruction() instanceof IMul))
|
if (!(value.getPushed().getInstruction() instanceof IMul))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -150,6 +155,11 @@ public class ModArith implements Deobfuscator
|
|||||||
if (value2 == 1 || value2 == 0)
|
if (value2 == 1 || value2 == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (field.getName().equals("field2201"))
|
||||||
|
{
|
||||||
|
int k=7;
|
||||||
|
}
|
||||||
|
|
||||||
constantSetters.put(field, value2);
|
constantSetters.put(field, value2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,60 +224,60 @@ public class ModArith implements Deobfuscator
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair guess(Field field, Collection<Integer> values, boolean getter)
|
// private Pair guess(Field field, Collection<Integer> values, boolean getter)
|
||||||
{
|
// {
|
||||||
Map<Integer, Integer> map = CollectionUtils.getCardinalityMap(values); // value -> how many times it occurs
|
// Map<Integer, Integer> map = CollectionUtils.getCardinalityMap(values); // value -> how many times it occurs
|
||||||
int max = Collections.max(map.values()); // largest occurance #
|
// int max = Collections.max(map.values()); // largest occurance #
|
||||||
int size = values.size();
|
// int size = values.size();
|
||||||
|
//
|
||||||
// if (max == size)
|
//// if (max == size)
|
||||||
// {
|
//// {
|
||||||
// // all getters are the same value
|
//// // all getters are the same value
|
||||||
// int constant = getters.iterator().next();
|
//// int constant = getters.iterator().next();
|
||||||
// Pair pair = new Pair();
|
//// Pair pair = new Pair();
|
||||||
// pair.getter = constant;
|
//// pair.getter = constant;
|
||||||
// System.out.println("Guessing " + field.getName() + " getter " + constant + " setter ");
|
//// System.out.println("Guessing " + field.getName() + " getter " + constant + " setter ");
|
||||||
// pair.setter = DMath.modInverse(constant);
|
//// pair.setter = DMath.modInverse(constant);
|
||||||
// return pair;
|
//// return pair;
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if (size < 50)
|
||||||
|
//// return null;
|
||||||
|
//
|
||||||
|
//// if (((float) max / (float) size) < 0.9)
|
||||||
|
//// return null;
|
||||||
|
//
|
||||||
|
// for (final Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
||||||
|
// if (max == entry.getValue()) {
|
||||||
|
// int constant = entry.getKey();
|
||||||
|
// int inverse;
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// inverse = DMath.modInverse(constant);
|
||||||
|
// }
|
||||||
|
// catch (ArithmeticException ex)
|
||||||
|
// {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Pair pair = new Pair();
|
||||||
|
// if (getter)
|
||||||
|
// {
|
||||||
|
// pair.getter = constant;
|
||||||
|
// pair.setter = inverse;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// pair.getter = inverse;
|
||||||
|
// pair.setter = constant;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return pair;
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (size < 50)
|
// return null;
|
||||||
// return null;
|
// }
|
||||||
|
|
||||||
// if (((float) max / (float) size) < 0.9)
|
|
||||||
// return null;
|
|
||||||
|
|
||||||
for (final Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
|
||||||
if (max == entry.getValue()) {
|
|
||||||
int constant = entry.getKey();
|
|
||||||
int inverse;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
inverse = DMath.modInverse(constant);
|
|
||||||
}
|
|
||||||
catch (ArithmeticException ex)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pair pair = new Pair();
|
|
||||||
if (getter)
|
|
||||||
{
|
|
||||||
pair.getter = constant;
|
|
||||||
pair.setter = inverse;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pair.getter = inverse;
|
|
||||||
pair.setter = constant;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pair;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reduce()
|
private void reduce()
|
||||||
{
|
{
|
||||||
@@ -277,11 +287,6 @@ public class ModArith implements Deobfuscator
|
|||||||
Collection<Integer> getters = constantGetters.getCollection(f),
|
Collection<Integer> getters = constantGetters.getCollection(f),
|
||||||
setters = constantSetters.getCollection(f);
|
setters = constantSetters.getCollection(f);
|
||||||
|
|
||||||
if (f.getName().equals("field542"))
|
|
||||||
{
|
|
||||||
int i =5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getters == null || setters == null)
|
if (getters == null || setters == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -421,6 +426,7 @@ public class ModArith implements Deobfuscator
|
|||||||
//if (!field.getName().equals("field3014") && !field.getName().equals("field2960"))
|
//if (!field.getName().equals("field3014") && !field.getName().equals("field2960"))
|
||||||
if (!field.getName().equals("field2201"))
|
if (!field.getName().equals("field2201"))
|
||||||
{
|
{
|
||||||
|
int j =5;
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction;
|
|||||||
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
|
||||||
import net.runelite.deob.attributes.code.instructions.BiPush;
|
import net.runelite.deob.attributes.code.instructions.BiPush;
|
||||||
import net.runelite.deob.attributes.code.instructions.IAdd;
|
import net.runelite.deob.attributes.code.instructions.IAdd;
|
||||||
|
import net.runelite.deob.attributes.code.instructions.IConst_M1;
|
||||||
import net.runelite.deob.attributes.code.instructions.IMul;
|
import net.runelite.deob.attributes.code.instructions.IMul;
|
||||||
import net.runelite.deob.attributes.code.instructions.ISub;
|
import net.runelite.deob.attributes.code.instructions.ISub;
|
||||||
import net.runelite.deob.attributes.code.instructions.LDC_W;
|
import net.runelite.deob.attributes.code.instructions.LDC_W;
|
||||||
@@ -49,7 +50,8 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
|
|
||||||
if (ctx.getInstruction() instanceof PushConstantInstruction)
|
if (ctx.getInstruction() instanceof PushConstantInstruction)
|
||||||
{
|
{
|
||||||
if (ctx.getInstruction() instanceof BiPush || ctx.getInstruction() instanceof SiPush)
|
if (ctx.getInstruction() instanceof BiPush || ctx.getInstruction() instanceof SiPush
|
||||||
|
|| ctx.getInstruction() instanceof IConst_M1)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
@@ -92,7 +94,8 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
{
|
{
|
||||||
if (i.getInstruction() instanceof PushConstantInstruction)
|
if (i.getInstruction() instanceof PushConstantInstruction)
|
||||||
{
|
{
|
||||||
if (i.getInstruction() instanceof BiPush || i.getInstruction() instanceof SiPush)
|
if (i.getInstruction() instanceof BiPush || i.getInstruction() instanceof SiPush
|
||||||
|
|| i.getInstruction() instanceof IConst_M1)
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
|
||||||
// a constant of imul
|
// a constant of imul
|
||||||
@@ -271,19 +274,23 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
if (one.getInstruction() != two.getInstruction())
|
if (one.getInstruction() != two.getInstruction())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check if stack at time of execution is equal
|
assert one.getPops().contains(sctx);
|
||||||
List<StackContext> ours = one.getStack().getStack(), theirs = two.getStack().getStack();
|
int i = one.getPops().indexOf(sctx);
|
||||||
//Stack ours = new Stack(one.getStack()), // copy stacks since we destroy them
|
|
||||||
// theirs = new Stack(two.getStack());
|
|
||||||
|
|
||||||
if (ours.size() != theirs.size()) // is this possible?
|
|
||||||
return false;
|
|
||||||
|
|
||||||
assert ours.contains(sctx);
|
|
||||||
int i = ours.indexOf(sctx);
|
|
||||||
|
|
||||||
StackContext theirsctx = theirs.get(i);
|
|
||||||
|
|
||||||
|
StackContext theirsctx = two.getPops().get(i);
|
||||||
|
// // check if stack at time of execution is equal
|
||||||
|
// List<StackContext> ours = one.getStack().getStack(), theirs = two.getStack().getStack();
|
||||||
|
// //Stack ours = new Stack(one.getStack()), // copy stacks since we destroy them
|
||||||
|
//// theirs = new Stack(two.getStack());
|
||||||
|
//
|
||||||
|
// if (ours.size() != theirs.size()) // is this possible?
|
||||||
|
// return false;
|
||||||
|
//
|
||||||
|
// assert ours.contains(sctx);
|
||||||
|
// int i = ours.indexOf(sctx);
|
||||||
|
//
|
||||||
|
// StackContext theirsctx = theirs.get(i);
|
||||||
|
//
|
||||||
if (sctx.getPushed().getInstruction() != theirsctx.getPushed().getInstruction())
|
if (sctx.getPushed().getInstruction() != theirsctx.getPushed().getInstruction())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user