Don't create dest dirs if we're just detecting obfuscators

This commit is contained in:
de4dot 2011-11-02 02:38:20 +01:00
parent 2ddf6b00de
commit e3b767adcc

View File

@ -78,7 +78,7 @@ namespace de4dot {
} }
void detectObfuscators() { void detectObfuscators() {
foreach (var file in loadAllFiles()) { foreach (var file in loadAllFiles(true)) {
removeModule(file.ModuleDefinition); removeModule(file.ModuleDefinition);
} }
} }
@ -114,7 +114,7 @@ namespace de4dot {
saveAllFiles(allFiles); saveAllFiles(allFiles);
} }
IEnumerable<IObfuscatedFile> loadAllFiles() { IEnumerable<IObfuscatedFile> loadAllFiles(bool onlyScan = false) {
var loader = new DotNetFileLoader(new DotNetFileLoader.Options { var loader = new DotNetFileLoader(new DotNetFileLoader.Options {
PossibleFiles = options.Files, PossibleFiles = options.Files,
SearchDirs = options.SearchDirs, SearchDirs = options.SearchDirs,
@ -125,6 +125,7 @@ namespace de4dot {
RenameSymbols = options.RenameSymbols, RenameSymbols = options.RenameSymbols,
ControlFlowDeobfuscation = options.ControlFlowDeobfuscation, ControlFlowDeobfuscation = options.ControlFlowDeobfuscation,
KeepObfuscatorTypes = options.KeepObfuscatorTypes, KeepObfuscatorTypes = options.KeepObfuscatorTypes,
CreateDestinationDir = !onlyScan,
}); });
return loader.load(); return loader.load();
} }
@ -144,6 +145,7 @@ namespace de4dot {
public bool RenameSymbols { get; set; } public bool RenameSymbols { get; set; }
public bool ControlFlowDeobfuscation { get; set; } public bool ControlFlowDeobfuscation { get; set; }
public bool KeepObfuscatorTypes { get; set; } public bool KeepObfuscatorTypes { get; set; }
public bool CreateDestinationDir { get; set; }
} }
public DotNetFileLoader(Options options) { public DotNetFileLoader(Options options) {
@ -203,6 +205,7 @@ namespace de4dot {
} }
else { else {
Log.n("Detected {0} ({1})", deob.Name, file.Filename); Log.n("Detected {0} ({1})", deob.Name, file.Filename);
if (options.CreateDestinationDir)
createDirectories(Path.GetDirectoryName(file.NewFilename)); createDirectories(Path.GetDirectoryName(file.NewFilename));
return true; return true;
} }