SKILL: Week 7: Defeating Windows Security Boundaries
Metadata
- Skill Name: windows-boundaries
- Folder: offensive-windows-boundaries
- Source: https://github.com/SnailSploit/offensive-checklist/blob/main/7-windows-boundaries.md
Description
Windows security boundary taxonomy and attack surface enumeration: kernel/user boundary, sandbox boundaries (LPAC, AppContainer), COM/RPC boundaries, hypervisor boundary, trust level transitions. Use when planning privilege escalation paths, sandbox escapes, or understanding Windows security architecture.
Trigger Phrases
Use this skill when the conversation involves any of:
Windows boundaries, security boundary, kernel user boundary, sandbox escape, AppContainer, LPAC, COM boundary, RPC boundary, hypervisor, Hyper-V, privilege escalation, trust level
Instructions for Claude
When this skill is active:
- Load and apply the full methodology below as your operational checklist
- Follow steps in order unless the user specifies otherwise
- For each technique, consider applicability to the current target/context
- Track which checklist items have been completed
- Suggest next steps based on findings
Full Methodology
Week 7: Defeating Windows Security Boundaries
Overview
created by AnotherOne from @Pwn3rzs Telegram channel.
Week 6 taught you how mitigations work defensively. You'll learn to bypass the OS security policies and features that prevent your code from running, your processes from accessing protected resources, and your actions from being logged. This is distinct from Week 8, which teaches you how to bypass exploit mitigations (DEP, ASLR, CFG) once your code is already running.
Week 7 vs Week 8 - The Key Distinction:
- Week 7 answers: "Can my code execute at all?" - bypass AMSI, WDAC, ASR, AppContainers, integrity levels, PPL, ETW telemetry
- Week 8 answers: "Can my exploit succeed?" - bypass DEP, ASLR, stack cookies, CFG/XFG, heap safe-unlinking
This Week's Focus:
- Offensive reconnaissance and mitigation fingerprinting
- AMSI bypass and script-based attack techniques
- Protected Process Light (PPL) exploitation
- Sandbox, integrity level, and AppContainer bypass
- WDAC and Attack Surface Reduction (ASR) bypass
- ETW manipulation and telemetry blinding
- Kernel driver interaction fundamentals (preparation for Week 11)
Prerequisites:
- Completed Week 6: Understanding Modern Windows Mitigations
- Week 5: Basic exploitation techniques (stack overflow, ROP, heap)
- Familiarity with WinDbg, x64dbg, and IDA/Ghidra
- C/C++, Python, and assembly knowledge
Week 7 Deliverables
By the end of this week, you should have completed:
- Recon Tool: Built a mitigation fingerprinting tool
- AMSI Bypass: Implemented working AMSI bypass techniques
- PPL Research: Documented PPL bypass vectors
- Sandbox Escape: Bypassed AppContainer or integrity level restrictions
- WDAC/ASR Bypass: Demonstrated at least one WDAC and one ASR bypass
- ETW Blinding: Implemented ETW provider patching to suppress telemetry
- Driver IOCTL Lab: Loaded a test driver, sent an IOCTL, set a kernel breakpoint (Week 11 prep)
Day 1: Offensive Reconnaissance & Mitigation Fingerprinting
- Goal: Master target enumeration - fingerprint system and process mitigations to identify attack vectors.
- Activities:
- Reading:
- Windows Exploit Protection - Official mitigation documentation
- Process Mitigation Policies
- Override Process Mitigations via Policy
- Online Resources:
- Tool Setup:
- Process Hacker / System Informer
- WinDbg Preview with mitigation inspection scripts
- PE-bear / pestudio for binary analysis
- Exercise:
- Build comprehensive mitigation scanner
- Enumerate all protected processes on target
- Identify legacy/unprotected binaries for exploitation
- Reading:
Deliverables
- Build a comprehensive mitigation scanner
- Fingerprint process-level protections remotely
- Identify unprotected/legacy binaries on target
- Map kernel mitigation status
Target Mitigation Landscape
┌─────────────────────────────────────────────────────────────────┐
│ Offensive Reconnaissance: What to Enumerate │
├─────────────────────────────────────────────────────────────────┤
│ │
│ SYSTEM-LEVEL PROCESS-LEVEL │
│ ───────────── ───────────── │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ VBS/HVCI │ │ DEP/NX │ │
│ │ WDAC/CI │ │ ASLR │ │
│ │ Secure Boot │ │ CFG/XFG │ │
│ │ Credential │ │ CET/Shadow │ │
│ │ Guard │ │ ACG │ │
│ │ KDP │ │ CIG │ │
│ │ KASLR │ │ Child Process│ │
│ └──────────────┘ └──────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ Determines: Determines: │
│ - Kernel exploit - Shellcode execution │
│ feasibility - Code injection │
│ - Driver loading - ROP requirements │
│ - Credential theft - Process hollowing │
│ │
│ ATTACK SURFACE MAPPING │
│ ───────────────────── │
│ ├── Unprotected legacy binaries (no ASLR/DEP) │
│ ├── Signed but vulnerable drivers (BYOVD) │
│ ├── Processes running without ACG/CFG │
│ └── Kernel version -> known vulnerabilities │
│ │
└─────────────────────────────────────────────────────────────────┘
Mitigation Scanner
This scanner enumerates security boundaries on a Windows target. Why this matters: Before exploiting a target, you need to know which mitigations are active.
// unified_recon.c
// Combines system, process, binary, and policy analysis
// Compile: cl src\unified_recon.c /Fe:bin\unified_recon.exe advapi32.lib
#include <windows.h>
#include <stdio.h>
#include <tlhelp32.h>
// PE DLL Characteristics flags
#define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
#define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
#define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
void CheckSystemMitigations() {
printf("\n=== SYSTEM-LEVEL MITIGATIONS ===\n\n");
// Check VBS/HVCI via registry (more reliable than WMI)
printf("[*] Checking VBS/HVCI status...\n");
HKEY hKey;
DWORD vbsEnabled = 0, hvciEnabled = 0;
DWORD size = sizeof(DWORD);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\DeviceGuard", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
RegQueryValueExA(hKey, "EnableVirtualizationBasedSecurity", NULL, NULL, (LPBYTE)&vbsEnabled, &size);
RegCloseKey(hKey);
}
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\DeviceGuard\\Scenarios\\HypervisorEnforcedCodeIntegrity",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
RegQueryValueExA(hKey, "Enabled", NULL, NULL, (LPBYTE)&hvciEnabled, &size);
RegCloseKey(hKey);
}
printf(" VBS: %s\n", vbsEnabled ? "ENABLED" : "Disabled");
printf(" HVCI: %s\n", hvciEnabled ? "ENABLED" : "Disabled");
if (hvciEnabled) {
printf(" [!] HVCI blocks unsigned kernel drivers\n");
printf(" [*] Attack: Need signed vulnerable driver (BYOVD)\n");
} else {
printf(" [+] HVCI disabled - unsigned drivers can load\n");
}
// Check Secure Boot via firmware variable
printf("\n[*] Checking Secure Boot...\n");
DWORD secureBootEnabled = 0;
size = sizeof(DWORD);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\SecureBoot\\State",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
RegQueryValueExA(hKey, "UEFISecureBootEnabled", NULL, NULL, (LPBYTE)&secureBootEnabled, &size);
RegCloseKey(hKey);
printf(" Secure Boot: %s\n", secureBootEnabled ? "ENABLED" : "Disabled");
} else {
printf(" Secure Boot: Unable to determine (may not be UEFI)\n");
}
// Check KASLR status (kernel base randomization)
printf("\n[*] Checking KASLR (kernel base varies per boot)...\n");
printf(" Note: KASLR leaks restricted in Win 24H2+ without SeDebugPrivilege\n");
printf(" KASLR is enabled by default on modern Windows\n");
// Check Credential Guard
printf("\n[*] Checking Credential Guard...\n");
DWORD credGuard = 0;
size = sizeof(DWORD);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Lsa", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
RegQueryValueExA(hKey, "LsaCfgFlags", NULL, NULL, (LPBYTE)&credGuard, &size);
RegCloseKey(hKey);
if (credGuard & 1) {
printf(" Credential Guard: ENABLED\n");
printf(" [!] Mimikatz credential dumping will FAIL\n");
} else {
printf(" Credential Guard: Disabled\n");
printf(" [+] Mimikatz can dump credentials\n");
}
}
}
void CheckProcessMitigations(DWORD pid, const char* procName) {
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
if (!hProcess) return;
printf("\n[%s (PID: %d)]\n", procName, pid);
// DEP
PROCESS_MITIGATION_DEP_POLICY depPolicy = {0};
if (GetProcessMitigationPolicy(hProcess, ProcessDEPPolicy, &depPolicy, sizeof(depPolicy))) {
printf(" DEP: %s%s\n",
depPolicy.Enable ? "ON" : "OFF",
depPolicy.Permanent ? " (Permanent)" : "");
}
// ASLR
PROCESS_MITIGATION_ASLR_POLICY aslrPolicy = {0};
if (GetProcessMitigationPolicy(hProcess, ProcessASLRPolicy, &aslrPolicy, sizeof(aslrPolicy))) {
printf(" ASLR: BottomUp=%d HighEntropy=%d ForceRelocate=%d\n",
aslrPolicy.EnableBottomUpRandomization,
aslrPolicy.EnableHighEntropy,
aslrPolicy.EnableForceRelocateImages);
}
// ACG (Dynamic Code)
PROCESS_MITIGATION_DYNAMIC_CODE_POLICY acgPolicy = {0};
if (GetProcessMitigationPolicy(hProcess, ProcessDynamicCodePolicy, &acgPolicy, sizeof(acgPolicy))) {
printf(" ACG: %s\n", acgPolicy.ProhibitDynamicCode ? "ON (No dynamic code)" : "OFF");
}
// CFG
PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY cfgPolicy = {0};
if (GetProcessMitigationPolicy(hProcess, ProcessControlFlowGuardPolicy, &cfgPolicy, sizeof(cfgPolicy))) {
printf(" CFG: %s StrictMode=%d\n",
cfgPolicy.EnableControlFlowGuard ? "ON" : "OFF",
cfgPolicy.StrictMode);
}
CloseHandle(hProcess);
}
void FindWeakProcesses() {
printf("\n=== HUNTING WEAK PROCESSES ===\n");
printf("[*] Looking for processes WITHOUT mitigations (exploitation targets)...\n\n");
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe = { sizeof(pe) };
if (Process32First(hSnapshot, &pe)) {
do {
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
if (!hProc) continue;
PROCESS_MITIGATION_DEP_POLICY dep = {0};
PROCESS_MITIGATION_ASLR_POLICY aslr = {0};
PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY cfg = {0};
GetProcessMitigationPolicy(hProc, ProcessDEPPolicy, &dep, sizeof(dep));
GetProcessMitigationPolicy(hProc, ProcessASLRPolicy, &aslr, sizeof(aslr));
GetProcessMitigationPolicy(hProc, ProcessControlFlowGuardPolicy, &cfg, sizeof(cfg));
// Flag if missing critical mitigations
if (!dep.Enable || !aslr.EnableBottomUpRandomization || !cfg.EnableControlFlowGuard) {
printf("[!] WEAK: %s (PID %d) - DEP:%d ASLR:%d CFG:%d\n",
pe.szExeFile, pe.th32ProcessID,
dep.Enable, aslr.EnableBottomUpRandomization, cfg.EnableControlFlowGuard);
}
CloseHandle(hProc);
} while (Process32Next(hSnapshot, &pe));
}
CloseHandle(hSnapshot);
}
void EnumerateDrivers() {
printf("\n=== DRIVER ENUMERATION (BYOVD Targets) ===\n");
printf("[*] Enumerating loaded kernel drivers...\n\n");
// Query drivers via registry
HKEY hKey;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
DWORD index = 0;
char subKeyName[256];
DWORD subKeyLen;
int driverCount = 0;
printf("%-30s %-10s %s\n", "Driver Name", "Type", "Path");
printf("%-30s %-10s %s\n", "===========", "====", "====");
while (1) {
subKeyLen = sizeof(subKeyName);
if (RegEnumKeyExA(hKey, index++, subKeyName, &subKeyLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
break;
HKEY hSubKey;
char fullPath[512];
snprintf(fullPath, sizeof(fullPath), "SYSTEM\\CurrentControlSet\\Services\\%s", subKeyName);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, fullPath, 0, KEY_READ, &hSubKey) == ERROR_SUCCESS) {
DWORD type = 0;
DWORD size = sizeof(DWORD);
if (RegQueryValueExA(hSubKey, "Type", NULL, NULL, (LPBYTE)&type, &size) == ERROR_SUCCESS) {
// Type 1 = Kernel driver
if (type == 1) {
char imagePath[512] = {0};
size = sizeof(imagePath);
RegQueryValueExA(hSubKey, "ImagePath", NULL, NULL, (LPBYTE)imagePath, &size);
printf("%-30s %-10s %s\n", subKeyName, "Kernel", imagePath);
driverCount++;
if (driverCount >= 20) { // Limit output
printf("\n[*] Showing first 20 drivers. Total may be higher.\n");
break;
}
}
}
RegCloseKey(hSubKey);
}
}
RegCloseKey(hKey);
}
printf("\n[*] Check against vulnerable driver list:\n");
printf(" https://www.loldrivers.io/\n");
printf(" https://github.com/magicsword-io/LOLDrivers\n");
}
// XFG (eXtended Flow Guard) - finer-grained CFI than CFG
void CheckXFGStatus(HANDLE hProcess, const char* procName) {
/*
XFG (eXtended Flow Guard) Detection:
=====================================
XFG improves on CFG by using type-based hashes for indirect calls.
Detection methods:
1. Check PE header for XFG metadata
2. Look for __guard_xfg_* symbols
3. Check if process has XFG-aware imports
Attack implications:
- XFG makes CFG bypass harder
- Need type-compatible function for exploit
- Data-only attacks still work
*/
PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY cfgPolicy = {0};
if (GetProcessMitigationPolicy(hProcess, ProcessControlFlowGuardPolicy, &cfgPolicy, sizeof(cfgPolicy))) {
printf(" XFG Analysis:\n");
printf(" CFG Enabled: %s\n", cfgPolicy.EnableControlFlowGuard ? "YES" : "NO");
printf(" Export Suppression: %s\n", cfgPolicy.EnableExportSuppression ? "YES" : "NO");
printf(" Strict Mode: %s\n", cfgPolicy.StrictMode ? "YES" : "NO");
if (cfgPolicy.EnableControlFlowGuard && cfgPolicy.StrictMode) {
printf(" [!] Likely XFG-enabled (strict CFG + export suppression)\n");
printf(" [*] Attack: Need type-compatible gadgets for bypass\n");
}
}
}
void CheckCETShadowStack(HANDLE hProcess, const char* procName) {
/*
CET Shadow Stack Detection:
===========================
Hardware-enforced return address protection (Intel 11th gen+)
Shadow stack keeps copy of return addresses in protected memory.
ROP attacks fail because RET validates against shadow stack.
Bypass vectors:
1. JOP (Jump-Oriented Programming) - doesn't use RET
2. COP (Call-Oriented Programming)
3. Find code without CET (legacy binaries)
4. Disable CET via kernel exploit
*/
PROCESS_MITIGATION_USER_SHADOW_STACK_POLICY cetPolicy = {0};
if (GetProcessMitigationPolicy(hProcess, ProcessUserShadowStackPolicy, &cetPolicy, sizeof(cetPolicy))) {
printf(" CET Shadow Stack:\n");
printf(" Enabled: %s\n", cetPolicy.EnableUserShadowStack ? "YES" : "NO");
printf(" Strict Mode: %s\n", cetPolicy.EnableUserShadowStackStrictMode ? "YES" : "NO");
printf(" Block Non-CET Binaries: %s\n", cetPolicy.BlockNonCetBinaries ? "YES" : "NO");
printf(" IP Validation: %s\n", cetPolicy.SetContextIpValidation ? "YES" : "NO");
if (cetPolicy.EnableUserShadowStack) {
printf(" [!] ROP will FAIL - shadow stack validates returns\n");
printf(" [*] Attack: Use JOP/COP or find non-CET modules\n");
if (!cetPolicy.BlockNonCetBinaries) {
printf(" [+] Non-CET binaries allowed - find legacy DLLs\n");
}
} else {
printf(" [+] CET disabled - ROP attacks viable\n");
}
} else {
printf(" CET Shadow Stack: Not supported or access denied\n");
}
}
void CheckARM64PAC() {
/*
ARM64 Pointer Authentication (PAC):
====================================
Signs pointers with cryptographic signature in unused bits.
Available on ARM64 Windows 11 and ARM Linux/macOS.
PAC keys:
- APIA/APIB: Instruction pointers (return addresses)
- APDA/APDB: Data pointers
- APGA: Generic authentication
Bypass vectors:
1. PAC oracle to brute-force signature
2. Pointer substitution attacks
3. Find code path that doesn't validate
4. Kernel exploit to leak/forge keys
*/
printf("\n=== ARM64 PAC Detection ===\n");
#ifdef _M_ARM64
// Check if running on ARM64 Windows
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64) {
printf("[*] Running on ARM64 architecture\n");
// Check for PAC support via IsProcessorFeaturePresent
// PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE (32) indicates ARMv8.3+
if (IsProcessorFeaturePresent(32)) {
printf("[!] ARMv8.3+ detected - PAC likely supported\n");
printf("[*] Attack implications:\n");
printf(" - Return addresses are signed (PACIA/PACIB)\n");
printf(" - ROP gadgets need valid PAC signatures\n");
printf(" - Look for PAC signing oracles or key leaks\n");
}
}
#else
printf("[*] Not ARM64 - PAC not applicable\n");
printf("[*] To test ARM64 PAC: Use Windows on ARM or ARM Linux/macOS\n");
#endif
}
DWORD GetProcessIdByName(const char* processName) {
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
PROCESSENTRY32 pe = { sizeof(pe) };
if (Process32First(hSnapshot, &pe)) {
do {
if (_stricmp(pe.szExeFile, processName) == 0) {
DWORD pid = pe.th32ProcessID;
CloseHandle(hSnapshot);
return pid;
}
} while (Process32Next(hSnapshot, &pe));
}
CloseHandle(hSnapshot);
return 0;
}
void CheckKASANStatus() {
/*
Windows KASAN (Kernel Address Sanitizer):
=========================================
detects kernel memory bugs.
Impact on exploitation:
- UAF and OOB bugs trigger Bug Check 0x1F2
- Makes reliability testing harder
- Detects heap spray corruption
For researchers:
- Use KASAN to find bugs faster
- Production systems usually don't have it
*/
printf("\n=== Windows KASAN Detection ===\n");
// Check registry for KASAN enablement
HKEY hKey;
DWORD kasanEnabled = 0;
DWORD size = sizeof(DWORD);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Kernel",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
RegQueryValueExA(hKey, "KasanEnabled", NULL, NULL,
(LPBYTE)&kasanEnabled, &size);
RegCloseKey(hKey);
}
printf("[*] KASAN Status: %s\n", kasanEnabled ? "ENABLED" : "Disabled/Not configured");
if (kasanEnabled) {
printf("[!] KASAN is enabled - memory bugs will trigger BSOD\n");
printf("[*] This is likely a development/test system\n");
printf("[*] Exploitation reliability will be harder to achieve\n");
} else {
printf("[*] KASAN not enabled - standard exploitation applies\n");
printf("[*] UAF/OOB exploitation possible without immediate crash\n");
}
}
void CheckKernelCET() {
/*
Kernel-mode CET Shadow Stack:
=============================
Protects kernel return addresses from ROP attacks.
Impact:
- Kernel ROP chains will fail
- Need different primitive (JOP, data-only)
- BYOVD still works if driver doesn't use ROP
*/
printf("\n=== Kernel CET Shadow Stack ===\n");
// Query via NtQuerySystemInformation or check feature flags
// For now, use registry/build check
OSVERSIONINFOEXW osvi = { sizeof(osvi) };
typedef NTSTATUS(WINAPI* RtlGetVersion_t)(PRTL_OSVERSIONINFOW);
RtlGetVersion_t RtlGetVersion = (RtlGetVersion_t)GetProcAddress(
GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion");
RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi);
printf("[*] Build: %d\n", osvi.dwBuildNumber);
if (osvi.dwBuildNumber >= 22621) { // Win11 22H2+
printf("[*] Build supports kernel CET\n");
// Check via registry for hypervisor settings
HKEY hKey;
char cetEnabled[256] = {0};
DWORD size = sizeof(cetEnabled);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\kernel",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
if (RegQueryValueExA(hKey, "CetEnabled", NULL, NULL, (LPBYTE)cetEnabled, &size) == ERROR_SUCCESS) {
printf("[*] Kernel CET Registry: %s\n", cetEnabled);
}
RegCloseKey(hKey);
}
printf("\n[*] If kernel CET enabled:\n");
printf(" - Kernel ROP attacks blocked\n");
printf(" - Need JOP/data-only techniques\n");
printf(" - Or exploit driver that doesn't use ROP internally\n");
} else {
printf("[+] Build predates kernel CET - kernel ROP viable\n");
}
}
void CheckSmartAppControl() {
/*
Smart App Control (SAC):
========================
blocks untrusted applications.
States:
- 0: Off (disabled, cannot re-enable without reinstall)
- 1: On (enforcing, blocks untrusted apps)
- 2: Evaluation (learning mode)
Bypass vectors:
- Signed malware with valid certificates
- LNK file bypass (CVE-2024-38217)
- LOLBins (trusted Microsoft binaries)
- Script execution (PowerShell not blocked by default)
- DLL sideloading into trusted processes
*/
printf("\n=== Smart App Control (SAC) ===\n");
HKEY hKey;
DWORD sacState = 0;
DWORD size = sizeof(DWORD);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\CI\\Policy",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
if (RegQueryValueExA(hKey, "VerifiedAndReputablePolicyState", NULL, NULL,
(LPBYTE)&sacState, &size) == ERROR_SUCCESS) {
switch (sacState) {
case 0:
printf("[+] SAC: Disabled\n");
printf("[*] Unsigned executables can run freely\n");
break;
case 1:
printf("[!] SAC: ENABLED (Enforcing)\n");
printf("[!] Unsigned executables will be blocked\n");
printf("[*] Bypass vectors:\n");
printf(" - Use signed malware (valid code signing cert)\n");
printf(" - LNK file bypass (CVE-2024-38217)\n");
printf(" - LOLBins (MSBuild, InstallUtil, Regsvr32)\n");
printf(" - Script-based payloads (PowerShell + AMSI bypass)\n");
printf(" - DLL sideloading into trusted processes\n");
break;
case 2:
printf("[*] SAC: Evaluation Mode (Learning)\n");
printf("[*] May transition to enforcing - establish persistence now\n");
break;
default:
printf("[?] SAC: Unknown state (%d)\n", sacState);
}
} else {
printf("[*] SAC: Not available (Pre-22H2 or Server)\n");
}
RegCloseKey(hKey);
} else {
printf("[*] SAC: Not available (Pre-22H2 or Server)\n");
}
}
void CheckAdminProtection() {
/*
Administrator Protection:
=========================
Windows Hello for admin operations.
Impact:
- UAC bypass alone insufficient
- Need Windows Hello PIN/biometric credential
- Kernel-level bypass still works (BYOVD)
Bypass vectors:
- Windows Hello PIN extraction (NGC folder + DPAPI)
- Pre-authentication persistence (standard user)
- Kernel-level token manipulation (BYOVD)
- Physical access (offline registry modification)
- Social engineering (fake Windows Hello prompt)
*/
printf("\n=== Administrator Protection ===\n");
HKEY hKey;
DWORD adminProtection = 0;
DWORD size = sizeof(DWORD);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
RegQueryValueExA(hKey, "EnableAdminProtection", NULL, NULL,
(LPBYTE)&adminProtection, &size);
RegCloseKey(hKey);
if (adminProtection == 1) {
printf("[!] Administrator Protection: ENABLED\n");
printf("[!] Admin operations require Windows Hello authentication\n");
printf("[*] Bypass vectors:\n");
printf(" - Extract Windows Hello PIN (NGC folder + DPAPI key)\n");
printf(" - Pre-authentication persistence (standard user context)\n");
printf(" - Kernel-level bypass (BYOVD -> token manipulation)\n");
printf(" - Physical access (offline registry modification)\n");
printf(" - Social engineering (fake Windows Hello prompt)\n");
} else {
printf("[+] Administrator Protection: Disabled\n");
printf("[*] Standard UAC bypass techniques applicable\n");
}
} else {
printf("[*] Administrator Protection: Not available (Pre-24H2)\n");
}
}
void AnalyzePEFile(const char* filepath) {
/*
PE Binary Analysis:
===================
Check PE headers for security mitigations.
Flags checked:
- DYNAMIC_BASE: ASLR enabled
- HIGH_ENTROPY_VA: 64-bit ASLR with more entropy
- NX_COMPAT: DEP enabled (non-executable stack/heap)
- GUARD_CF: Control Flow Guard enabled
- NO_SEH: SEH removed (CFG requirement)
*/
HANDLE hFile = CreateFileA(filepath, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
printf("[-] Cannot open: %s\n", filepath);
return;
}
HANDLE hMapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (!hMapping) {
CloseHandle(hFile);
return;
}
LPVOID pBase = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
if (!pBase) {
CloseHandle(hMapping);
CloseHandle(hFile);
return;
}
PIMAGE_DOS_HEADER pDos = (PIMAGE_DOS_HEADER)pBase;
if (pDos->e_magic != IMAGE_DOS_SIGNATURE) {
UnmapViewOfFile(pBase);
CloseHandle(hMapping);
CloseHandle(hFile);
return;
}
PIMAGE_NT_HEADERS pNt = (PIMAGE_NT_HEADERS)((BYTE*)pBase + pDos->e_lfanew);
if (pNt->Signature != IMAGE_NT_SIGNATURE) {
UnmapViewOfFile(pBase);
CloseHandle(hMapping);
CloseHandle(hFile);
return;
}
WORD dllChars = pNt->OptionalHeader.DllCharacteristics;
printf("\n[%s]\n", filepath);
printf(" ASLR (DYNAMICBASE): %s\n", (dllChars & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) ? "YES" : "NO <<<");
printf(" High Entropy ASLR: %s\n", (dllChars & IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA) ? "YES" : "NO");
printf(" DEP (NX_COMPAT): %s\n", (dllChars & IMAGE_DLLCHARACTERISTICS_NX_COMPAT) ? "YES" : "NO <<<");
printf(" CFG (GUARD_CF): %s\n", (dllChars & IMAGE_DLLCHARACTERISTICS_GUARD_CF) ? "YES" : "NO <<<");
printf(" NO_SEH: %s\n", (dllChars & IMAGE_DLLCHARACTERISTICS_NO_SEH) ? "YES" : "NO");
// Flag as potential target if missing protections
if (!(dllChars & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) ||
!(dllChars & IMAGE_DLLCHARACTERISTICS_NX_COMPAT) ||
!(dllChars & IMAGE_DLLCHARACTERISTICS_GUARD_CF)) {
printf(" >>> POTENTIAL EXPLOITATION TARGET <<<\n");
}
UnmapViewOfFile(pBase);
CloseHandle(hMapping);
CloseHandle(hFile);
}
int main(int argc, char* argv[]) {
CheckSystemMitigations();
CheckSmartAppControl();
CheckAdminProtection();
FindWeakProcesses();
EnumerateDrivers();
CheckKernelCET();
CheckKASANStatus();
CheckARM64PAC();
// Check specific high-value target
DWORD lsassPid = GetProcessIdByName("lsass.exe");
if (lsassPid) {
HANDLE hLsass = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, lsassPid);
if (hLsass) {
printf("\n[LSASS.EXE Analysis]\n");
CheckXFGStatus(hLsass, "lsass.exe");
CheckCETShadowStack(hLsass, "lsass.exe");
CloseHandle(hLsass);
}
}
// Binary analysis if files provided
if (argc > 1) {
printf("\n");
for (int i = 1; i < argc; i++) {
AnalyzePEFile(argv[i]);
}
}
printf("\n=== ATTACK PATH RECOMMENDATIONS ===\n");
printf("1. If VBS/HVCI disabled: Kernel exploitation viable\n");
printf("2. If weak processes found: Target for injection\n");
printf("3. If vulnerable drivers present: BYOVD path available\n");
printf("4. If Credential Guard off: Mimikatz will work\n");
printf("5. If CET disabled: ROP attacks work\n");
printf("6. If CET enabled: Use JOP/COP or find non-CET binaries\n");
printf("7. If XFG strict: Need type-compatible function gadgets\n");
printf("8. On ARM64 with PAC: Look for signing oracles\n");
printf("9. If SAC enabled: Use signed malware or LOLBins\n");
printf("10. If Admin Protection on: Extract Windows Hello PIN or use kernel bypass\n");
return 0;
}
Usage Examples:
# System-wide reconnaissance
.\bin\unified_recon.exe
# Include binary analysis
.\bin\unified_recon.exe bin\vuln_capstone_weak.exe bin\vuln_capstone_hard.exe
# Analyze specific binaries
.\bin\unified_recon.exe C:\Windows\System32\notepad.exe C:\Windows\System32\calc.exe
Linux Mitigation Fingerprinting
Linux systems have their own set of security boundaries that differ significantly from Windows. This scanner checks kernel hardening features. Why this matters: io_uring is a game-changer for Linux exploitation - it allows file and network operations without triggering seccomp filters, making it a powerful sandbox escape vector.
#!/bin/bash
# ~/offensive_lab/linux_mitigation_scanner.sh
# Fingerprints kernel hardening, sandboxing, and exploit mitigations
cat << 'BANNER'
Linux Mitigation Scanner - Offensive Recon
BANNER
echo ""
echo "=== KERNEL HARDENING STATUS ==="
echo ""
# KASLR
echo -n "[*] KASLR: "
if cat /proc/kallsyms 2>/dev/null | head -1 | grep -q "0000000000000000"; then
echo "ENABLED (symbols zeroed for non-root)"
echo " Attack: Need info leak or /dev/mem access"
else
echo "READABLE or disabled"
if [ "$(id -u)" = "0" ]; then
KBASE=$(cat /proc/kallsyms | head -1 | awk '{print $1}')
echo " Kernel base: 0x$KBASE"
fi
fi
# SMEP/SMAP (CPU features)
echo -n "[*] SMEP: "
if grep -q smep /proc/cpuinfo 2>/dev/null; then
echo "SUPPORTED (blocks user-space code exec from kernel)"
echo " Attack: ROP/JOP required, can't jump to userspace shellcode"
else
echo "NOT SUPPORTED - ret2user viable"
fi
echo -n "[*] SMAP: "
if grep -q smap /proc/cpuinfo 2>/dev/null; then
echo "SUPPORTED (blocks user-space data access from kernel)"
echo " Attack: Need copy_from_user or disable SMAP (popf gadget)"
else
echo "NOT SUPPORTED - can access userspace data from kernel"
fi
# Kernel lockdown
echo -n "[*] Kernel Lockdown: "
if [ -f /sys/kernel/security/lockdown ]; then
LOCKDOWN=$(cat /sys/kernel/security/lockdown)
echo "$LOCKDOWN"
if [[ "$LOCKDOWN" == *"[integrity]"* ]] || [[ "$LOCKDOWN" == *"[confidentiality]"* ]]; then
echo " Attack: /dev/mem, kexec, BPF restricted"
fi
else
echo "NOT CONFIGURED"
fi
# KFENCE (production memory safety)
echo -n "[*] KFENCE: "
if [ -d /sys/kernel/debug/kfence ] 2>/dev/null; then
echo "ENABLED (sampling memory safety)"
echo " Impact: Some UAF/OOB bugs will be detected"
else
echo "Not detected"
fi
echo ""
echo "=== SANDBOX/LSM STATUS ==="
echo ""
# Check active LSMs
echo "[*] Active LSMs:"
if [ -f /sys/kernel/security/lsm ]; then
cat /sys/kernel/security/lsm
fi
# Landlock (unprivileged sandboxing)
echo ""
echo -n "[*] Landlock LSM: "
if [ -f /sys/kernel/security/landlock/abi_version ]; then
VERSION=$(cat /sys/kernel/security/landlock/abi_version)
echo "AVAILABLE (ABI version $VERSION)"
echo " Applications can sandbox themselves without root"
echo " Check: strace -e landlock_create_ruleset app"
else
echo "NOT AVAILABLE"
fi
# eBPF LSM
echo -n "[*] eBPF LSM: "
if grep -q bpf /sys/kernel/security/lsm 2>/dev/null; then
echo "ENABLED"
echo " [!] Programs can attach BPF LSM hooks"
echo " Check for security policy BPF programs"
else
echo "Not in active LSMs"
fi
# BPF restrictions
echo "[*] BPF Unprivileged Access:"
UNPRIVBPF=$(cat /proc/sys/kernel/unprivileged_bpf_disabled 2>/dev/null)
case $UNPRIVBPF in
0) echo " ALLOWED - unprivileged users can load BPF" ;;
1) echo " DISABLED - requires CAP_BPF/root" ;;
2) echo " PERMANENTLY DISABLED" ;;
*) echo " Unknown ($UNPRIVBPF)" ;;
esac
echo ""
echo "=== SECCOMP & io_uring STATUS ==="
echo ""
# Check seccomp support
echo -n "[*] Seccomp: "
if grep -q SECCOMP /proc/self/status; then
SECCOMP_MODE=$(grep Seccomp /proc/self/status | awk '{print $2}')
case $SECCOMP_MODE in
0) echo "AVAILABLE (this shell not filtered)" ;;
1) echo "STRICT MODE (only read/write/exit)" ;;
2) echo "FILTER MODE (BPF filtering active)" ;;
esac
else
echo "NOT AVAILABLE"
fi
# io_uring - THE HOT ATTACK SURFACE
echo ""
echo "[*] io_uring Status:"
echo " [!!!] io_uring BYPASSES seccomp filters!"
echo ""
IOURING_DISABLED=$(cat /proc/sys/kernel/io_uring_disabled 2>/dev/null)
case $IOURING_DISABLED in
0)
echo " io_uring: FULLY ENABLED"
echo " [!] All users can use io_uring - seccomp bypass possible!"
echo " Attack: Use io_uring ops instead of blocked syscalls"
;;
1)
echo " io_uring: RESTRICTED (CAP_SYS_RESOURCE required)"
echo " Unprivileged io_uring disabled"
;;
2)
echo " io_uring: FULLY DISABLED"
echo " Hardened against io_uring attacks"
;;
*)
# Check if io_uring exists another way
if [ -e /proc/self/fdinfo ] && ls /proc/*/fdinfo 2>/dev/null | head -1 | xargs grep -l io_uring 2>/dev/null; then
echo " io_uring: ENABLED (processes using it detected)"
else
echo " io_uring: Status unclear, test with io_uring_setup syscall"
fi
;;
esac
echo ""
echo "=== USER NAMESPACE STATUS ==="
echo ""
# User namespaces - critical for container escapes
USERNS=$(cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null || \
cat /proc/sys/user/max_user_namespaces 2>/dev/null)
echo -n "[*] Unprivileged User Namespaces: "
if [ "$USERNS" = "0" ]; then
echo "DISABLED"
echo " Container escapes via userns harder"
echo " Many sandbox escapes blocked"
else
echo "ENABLED"
echo " [!] Can create user namespaces without root"
echo " Attack: userns -> mount namespace -> escape attempts"
fi
echo ""
echo "=== ATTACK PATH RECOMMENDATIONS ==="
echo ""
echo "Linux-Specific Attack Vectors:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [ "$IOURING_DISABLED" != "2" ] && [ "$IOURING_DISABLED" != "1" ]; then
echo "[!] io_uring ENABLED: Use for seccomp bypass"
echo " -> io_uring ops don't trigger seccomp filters"
echo " -> Read/write files, network I/O without syscalls"
fi
if [ "$USERNS" != "0" ]; then
echo "[!] User namespaces ENABLED: Container escape vector"
echo " -> Create privileged namespace context"
echo " -> Pair with other vulns for escape"
fi
if ! grep -q bpf /sys/kernel/security/lsm 2>/dev/null; then
echo "[+] No eBPF LSM: Traditional evasion techniques work"
fi
echo ""
echo "[*] Run this on target to identify attack surface"
echo "[*] For containers: also check cgroup escapes, /proc mounts"
#!/usr/bin/env python3
# ~/offensive_lab/linux_recon.py
import os
import subprocess
from pathlib import Path
class LinuxMitigationScanner:
def __init__(self):
self.results = {}
def check_kaslr(self):
"""Check KASLR status"""
try:
with open('/proc/kallsyms', 'r') as f:
first_line = f.readline()
if first_line.startswith('0000000000000000'):
return {'enabled': True, 'note': 'Symbols hidden from non-root'}
else:
addr = first_line.split()[0]
return {'enabled': True, 'kernel_base': f'0x{addr}'}
except PermissionError:
return {'enabled': True, 'note': 'Cannot read kallsyms'}
except:
return {'enabled': 'unknown'}
def check_cpu_features(self):
"""Check SMEP
…(truncated)