NtSystemDebugControl
Enruta solicitudes estilo depurador de kernel (R/W de kernel, espacio de control, breakpoints, profiler) seleccionadas por la enum SysDbgCommand.
Prototipo
NTSTATUS NtSystemDebugControl( SYSDBG_COMMAND Command, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG ReturnLength );
Argumentos
| Name | Type | Dir | Description |
|---|---|---|---|
| Command | SYSDBG_COMMAND | in | Selector de operación: SysDbgReadVirtual, SysDbgWriteVirtual, SysDbgReadPhysical, SysDbgWritePhysical, SysDbgReadControlSpace, SysDbgGetTriageDump, SysDbgBreakPoint, etc. |
| InputBuffer | PVOID | in | Entrada específica del comando (típicamente un descriptor SYSDBG_VIRTUAL o SYSDBG_PHYSICAL con Address/Buffer/Request). |
| InputBufferLength | ULONG | in | Tamaño en bytes de InputBuffer. |
| OutputBuffer | PVOID | out | Buffer de salida específico del comando (p. ej. recibe datos para SysDbgReadVirtual). |
| OutputBufferLength | ULONG | in | Tamaño en bytes de OutputBuffer. |
| ReturnLength | PULONG | out | Opcional. Recibe el número de bytes realmente escritos en OutputBuffer. |
IDs de syscalls por versión de Windows
| Versión de Windows | ID de syscall | Build |
|---|---|---|
| Win10 1507 | 0x1A1 | win10-1507 |
| Win10 1607 | 0x1AA | win10-1607 |
| Win10 1703 | 0x1B0 | win10-1703 |
| Win10 1709 | 0x1B3 | win10-1709 |
| Win10 1803 | 0x1B5 | win10-1803 |
| Win10 1809 | 0x1B6 | win10-1809 |
| Win10 1903 | 0x1B7 | win10-1903 |
| Win10 1909 | 0x1B7 | win10-1909 |
| Win10 2004 | 0x1BD | win10-2004 |
| Win10 20H2 | 0x1BD | win10-20h2 |
| Win10 21H1 | 0x1BD | win10-21h1 |
| Win10 21H2 | 0x1BF | win10-21h2 |
| Win10 22H2 | 0x1BF | win10-22h2 |
| Win11 21H2 | 0x1C9 | win11-21h2 |
| Win11 22H2 | 0x1CD | win11-22h2 |
| Win11 23H2 | 0x1CD | win11-23h2 |
| Win11 24H2 | 0x1D0 | win11-24h2 |
| Server 2016 | 0x1AA | winserver-2016 |
| Server 2019 | 0x1B6 | winserver-2019 |
| Server 2022 | 0x1C5 | winserver-2022 |
| Server 2025 | 0x1D0 | winserver-2025 |
Módulo del kernel
APIs relacionadas
Stub del syscall
4C 8B D1 mov r10, rcx B8 D0 01 00 00 mov eax, 0x1D0 F6 04 25 08 03 FE 7F 01 test byte ptr [0x7FFE0308], 1 75 03 jne short +3 0F 05 syscall C3 ret CD 2E int 2Eh C3 ret
Notas no documentadas
NtSystemDebugControl es un multiplexor de operaciones de kernel estilo depurador. La enum Command (SYSDBG_COMMAND / SysDbgCommand) selecciona entre lectura/escritura de memoria virtual o física, acceso al control space, lecturas de MSR, control de profiler, instalación de breakpoints, recuperación de triage-dump y varios comandos heredados. *Crucial*: en builds free / retail Microsoft ha restringido progresivamente los comandos realmente potentes: SysDbgReadVirtual, SysDbgWriteVirtual, SysDbgReadPhysical y SysDbgWritePhysical devuelven STATUS_NOT_IMPLEMENTED salvo que el sistema corra un kernel debug (checked) o haya arrancado con `/DEBUG`. En un Win10/Win11 estándar esos bytes son inertes. El llamador además requiere SeDebugPrivilege.
Uso común por malware
Históricamente — Windows XP y comienzos de Vista — NtSystemDebugControl con SysDbgReadVirtual/WriteVirtual era una primitiva limpia de R/W de kernel desde user-mode que varios rootkits abusaron. Rustock y el driver de kernel de BlackEnergy 2 son ejemplos típicos; numerosos PoCs de investigación de la misma época la usaban para parchear la SSDT y manipular estructuras del kernel. Desde Vista x64 + PatchGuard + la restricción de free-build esta vía está esencialmente cerrada en sistemas modernos. El malware moderno no abusa de NtSystemDebugControl para R/W de kernel — el camino está cortado. Persisten usos indirectos: SysDbgGetTriageDump puede invocarse desde código anti-análisis para detectar la presencia de un depurador de kernel o un profiler activo.
Oportunidades de detección
En un sistema moderno, *cualquier* llamada exitosa a NtSystemDebugControl desde un proceso no depurador es sospechosa. ETW Microsoft-Windows-Kernel-Audit-API-Calls cubre la superficie privilegiada de depurador, y el uso de SeDebugPrivilege aparece en la auditoría de seguridad (Event ID 4673). En el EDR, hookear ntdll!NtSystemDebugControl, decodificar el comando y tratar SysDbgReadVirtual / SysDbgWriteVirtual / SysDbgReadControlSpace / SysDbgReadMsr como indicadores de alta confianza independientemente del status de retorno. Las llamadas que devuelven STATUS_NOT_IMPLEMENTED son en sí mismas una señal de sondeo digna de log.
Ejemplos de syscalls directos
asmx64 direct stub (Win11 24H2 SSN)
; Direct syscall stub for NtSystemDebugControl (SSN 0x1D0 on Win11 24H2 / Server 2025)
NtSystemDebugControl PROC
mov r10, rcx ; syscall convention
mov eax, 1D0h ; SSN for win11-24h2
syscall
ret
NtSystemDebugControl ENDPcSysDbgReadVirtual sketch (gated on free builds)
// Read N bytes from a kernel virtual address.
// On a stock Win10/Win11 system this returns STATUS_NOT_IMPLEMENTED.
// Only works against a checked kernel or with the system booted /DEBUG.
typedef enum _SYSDBG_COMMAND {
SysDbgReadVirtual = 8,
SysDbgWriteVirtual = 9,
SysDbgReadPhysical = 10,
SysDbgWritePhysical = 11,
SysDbgReadControlSpace = 12,
SysDbgGetTriageDump = 29,
} SYSDBG_COMMAND;
typedef struct _SYSDBG_VIRTUAL {
PVOID Address;
PVOID Buffer;
ULONG Request;
} SYSDBG_VIRTUAL, *PSYSDBG_VIRTUAL;
// caller must have SeDebugPrivilege enabled
BYTE buf[16] = { 0 };
SYSDBG_VIRTUAL in = {
.Address = (PVOID)0xfffff80000000000ULL, // some kernel VA
.Buffer = buf,
.Request = sizeof(buf),
};
ULONG returned = 0;
NTSTATUS s = NtSystemDebugControl(SysDbgReadVirtual,
&in, sizeof(in),
NULL, 0,
&returned);
// On a free build: s == STATUS_NOT_IMPLEMENTED (0xC0000002).rustwindows-sys + naked syscall stub
// Cargo: windows-sys = "0.59"
use std::arch::asm;
#[unsafe(naked)]
unsafe extern "system" fn nt_system_debug_control_stub() {
asm!(
"mov r10, rcx",
"mov eax, 0x1D0", // Win11 24H2; resolve dynamically for other builds
"syscall",
"ret",
options(noreturn),
);
}Mapeos MITRE ATT&CK
Last verified: 2026-05-20