Exemple #1
0
        public Deobfuscator(DeobfuscatorContext context)
        {
            Globals.DeobContext = context;

            Globals.Bugster = new BugReporter("150fa190dbb7a61815b4103fee172550", new NETDeobExceptionFormatter());
            AppDomain.CurrentDomain.UnhandledException += Globals.Bugster.UnhandledExceptionHandler;
            Globals.Bugster.ReportCompleted += (o, e) =>
                                                   {
                                                       if (e.WasSuccesful)
                                                       {
                                                           Console.WriteLine(
                                                               "\nAn unhandled exception have occured and caused NETDeob to terminate!\n\nAn automatic report have been sent to the author.");
                                                           Console.ReadLine();
                                                           Environment.Exit(-1);
                                                       }
                                                       else
                                                       {
                                                           Console.WriteLine("Contact author!");
                                                           Console.ReadLine();
                                                           Environment.Exit(-1);
                                                       }
                                                   };

            _options = Globals.DeobContext.Options = Globals.DeobContext.Options ?? new DeobfuscatorOptions();
        }
Exemple #2
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
                return;

            var ctx = new DeobfuscatorContext();
            var optionSet = new OptionSet()
                                {
                                    {"st=|strtok=", t =>
                                                            {
                                                                if (t != null)
                                                                   ctx.DynStringCtx = new DeobfuscatorContext.DynamicStringDecryptionContext
                                                                                                           {
                                                                                                               AssociatedToken = Int32.Parse(t, NumberStyles.HexNumber),
                                                                                                               DecryptionType = DeobfuscatorContext.StringDecryption.Dynamic
                                                                                                           };
                                                            }},
                                     {"v|verbose", v =>
                                                        {
                                                           if (v != null)
                                                               ctx.Output = DeobfuscatorContext.OutputType.Verbose;
                                                         }},
                                     { "d|debug", d =>
                                                     {
                                                          if(d != null)
                                                             ctx.Debug = true;
                                                     }},

                                     {"fsig|fetchsignature", fs =>
                                                                {
                                                                    if(fs != null)
                                                                    {
                                                                        Console.WriteLine(new Deobfuscator(ctx).FetchSignature());
                                                                        Console.ReadLine();
                                                                        Environment.Exit(-1);
                                                                    }
                                                                }},
                                     {"o=|output=", o =>
                                                                {
                                                                    if (o != null)
                                                                        ctx.OutPath = o;
                                                                }},
                                     {"pp=|pluginpath=", pp =>
                                                                {
                                                                    if(pp != null)
                                                                    {
                                                                        ctx.Options = new DeobfuscatorOptions();
                                                                        ctx.Options.LoadPlugins = true;
                                                                        ctx.Options.PluginLoadPath = pp;
                                                                    }
                                                                }},
                                     {"prp|preferplugins", prp =>
                                                                 {
                                                                     if(prp != null)
                                                                     {
                                                                         ctx.Options.LoadPlugins = true;
                                                                         ctx.Options.PreferPluginsOverBuiltinIdentifiers = true;
                                                                     }
                                                                 }}
                                };

            AssemblyDefinition tmpAsm = null;

            try
            {
                tmpAsm = AssemblyDefinition.ReadAssembly((ctx.InPath = args[0]));
            }
            catch
            {
                Console.WriteLine("File is not a valid .NET PE file!");
                Console.ReadLine();
                Environment.Exit(-1);
            }

            ctx.AsmDef = tmpAsm;

            Console.WriteLine(string.Concat("NETDeob ", Version, " BETA"));
            Console.WriteLine();

            ctx.OutPath = ctx.OutPath ?? Path.Combine(Path.GetDirectoryName(ctx.InPath), tmpAsm.Name.Name + "_deobf.exe");

            try
            {
                optionSet.Parse(args.FromIndex(1));
            }
            catch (OptionException e)
            {
                Console.WriteLine("Invalid parameters supplied!");
                Console.ReadLine();
                Environment.Exit(-1);
            }

            var deob = new Deobfuscator(ctx);
            deob.Deobfuscate();

            Console.Read();
        }