rename unique works
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -10,4 +10,8 @@
|
|||||||
<version>4.0</version>
|
<version>4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
@@ -58,7 +58,8 @@ public class ANewArray extends Instruction
|
|||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void renameClass(ClassFile cf, String name)
|
||||||
{
|
{
|
||||||
if (clazz.getName().equals(cf.getName()))
|
info.sigterm.deob.signature.Type t = new info.sigterm.deob.signature.Type(clazz.getName());
|
||||||
clazz = new Class(name);
|
if (t.getType().equals("L" + cf.getName() + ";") || t.getType().equals(cf.getName()))
|
||||||
|
clazz = new Class(name, t.getArrayDims());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import info.sigterm.deob.attributes.code.Instructions;
|
|||||||
import info.sigterm.deob.pool.Class;
|
import info.sigterm.deob.pool.Class;
|
||||||
import info.sigterm.deob.signature.Signature;
|
import info.sigterm.deob.signature.Signature;
|
||||||
import info.sigterm.deob.signature.Type;
|
import info.sigterm.deob.signature.Type;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class RenameUnique implements Deobfuscator
|
public class RenameUnique implements Deobfuscator
|
||||||
{
|
{
|
||||||
@@ -100,48 +102,37 @@ public class RenameUnique implements Deobfuscator
|
|||||||
field.setName(name);
|
field.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findMethodDown(List<Method> list, ClassFile cf, Method method)
|
private void findMethod(List<Method> list, Set<ClassFile> visited, ClassFile cf, Method method)
|
||||||
{
|
{
|
||||||
if (cf == null)
|
if (cf == null || visited.contains(cf))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
visited.add(cf);
|
||||||
|
|
||||||
Method m = cf.findMethod(method.getNameAndType());
|
Method m = cf.findMethod(method.getNameAndType());
|
||||||
if (m != null && !m.isStatic())
|
if (m != null && !m.isStatic())
|
||||||
list.add(m);
|
list.add(m);
|
||||||
|
|
||||||
findMethodDown(list, cf.getParent(), method);
|
findMethod(list, visited, cf.getParent(), method);
|
||||||
|
|
||||||
for (ClassFile inter : cf.getInterfaces().getMyInterfaces())
|
for (ClassFile inter : cf.getInterfaces().getMyInterfaces())
|
||||||
findMethodDown(list, inter, method);
|
findMethod(list, visited, inter, method);
|
||||||
}
|
|
||||||
|
|
||||||
private void findMethodUp(List<Method> list, ClassFile cf, Method method)
|
|
||||||
{
|
|
||||||
Method m = cf.findMethod(method.getNameAndType());
|
|
||||||
if (m != null && !m.isStatic())
|
|
||||||
list.add(m);
|
|
||||||
|
|
||||||
for (ClassFile child : cf.getChildren())
|
for (ClassFile child : cf.getChildren())
|
||||||
findMethodUp(list, child, method);
|
findMethod(list, visited, child, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Method> getVirutalMethods(Method method)
|
private List<Method> getVirutalMethods(Method method)
|
||||||
{
|
{
|
||||||
List<Method> list = new ArrayList<>();
|
List<Method> list = new ArrayList<>();
|
||||||
|
|
||||||
list.add(method);
|
|
||||||
|
|
||||||
if (method.isStatic())
|
if (method.isStatic())
|
||||||
|
{
|
||||||
|
list.add(method);
|
||||||
return list;
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
ClassFile classOfMethod = method.getMethods().getClassFile();
|
findMethod(list, new HashSet<ClassFile>(), method.getMethods().getClassFile(), method);
|
||||||
findMethodDown(list, classOfMethod.getParent(), method);
|
|
||||||
|
|
||||||
for (ClassFile inter : classOfMethod.getInterfaces().getMyInterfaces())
|
|
||||||
findMethodDown(list, inter, method);
|
|
||||||
|
|
||||||
for (ClassFile child : classOfMethod.getChildren())
|
|
||||||
findMethodUp(list, child, method);
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user