Commit a9251de1 authored by Skylot's avatar Skylot

deobf: prevents overlaping of class names and packages (#335)

parent 56798e71
......@@ -2,7 +2,9 @@ package jadx.core.deobf;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
......@@ -48,6 +50,7 @@ public class Deobfuscator {
private final PackageNode rootPackage = new PackageNode("");
private final Set<String> pkgSet = new TreeSet<>();
private final Set<String> reservedClsNames = new HashSet<>();
private final int maxLength;
private final int minLength;
......@@ -89,6 +92,11 @@ public class Deobfuscator {
private void preProcess() {
for (DexNode dexNode : dexNodes) {
for (ClassNode cls : dexNode.getClasses()) {
Collections.addAll(reservedClsNames, cls.getPackage().split("\\."));
}
}
for (DexNode dexNode : dexNodes) {
for (ClassNode cls : dexNode.getClasses()) {
preProcessClass(cls);
}
}
......@@ -312,9 +320,11 @@ public class Deobfuscator {
if (alias != null) {
clsMap.put(classInfo, new DeobfClsInfo(this, cls, pkg, alias));
} else {
if (!clsMap.containsKey(classInfo)
&& shouldRename(classInfo.getShortName())) {
makeClsAlias(cls);
if (!clsMap.containsKey(classInfo)) {
String clsShortName = classInfo.getShortName();
if (shouldRename(clsShortName) || reservedClsNames.contains(clsShortName)) {
makeClsAlias(cls);
}
}
}
for (ClassNode innerCls : cls.getInnerClasses()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment