Also direct assignment

This commit is contained in:
Adam
2015-08-23 18:35:45 -04:00
parent 7ac2b0e977
commit 5561478ec8
3 changed files with 41 additions and 2 deletions

View File

@@ -56,6 +56,18 @@ public class PutStatic extends Instruction implements SetFieldInstruction
{
Pair pair = encryption.getField(myField);
InstructionContext ctx = object.getPushed();
if (ctx.getInstruction() instanceof PushConstantInstruction && pair != null)
{
// field = encryptedvalue
// decrypt value by * getter
PushConstantInstruction pci = (PushConstantInstruction) ctx.getInstruction();
int value = (int) pci.getConstant().getObject();
value = value * pair.getter;
encryption.change(pci, value);
}
if (ctx.getInstruction() instanceof ISub)
{
List<StackContext> stackCtx = ctx.getPops();

View File

@@ -10,10 +10,17 @@ public class Encryption
{
private Map<Field, Pair> fields = new HashMap<>();
private Map<PushConstantInstruction, Integer> changes = new HashMap<>();
int i;
private Pair p;
public Encryption(int i)
{
this.i = i;
}
public Pair getField(Field field)
{
if (field.getName().equals("field1170"))
if (i == 0 && field.getName().equals("field1170"))
{
Pair p = new Pair();
p.field = field;
@@ -22,6 +29,15 @@ public class Encryption
assert p.setter == 1237096007;
return p;
}
if (i == 1 && field.getName().equals("field700"))
{
Pair p = new Pair();
p.field = field;
p.getter = -478315765;
p.setter = DMath.modInverse(p.getter);
//assert p.setter ==
return p;
}
return null;
//return fields.get(field);
}

View File

@@ -179,7 +179,18 @@ public class ModArith implements Deobfuscator
execution = new Execution(group);
execution.populateInitialMethods();
Encryption encr = new Encryption();
Encryption encr = new Encryption(0);
execution.setEncryption(encr);
execution.run();
encr.doChange();
execution = new Execution(group);
execution.populateInitialMethods();
encr = new Encryption(1);
execution.setEncryption(encr);
execution.run();