rename unique works
This commit is contained in:
28
pom.xml
28
pom.xml
@@ -1,13 +1,17 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>info.sigterm</groupId>
|
||||
<artifactId>deob</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>info.sigterm</groupId>
|
||||
<artifactId>deob</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -58,7 +58,8 @@ public class ANewArray extends Instruction
|
||||
@Override
|
||||
public void renameClass(ClassFile cf, String name)
|
||||
{
|
||||
if (clazz.getName().equals(cf.getName()))
|
||||
clazz = new Class(name);
|
||||
info.sigterm.deob.signature.Type t = new info.sigterm.deob.signature.Type(clazz.getName());
|
||||
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.signature.Signature;
|
||||
import info.sigterm.deob.signature.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class RenameUnique implements Deobfuscator
|
||||
{
|
||||
@@ -100,49 +102,38 @@ public class RenameUnique implements Deobfuscator
|
||||
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;
|
||||
|
||||
visited.add(cf);
|
||||
|
||||
Method m = cf.findMethod(method.getNameAndType());
|
||||
if (m != null && !m.isStatic())
|
||||
list.add(m);
|
||||
|
||||
findMethodDown(list, cf.getParent(), method);
|
||||
findMethod(list, visited, cf.getParent(), method);
|
||||
|
||||
for (ClassFile inter : cf.getInterfaces().getMyInterfaces())
|
||||
findMethodDown(list, 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);
|
||||
|
||||
findMethod(list, visited, inter, method);
|
||||
|
||||
for (ClassFile child : cf.getChildren())
|
||||
findMethodUp(list, child, method);
|
||||
findMethod(list, visited, child, method);
|
||||
}
|
||||
|
||||
private List<Method> getVirutalMethods(Method method)
|
||||
{
|
||||
List<Method> list = new ArrayList<>();
|
||||
|
||||
list.add(method);
|
||||
|
||||
if (method.isStatic())
|
||||
{
|
||||
list.add(method);
|
||||
return list;
|
||||
}
|
||||
|
||||
ClassFile classOfMethod = method.getMethods().getClassFile();
|
||||
findMethodDown(list, classOfMethod.getParent(), method);
|
||||
|
||||
for (ClassFile inter : classOfMethod.getInterfaces().getMyInterfaces())
|
||||
findMethodDown(list, inter, method);
|
||||
|
||||
for (ClassFile child : classOfMethod.getChildren())
|
||||
findMethodUp(list, child, method);
|
||||
|
||||
findMethod(list, new HashSet<ClassFile>(), method.getMethods().getClassFile(), method);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user