Beispiel #1
0
 static void Main(string[] args)
 {
     string file = args[0];
     List<TaskID> taskList = new List<TaskID>();
     Preset preset = Preset.none;
     if (args.Length > 1)
     {
         for (int i = 1; i < args.Length; i++)
         {
             string arg = args[i];
             if (arg == "-min")
                 preset = Preset.min;
             else if (arg == "-mid")
                 preset = Preset.mid;
             else if (arg == "-max")
                 preset = Preset.max;
             else
             {
                 if (arg == "-invalidMd")
                     taskList.Add(TaskID.InvalidMD);
                 if (arg == "-ren")
                     taskList.Add(TaskID.Ren);
                 if (arg == "-antiDbg")
                     taskList.Add(TaskID.AntiDebug);
                 if (arg == "-stringEnc")
                     taskList.Add(TaskID.StringEnc);
                 if (arg == "-ctrlFlow")
                     taskList.Add(TaskID.CtrlFlow);
             }
         }
     }
     else
         preset = Preset.max;
     Context ctx;
     if (preset == Preset.none)
         ctx = new Context(file, taskList);
     else
         ctx = new Context(file, preset);
     Processor.LogInfo l = LogInfo;
     Processor.LogWarn w = LogWarn;
     Processor.LogErr e = LogErr;
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("                       Denvelope obfuscator 2014 - 2015" + Environment.NewLine);
     Console.ResetColor();
     Console.WriteLine("File: " + file + Environment.NewLine);
     Processor.Process(ctx, l, w, e);
     Console.WriteLine("Finished.");
     Console.Read();
 }
Beispiel #2
0
 public static string Process(Context ctx, LogInfo info, LogWarn war, LogErr err)
 {
     try
     {
         string startobf = "Starting ";
         ModuleDefMD module = ModuleDefMD.Load(ctx.FileName);
         module.GlobalType.FindOrCreateStaticConstructor();
         foreach (TaskID task in ctx.TasksList)
         {
             switch (task)
             {
                 case AntiDebugTask.ID:
                     {
                         info(startobf + "Anti-Debug Task...");
                         AntiDebugTask.Execute(module);
                     } break;
                 case StringEncodingTask.ID:
                     {
                         info(startobf + "String encoding Task...");
                         StringEncodingTask.Execute(module);
                     } break;
                 case ControlFlowTask.ID:
                     {
                         info(startobf + "Control Flow Task...");
                         ControlFlowTask.Execute(module);
                     } break;
                case InvalidMDTask.ID:
                     {
                         info(startobf + "Invalid Metadata Task...");
                         InvalidMDTask.Execute(module);
                     } break;
                 case RenameTask.ID:
                     RenameTask.IsObfuscationActive = true; break;
             }
         }
         info(startobf + "Rename Task..." + Environment.NewLine);
             RenameTask.Execute(module);
         module.Write(ctx.NewPath, new ModuleWriterOptions() { Listener = NETUtils.listener });
         return ctx.NewPath;
     }
     catch (Exception ex)
     {
         err(ex.Message);
         return "";
     }
 }