NtSystemDebugControl
Achemine des requêtes de type débogueur noyau (R/W noyau, espace de contrôle, points d'arrêt, profileur) sélectionnées par l'enum SysDbgCommand.
Prototype
NTSTATUS NtSystemDebugControl( SYSDBG_COMMAND Command, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG ReturnLength );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| Command | SYSDBG_COMMAND | in | Sélecteur d'opération : SysDbgReadVirtual, SysDbgWriteVirtual, SysDbgReadPhysical, SysDbgWritePhysical, SysDbgReadControlSpace, SysDbgGetTriageDump, SysDbgBreakPoint, etc. |
| InputBuffer | PVOID | in | Entrée spécifique à la commande (typiquement un descripteur SYSDBG_VIRTUAL ou SYSDBG_PHYSICAL avec Address/Buffer/Request). |
| InputBufferLength | ULONG | in | Taille en octets de InputBuffer. |
| OutputBuffer | PVOID | out | Buffer de sortie spécifique à la commande (ex. reçoit les données pour SysDbgReadVirtual). |
| OutputBufferLength | ULONG | in | Taille en octets de OutputBuffer. |
| ReturnLength | PULONG | out | Optionnel. Reçoit le nombre d'octets effectivement écrits dans OutputBuffer. |
IDs de syscalls par version de Windows
| Version 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 |
Module noyau
APIs liées
Stub du 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
Notes non documentées
NtSystemDebugControl est un multiplexeur d'opérations noyau de type débogueur. L'enum Command (SYSDBG_COMMAND / SysDbgCommand) sélectionne entre lecture/écriture mémoire virtuelle ou physique, accès au control space, lectures MSR, contrôle du profileur, pose de points d'arrêt, récupération de triage-dump et plusieurs commandes historiques. *Crucial* : sur les builds free / retail Microsoft a progressivement restreint les commandes réellement puissantes : SysDbgReadVirtual, SysDbgWriteVirtual, SysDbgReadPhysical et SysDbgWritePhysical retournent STATUS_NOT_IMPLEMENTED sauf si le système exécute un noyau debug (checked) ou a été démarré avec `/DEBUG`. Sur un poste Win10/Win11 standard ces octets sont inertes. L'appelant doit également disposer de SeDebugPrivilege.
Usage courant par les malwares
Historiquement — Windows XP et début Vista — NtSystemDebugControl avec SysDbgReadVirtual/WriteVirtual offrait une primitive R/W noyau propre depuis l'user-mode que plusieurs rootkits ont exploitée. Rustock et le driver noyau BlackEnergy 2 sont des exemples souvent cités ; de nombreux PoC de recherche de la même époque l'utilisaient pour patcher la SSDT ou altérer des structures noyau. Depuis Vista x64 + PatchGuard + la restriction free-build, cette voie est essentiellement fermée sur les systèmes modernes. Le malware moderne n'abuse plus de NtSystemDebugControl pour du R/W noyau — le chemin est coupé. Des usages indirects subsistent : SysDbgGetTriageDump peut être invoquée par du code anti-analyse pour détecter la présence d'un débogueur noyau ou d'un profileur actif.
Opportunités de détection
Sur un système moderne, *tout* appel réussi à NtSystemDebugControl depuis un processus non-débogueur est suspect. ETW Microsoft-Windows-Kernel-Audit-API-Calls couvre la surface privilégiée du débogueur, et l'usage de SeDebugPrivilege apparaît dans l'audit de sécurité (Event ID 4673). Côté EDR, hooker ntdll!NtSystemDebugControl, décoder la commande et traiter SysDbgReadVirtual / SysDbgWriteVirtual / SysDbgReadControlSpace / SysDbgReadMsr comme indicateurs à forte confiance, indépendamment du status de retour. Les appels qui retournent STATUS_NOT_IMPLEMENTED sont eux-mêmes un signal de sondage à logger.
Exemples de syscalls directs
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),
);
}Mappings MITRE ATT&CK
Last verified: 2026-05-20