fix unused methods again
This commit is contained in:
@@ -153,6 +153,7 @@ public class ClassFile
|
|||||||
if (m != null)
|
if (m != null)
|
||||||
return m;
|
return m;
|
||||||
|
|
||||||
|
// XXX is this necessary?
|
||||||
ClassFile parent = getParent();
|
ClassFile parent = getParent();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
return parent.findMethod(nat);
|
return parent.findMethod(nat);
|
||||||
@@ -172,15 +173,26 @@ public class ClassFile
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearClassGraph()
|
||||||
|
{
|
||||||
|
parent = null;
|
||||||
|
children.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void buildClassGraph()
|
public void buildClassGraph()
|
||||||
{
|
{
|
||||||
ClassFile other = getParent();
|
ClassFile other = group.findClass(super_class.getName());
|
||||||
if (other == null)
|
if (other != null)
|
||||||
return; // inherits from a class not in my group
|
{
|
||||||
|
this.parent = other;
|
||||||
this.parent = other;
|
parent.children.add(this);
|
||||||
parent.children.add(this);
|
}
|
||||||
|
|
||||||
|
for (ClassFile i : interfaces.getInterfaces())
|
||||||
|
{
|
||||||
|
i.children.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildInstructionGraph()
|
public void buildInstructionGraph()
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ public class ClassGroup
|
|||||||
|
|
||||||
public void buildClassGraph()
|
public void buildClassGraph()
|
||||||
{
|
{
|
||||||
|
for (ClassFile c : classes)
|
||||||
|
c.clearClassGraph();
|
||||||
|
|
||||||
for (ClassFile c : classes)
|
for (ClassFile c : classes)
|
||||||
c.buildClassGraph();
|
c.buildClassGraph();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class Deob
|
|||||||
new UnusedBlocks().run(group);
|
new UnusedBlocks().run(group);
|
||||||
|
|
||||||
// remove unused parameters
|
// remove unused parameters
|
||||||
new UnusedParameters().run(group);
|
//new UnusedParameters().run(group);
|
||||||
|
|
||||||
// remove jump obfuscation
|
// remove jump obfuscation
|
||||||
new Jumps().run(group);
|
new Jumps().run(group);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
|||||||
|
|
||||||
ins.push(ctx);
|
ins.push(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (info.sigterm.deob.Method method : getMethods())
|
for (info.sigterm.deob.Method method : getMethods())
|
||||||
{
|
{
|
||||||
ins.invoke(method);
|
ins.invoke(method);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.math.BigInteger;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import info.sigterm.deob.ClassFile;
|
import info.sigterm.deob.ClassFile;
|
||||||
import info.sigterm.deob.ClassGroup;
|
import info.sigterm.deob.ClassGroup;
|
||||||
@@ -129,6 +130,12 @@ public class ModularArithmeticDeobfuscation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Found " + constants.size() + " constants");
|
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)
|
private static BigInteger modInverse(BigInteger val, int bits)
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ public class UnusedMethods
|
|||||||
{
|
{
|
||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
{
|
{
|
||||||
|
group.buildClassGraph();
|
||||||
|
|
||||||
Execution execution = new Execution(group);
|
Execution execution = new Execution(group);
|
||||||
execution.populateInitialMethods();
|
execution.populateInitialMethods();
|
||||||
execution.run();
|
execution.run();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
|
|||||||
Reference in New Issue
Block a user