feat(cli): add option to change deobfuscation map file (#1117)
Signed-off-by: Skylot <skylot@gmail.com>
This commit is contained in:
@@ -86,8 +86,10 @@ 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-cfg-file - deobfuscation map file, default: same dir and name as input file with '.jobf' extension
|
||||
--deobf-rewrite-cfg - force to save deobfuscation map
|
||||
--deobf-use-sourcename - use source file name as class name alias
|
||||
--deobf-parse-kotlin-metadata - parse kotlin metadata to class and package names
|
||||
--rename-flags - what to rename, comma-separated, 'case' for system case sensitivity, 'valid' for java identifiers, 'printable' characters, 'none' or 'all' (default)
|
||||
--fs-case-sensitive - treat filesystem as case sensitive, false by default
|
||||
--cfg - save methods control flow graph to dot file
|
||||
|
||||
@@ -79,6 +79,12 @@ public class JadxCLIArgs {
|
||||
@Parameter(names = { "--deobf-max" }, description = "max length of name, renamed if longer")
|
||||
protected int deobfuscationMaxLength = 64;
|
||||
|
||||
@Parameter(
|
||||
names = { "--deobf-cfg-file" },
|
||||
description = "deobfuscation map file, default: same dir and name as input file with '.jobf' extension"
|
||||
)
|
||||
protected String deobfuscationMapFile;
|
||||
|
||||
@Parameter(names = { "--deobf-rewrite-cfg" }, description = "force to save deobfuscation map")
|
||||
protected boolean deobfuscationForceSave = false;
|
||||
|
||||
@@ -193,6 +199,7 @@ public class JadxCLIArgs {
|
||||
args.setRawCFGOutput(rawCfgOutput);
|
||||
args.setReplaceConsts(replaceConsts);
|
||||
args.setDeobfuscationOn(deobfuscationOn);
|
||||
args.setDeobfuscationMapFile(FileUtils.toFile(deobfuscationMapFile));
|
||||
args.setDeobfuscationForceSave(deobfuscationForceSave);
|
||||
args.setDeobfuscationMinLength(deobfuscationMinLength);
|
||||
args.setDeobfuscationMaxLength(deobfuscationMaxLength);
|
||||
@@ -271,6 +278,10 @@ public class JadxCLIArgs {
|
||||
return deobfuscationMaxLength;
|
||||
}
|
||||
|
||||
public String getDeobfuscationMapFile() {
|
||||
return deobfuscationMapFile;
|
||||
}
|
||||
|
||||
public boolean isDeobfuscationForceSave() {
|
||||
return deobfuscationForceSave;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class JadxArgs {
|
||||
private boolean deobfuscationForceSave = false;
|
||||
private boolean useSourceNameAsClassAlias = false;
|
||||
private boolean parseKotlinMetadata = false;
|
||||
private File deobfuscationMapFile = null;
|
||||
|
||||
private int deobfuscationMinLength = 0;
|
||||
private int deobfuscationMaxLength = Integer.MAX_VALUE;
|
||||
@@ -255,6 +256,14 @@ public class JadxArgs {
|
||||
this.deobfuscationMaxLength = deobfuscationMaxLength;
|
||||
}
|
||||
|
||||
public File getDeobfuscationMapFile() {
|
||||
return deobfuscationMapFile;
|
||||
}
|
||||
|
||||
public void setDeobfuscationMapFile(File deobfuscationMapFile) {
|
||||
this.deobfuscationMapFile = deobfuscationMapFile;
|
||||
}
|
||||
|
||||
public boolean isEscapeUnicode() {
|
||||
return escapeUnicode;
|
||||
}
|
||||
@@ -370,6 +379,7 @@ public class JadxArgs {
|
||||
+ ", skipResources=" + skipResources
|
||||
+ ", skipSources=" + skipSources
|
||||
+ ", deobfuscationOn=" + deobfuscationOn
|
||||
+ ", deobfuscationMapFile=" + deobfuscationMapFile
|
||||
+ ", deobfuscationForceSave=" + deobfuscationForceSave
|
||||
+ ", useSourceNameAsClassAlias=" + useSourceNameAsClassAlias
|
||||
+ ", parseKotlinMetadata=" + parseKotlinMetadata
|
||||
|
||||
@@ -6,12 +6,19 @@ import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.JadxArgs;
|
||||
import jadx.core.dex.info.ClassInfo;
|
||||
import jadx.core.dex.info.FieldInfo;
|
||||
import jadx.core.dex.info.MethodInfo;
|
||||
@@ -40,12 +47,18 @@ public class DeobfPresets {
|
||||
if (deobfMapPath == null) {
|
||||
return null;
|
||||
}
|
||||
LOG.info("Deobfuscation map file set to: {}", deobfMapPath);
|
||||
return new DeobfPresets(deobfMapPath);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Path getPathDeobfMapPath(RootNode root) {
|
||||
List<File> inputFiles = root.getArgs().getInputFiles();
|
||||
JadxArgs jadxArgs = root.getArgs();
|
||||
File deobfMapFile = jadxArgs.getDeobfuscationMapFile();
|
||||
if (deobfMapFile != null) {
|
||||
return deobfMapFile.toPath();
|
||||
}
|
||||
List<File> inputFiles = jadxArgs.getInputFiles();
|
||||
if (inputFiles.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
|
||||
static final Set<String> SKIP_FIELDS = new HashSet<>(Arrays.asList(
|
||||
"files", "input", "outDir", "outDirSrc", "outDirRes", "outputFormat",
|
||||
"deobfuscationMapFile",
|
||||
"verbose", "quiet", "logLevel",
|
||||
"printVersion", "printHelp"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user