I think my invokevirtual execution is wrong because it doesn't actually

look for virtual methods on the type, which is why my unused method deob
does weird things. I am seeing methods that still exist after running it
that appear to be using non-inversible constants.
This commit is contained in:
Adam
2015-06-25 19:07:46 -04:00
parent 1eee5a48ae
commit 0543950013
7 changed files with 89 additions and 25 deletions

View File

@@ -22,7 +22,10 @@ public class InstructionContext
public void pop(StackContext... ctx)
{
for (StackContext c : ctx)
{
c.setPopped(this); // now we know which instruction popped this, record it
pops.add(c);
}
}
public void push(StackContext... ctx)
@@ -47,6 +50,11 @@ public class InstructionContext
return pops;
}
public List<StackContext> getPushes()
{
return pushes;
}
public void removeStack(int idx)
{
// idx 0 is top of the stack, 1 is one under

View File

@@ -22,8 +22,8 @@ public class Stack
{
for (int i = 0; i < level; ++i)
System.err.print(" ");
System.err.println(ctx.getType().type + " pushed by " + ctx.getIns().getInstruction().getType().getName() + " at " + ctx.getIns().getInstruction().getPc());
for (StackContext c : ctx.getIns().getPops())
System.err.println(ctx.getType().type + " pushed by " + ctx.getPushed().getInstruction().getType().getName() + " at " + ctx.getPushed().getInstruction().getPc());
for (StackContext c : ctx.getPushed().getPops())
printStack(c, level + 2);
}
@@ -31,7 +31,7 @@ public class Stack
{
if (size == stack.length)
{
info.sigterm.deob.Method m = i.getIns().getInstruction().getInstructions().getCode().getAttributes().getMethod();
info.sigterm.deob.Method m = i.getPushed().getInstruction().getInstructions().getCode().getAttributes().getMethod();
System.err.println("in " + m.getMethods().getClassFile().getName() + " method " + m.getNameAndType().getName());
for (int c = 0; c < stack.length; ++c)
printStack(stack[c], 0);

View File

@@ -2,32 +2,43 @@ package info.sigterm.deob.execution;
public class StackContext
{
private InstructionContext ic; // instruction which pushed this
private InstructionContext pushed; // instruction which pushed this
private InstructionContext popped; // instruction which popped this
private Type type; // type of this
public StackContext(InstructionContext i, Type t)
public StackContext(InstructionContext pushed, Type type)
{
ic = i;
type = t;
this.pushed = pushed;
this.type = type;
}
public StackContext(InstructionContext i, Class<?> c)
public StackContext(InstructionContext pushed, Class<?> clazz)
{
ic = i;
type = new Type(c.getCanonicalName());
this.pushed = pushed;
type = new Type(clazz.getCanonicalName());
}
public StackContext(InstructionContext i, info.sigterm.deob.pool.Class c)
public StackContext(InstructionContext pushed, info.sigterm.deob.pool.Class c)
{
ic = i;
this.pushed = pushed;
type = new Type(c.getName());
}
public InstructionContext getIns()
public InstructionContext getPushed()
{
return ic;
return pushed;
}
public InstructionContext getPopped()
{
return popped;
}
public void setPopped(InstructionContext popped)
{
this.popped = popped;
}
public Type getType()
{
return type;
@@ -37,13 +48,13 @@ public class StackContext
public void removeStack()
{
// remove the instruction which pushed this
if (!ic.getInstruction().removeStack())
if (!pushed.getInstruction().removeStack())
// dup will return false as the other objects on the stack below this are necessary
// for the other branch.
return;
// remove from the stack things this instruction read
for (StackContext ctx : ic.getPops())
for (StackContext ctx : pushed.getPops())
ctx.removeStack();
}
}