Improve deobf whitelist
This commit is contained in:
@@ -128,7 +128,7 @@ options:
|
||||
--deobf - activate deobfuscation
|
||||
--deobf-min - min length of name, renamed if shorter, default: 3
|
||||
--deobf-max - max length of name, renamed if longer, default: 64
|
||||
--deobf-whitelist - space separated list of classes (full name) and packages (ends with '.*') to exclude from deobfuscation, default: android.support.v4.* android.support.v7.* android.support.v4.os.* android.support.annotation.Px androidx.core.os.* androidx.annotation.Px
|
||||
--deobf-whitelist - space separated list of classes (full name) and packages (ends with '.*') to exclude from deobfuscation
|
||||
--deobf-cfg-file - deobfuscation mappings file used for JADX auto-generated names (in the JOBF file format), default: same dir and name as input file with '.jobf' extension
|
||||
--deobf-cfg-file-mode - set mode for handling the JADX auto-generated names' deobfuscation map file:
|
||||
'read' - read if found, don't save (default)
|
||||
|
||||
@@ -28,7 +28,6 @@ import jadx.api.args.GeneratedRenamesMappingFileMode;
|
||||
import jadx.api.args.IntegerFormat;
|
||||
import jadx.api.args.ResourceNameSource;
|
||||
import jadx.api.args.UserRenamesMappingsMode;
|
||||
import jadx.core.deobf.conditions.DeobfWhitelist;
|
||||
import jadx.core.utils.exceptions.JadxArgsValidateException;
|
||||
import jadx.core.utils.files.FileUtils;
|
||||
|
||||
@@ -146,7 +145,7 @@ public class JadxCLIArgs {
|
||||
names = { "--deobf-whitelist" },
|
||||
description = "space separated list of classes (full name) and packages (ends with '.*') to exclude from deobfuscation"
|
||||
)
|
||||
protected String deobfuscationWhitelistStr = DeobfWhitelist.DEFAULT_STR;
|
||||
protected String deobfuscationWhitelistStr = "";
|
||||
|
||||
@Parameter(
|
||||
names = { "--deobf-cfg-file" },
|
||||
|
||||
@@ -32,7 +32,6 @@ import jadx.api.plugins.loader.JadxPluginLoader;
|
||||
import jadx.api.usage.IUsageInfoCache;
|
||||
import jadx.api.usage.impl.InMemoryUsageInfoCache;
|
||||
import jadx.core.deobf.DeobfAliasProvider;
|
||||
import jadx.core.deobf.conditions.DeobfWhitelist;
|
||||
import jadx.core.deobf.conditions.JadxRenameConditions;
|
||||
import jadx.core.plugins.PluginContext;
|
||||
import jadx.core.utils.files.FileUtils;
|
||||
@@ -110,7 +109,7 @@ public class JadxArgs implements Closeable {
|
||||
/**
|
||||
* List of classes and packages (ends with '.*') to exclude from deobfuscation
|
||||
*/
|
||||
private List<String> deobfuscationWhitelist = DeobfWhitelist.DEFAULT_LIST;
|
||||
private List<String> deobfuscationWhitelist = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Nodes alias provider for deobfuscator and rename visitor
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
package jadx.core.deobf.conditions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.core.dex.nodes.FieldNode;
|
||||
import jadx.core.dex.nodes.MethodNode;
|
||||
import jadx.core.dex.nodes.PackageNode;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
import jadx.core.utils.Utils;
|
||||
|
||||
public class DeobfWhitelist extends AbstractDeobfCondition {
|
||||
|
||||
public static final List<String> DEFAULT_LIST = Arrays.asList(
|
||||
"android.support.v4.*",
|
||||
"android.support.v7.*",
|
||||
"android.support.v4.os.*",
|
||||
"android.support.annotation.Px",
|
||||
"androidx.core.os.*",
|
||||
"androidx.annotation.Px");
|
||||
|
||||
public static final String DEFAULT_STR = Utils.listToString(DEFAULT_LIST, " ");
|
||||
|
||||
private final Set<String> packages = new HashSet<>();
|
||||
private final Set<String> classes = new HashSet<>();
|
||||
|
||||
@@ -42,7 +30,8 @@ public class DeobfWhitelist extends AbstractDeobfCondition {
|
||||
|
||||
@Override
|
||||
public Action check(PackageNode pkg) {
|
||||
if (packages.contains(pkg.getPkgInfo().getFullName())) {
|
||||
String pkgName = pkg.getPkgInfo().getFullName();
|
||||
if (packages.stream().anyMatch(pattern -> pattern.equals(pkgName) || pkgName.startsWith(pattern + "."))) {
|
||||
return Action.FORBID_RENAME;
|
||||
}
|
||||
return Action.NO_ACTION;
|
||||
@@ -53,6 +42,16 @@ public class DeobfWhitelist extends AbstractDeobfCondition {
|
||||
if (classes.contains(cls.getClassInfo().getFullName())) {
|
||||
return Action.FORBID_RENAME;
|
||||
}
|
||||
return Action.NO_ACTION;
|
||||
return check(cls.getPackageNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action check(FieldNode fld) {
|
||||
return check(fld.getParentClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action check(MethodNode mth) {
|
||||
return check(mth.getParentClass());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user