Пример #1
0
 private void Protect() //The 'protect' function.
 {
     Invoke((MethodInvoker)(() => StatusLbl.Text = "Obfuscating..."));
     Invoke((MethodInvoker)(() => StatusLbl.ForeColor = Color.Yellow));
     Invoke((MethodInvoker)(() => SetControls(false)));
     try
     {
         MainClass.MainModule = ModuleDefMD.Load(File.ReadAllBytes(MainClass.Settings.AssemblyPath));
         MainClass.AntiILDasm.Execute();
         MainClass.Renaming.RenameNamespaces();
         MainClass.Renaming.RenameTypes();
         MainClass.Renaming.RenameMethods();
         MainClass.Renaming.RenameFields();
         MainClass.Renaming.RenameProperties();
         MainClass.StringEcnryption.Encrypt();
         //This part is very important. If the anti tampering is enabled then the type of the custom attribute will be with a radnom namespace and type name.
         //Making it harder for a deobfuscator to detect it. Or else it will have its normal namespace and type name.
         if (!MainClass.Settings.AntiTampering)
         {
             Watermarking.Watermark("UnityObfuscator.Attributes", "ObfuscatedByAttribute", "Unity3D Obfuscator by AkyrosXD");
         }
         else
         {
             Watermarking.Watermark(string.Concat(GlobalStrings.RandomString, ".", GlobalStrings.RandomString), string.Concat(GlobalStrings.RandomString, "Attribute"), "Obfuscated by [Unity3D Obfuscator by AkyrosXD]");
         }
         MainClass.AntiTampering.ExecuteAntiTampering();
         SaveProtectedAssembly();
         Invoke((MethodInvoker)(() => StatusLbl.Text = "Obfuscation Completed!"));
         Invoke((MethodInvoker)(() => StatusLbl.ForeColor = Color.LimeGreen));
         Invoke((MethodInvoker)(() => SetControls(true)));
         MainClass.ObfuscationThread = null;
     }
     catch (Exception ex)
     {
         if (ex.Message.Equals("Thread was being aborted."))
         {
             Invoke((MethodInvoker)(() => CancelBtn.Visible = false));
             MainClass.ObfuscationThread = null;
             Invoke((MethodInvoker)(() => SetControls(true)));
             return;
         }
         Invoke((MethodInvoker)(() => StatusLbl.Text = "Obfuscation Failed!"));
         Invoke((MethodInvoker)(() => StatusLbl.ForeColor = Color.Red));
         Invoke((MethodInvoker)(() => SetControls(true)));
         NativeWindow nativeWindow = new NativeWindow();
         nativeWindow.AssignHandle(GetForegroundWindow());
         MessageBox.Show(nativeWindow, "An error occurred!\nException:\n" + ex.Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
         MainClass.ObfuscationThread = null;
     }
 }
Пример #2
0
        //Anti tampering class.
        public void ExecuteAntiTampering()
        {
            if (!MainClass.Settings.AntiTampering)
            {
                return;
            }
            string typeName = "╬.☻♥♦♣♠•◘○";
            string value    = GlobalStrings.RandomString;

            Watermarking.AddCustomAttributeToAssembly(string.Empty, typeName, value);
            Watermarking.RemoveAttributeType(typeName);
            //The way the anti tampering works is by adding a custom attribute and removing its type directly from the assembly instead of deleting the attribute from the assembly first.
            //WARNING! Anti tampering may not work in some assemblies.
            //I figured this method by accident, lol!
        }