fix unused methods again

This commit is contained in:
Adam
2015-06-28 20:45:01 -04:00
parent b0f5f33e89
commit 91f189add1
6 changed files with 33 additions and 9 deletions

View File

@@ -153,6 +153,7 @@ public class ClassFile
if (m != null)
return m;
// XXX is this necessary?
ClassFile parent = getParent();
if (parent != null)
return parent.findMethod(nat);
@@ -172,15 +173,26 @@ public class ClassFile
return null;
}
public void clearClassGraph()
{
parent = null;
children.clear();
}
public void buildClassGraph()
{
ClassFile other = getParent();
if (other == null)
return; // inherits from a class not in my group
this.parent = other;
parent.children.add(this);
ClassFile other = group.findClass(super_class.getName());
if (other != null)
{
this.parent = other;
parent.children.add(this);
}
for (ClassFile i : interfaces.getInterfaces())
{
i.children.add(this);
}
}
public void buildInstructionGraph()

View File

@@ -36,6 +36,9 @@ public class ClassGroup
public void buildClassGraph()
{
for (ClassFile c : classes)
c.clearClassGraph();
for (ClassFile c : classes)
c.buildClassGraph();
}

View File

@@ -54,7 +54,7 @@ public class Deob
new UnusedBlocks().run(group);
// remove unused parameters
new UnusedParameters().run(group);
//new UnusedParameters().run(group);
// remove jump obfuscation
new Jumps().run(group);

View File

@@ -68,7 +68,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
ins.push(ctx);
}
for (info.sigterm.deob.Method method : getMethods())
{
ins.invoke(method);

View File

@@ -4,6 +4,7 @@ import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import info.sigterm.deob.ClassFile;
import info.sigterm.deob.ClassGroup;
@@ -129,6 +130,12 @@ public class ModularArithmeticDeobfuscation
}
}
System.out.println("Found " + constants.size() + " constants");
for (Entry<Field, Integer> entry : constants.entrySet())
{
Field f = entry.getKey();
Integer v = entry.getValue();
System.out.println(f.getClassEntry().getName() + "." + f.getNameAndType().getName() + " -> " + v);
}
}
private static BigInteger modInverse(BigInteger val, int bits)

View File

@@ -11,9 +11,11 @@ public class UnusedMethods
{
public void run(ClassGroup group)
{
group.buildClassGraph();
Execution execution = new Execution(group);
execution.populateInitialMethods();
execution.run();
execution.run();
int i = 0;
for (ClassFile cf : group.getClasses())