private static void ActivateCommands(ArgumentParser parser, out bool autoDeob, out int token) { autoDeob = true; token = 0; foreach (var cmd in parser.ParsedCommands) { if (cmd is CmdVerbose) DeobfuscatorContext.Output = DeobfuscatorContext.OutputType.Verbose; if (cmd is CmdOut) DeobfuscatorContext.OutPath = cmd.UserInput.Substring(1); if (cmd is CmdFetchSignature) { autoDeob = false; Logger.VSLog(new Deobfuscator().FetchSignature()); } if (cmd is CmdDynamicStringDecryption) token = Int32.Parse(cmd.UserInput.Split(':')[1].Trim(), NumberStyles.HexNumber); if (cmd is CmdDebug) DeobfuscatorContext.Debug = true; if (cmd is CmdPluginPath) { DeobfuscatorContext.Options.LoadPlugins = true; DeobfuscatorContext.Options.PluginLoadPath = cmd.UserInput.Substring(9); } if (cmd is CmdPreferPlugins) { DeobfuscatorContext.Options.PreferPluginsOverBuiltinIdentifiers = true; DeobfuscatorContext.Options.LoadPlugins = true; } } }
private static void ActivateCommands(ArgumentParser parser, out bool autoDeob, out int token) { autoDeob = true; token = 0; foreach(var cmd in parser.ParsedCommands) { if (cmd is CmdVerbose) DeobfuscatorContext.Output = DeobfuscatorContext.OutputType.Verbose; if (cmd is CmdOut) DeobfuscatorContext.OutPath = cmd.UserInput.Substring(1); if (cmd is CmdFetchSignature) { autoDeob = false; var deob = new Deobfuscator(null); Logger.VSLog(deob.FetchSignature()); } if(cmd is CmdDynamicStringDecryption) { token = Int32.Parse(cmd.UserInput.Split(':')[1].Trim(), NumberStyles.HexNumber); } if (cmd is CmdDebug) DeobfuscatorContext.Debug = true; } }
private static void Main(string[] args) { var parser = new ArgumentParser(args); bool autoDeob; int token; if(!parser.ParseRawInput()){ Console.ReadLine(); Environment.Exit(-1); } AssemblyDefinition tmpAsm = null; try { tmpAsm = AssemblyDefinition.ReadAssembly(args[0]); } catch { Logger.VSLog("File is not a valid .NET PE file!"); Console.ReadLine(); Environment.Exit(-1); } DeobfuscatorContext.AsmDef = tmpAsm; Logger.VSLog(string.Concat("NETDeob ", Version, " BETA")); Logger.VSLog(""); DeobfuscatorContext.OutPath = DeobfuscatorContext.InPath + "_deobf.exe"; ActivateCommands(parser, out autoDeob, out token); DeobfuscatorContext.Options.UnhandledExceptionHandler = GlobalExcHandle; if (autoDeob) { var deob = new Deobfuscator(); deob.Deobfuscate(token == 0 ? null : new DynamicStringDecryptionContetx { AssociatedTokens = new List<int> { token }, DecryptionType = StringDecryption.Dynamic }); } Console.Read(); }