NtSetSystemPowerState
Transiciona el sistema al estado de energía solicitado (suspensión, hibernación, funcionamiento).
Prototipo
NTSTATUS NtSetSystemPowerState( POWER_ACTION SystemAction, SYSTEM_POWER_STATE MinSystemState, ULONG Flags );
Argumentos
| Name | Type | Dir | Description |
|---|---|---|---|
| SystemAction | POWER_ACTION | in | Acción: PowerActionNone, Reserved, Sleep, Hibernate, Shutdown, ShutdownReset, ShutdownOff, WarmEject, DisplayOff. |
| MinSystemState | SYSTEM_POWER_STATE | in | Estado de energía mínimo aceptable, p. ej. PowerSystemSleeping1..3, PowerSystemHibernate, PowerSystemShutdown. |
| Flags | ULONG | in | Flags POWER_ACTION_*: QUERY_ALLOWED, UI_ALLOWED, OVERRIDE_APPS, LIGHTEST_FIRST, DISABLE_WAKES, CRITICAL. |
IDs de syscalls por versión de Windows
| Versión de Windows | ID de syscall | Build |
|---|---|---|
| Win10 1507 | 0x18F | win10-1507 |
| Win10 1607 | 0x198 | win10-1607 |
| Win10 1703 | 0x19E | win10-1703 |
| Win10 1709 | 0x1A1 | win10-1709 |
| Win10 1803 | 0x1A3 | win10-1803 |
| Win10 1809 | 0x1A4 | win10-1809 |
| Win10 1903 | 0x1A5 | win10-1903 |
| Win10 1909 | 0x1A5 | win10-1909 |
| Win10 2004 | 0x1AB | win10-2004 |
| Win10 20H2 | 0x1AB | win10-20h2 |
| Win10 21H1 | 0x1AB | win10-21h1 |
| Win10 21H2 | 0x1AD | win10-21h2 |
| Win10 22H2 | 0x1AD | win10-22h2 |
| Win11 21H2 | 0x1B6 | win11-21h2 |
| Win11 22H2 | 0x1BA | win11-22h2 |
| Win11 23H2 | 0x1BA | win11-23h2 |
| Win11 24H2 | 0x1BD | win11-24h2 |
| Server 2016 | 0x198 | winserver-2016 |
| Server 2019 | 0x1A4 | winserver-2019 |
| Server 2022 | 0x1B3 | winserver-2022 |
| Server 2025 | 0x1BD | winserver-2025 |
Módulo del kernel
APIs relacionadas
Stub del syscall
4C 8B D1 mov r10, rcx B8 BD 01 00 00 mov eax, 0x1BD 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
Primo de bajo nivel de `NtInitiatePowerAction` — `NtSetSystemPowerState` salta el arbitraje del policy manager y es la función que el propio kernel invoca una vez que el power manager terminó sus negociaciones. El wrapper Win32 `SetSystemPowerState` aterriza aquí. El llamador debe poseer `SeShutdownPrivilege` (sesiones interactivas) o `SeRemoteShutdownPrivilege` (variantes cross-machine). La función no retorna hasta que el sistema haya reanudado desde el estado objetivo o rechazado la transición (p. ej. un driver vetó Sleep). Pasar `POWER_ACTION_DISABLE_WAKES | POWER_ACTION_CRITICAL` es la combinación 'cállate y hazlo' que evita la mayoría de los vetos aplicativos al Sleep.
Uso común por malware
Tres patrones reales. (1) **Wipers**: HermeticWiper, IsaacWiper y CaddyWiper han sido observados llamando acciones de reboot al final de su pasada de destrucción para forzar al equipo a arrancar con datos de boot corruptos — el usuario ve un BSOD o pantalla 'Inaccessible Boot Device' en el siguiente arranque. (2) **Reboot post-cifrado de ransomware**: Royal, BlackCat/ALPHV y BlackSuit han disparado un reboot vía esta familia de syscalls tras dejar su nota, tanto para imponer un estado limpio sobre el volumen cifrado como para asegurar que los ficheros abiertos queden cerrados. (3) **Evasión de sandbox**: un pequeño conjunto de loaders red-team llama PowerSystemSleeping3 o DisplayOff dentro de una VM de análisis automático con la esperanza de que el harness trate la transición como 'ejecución completada' y desmonte antes de que el payload real corra. A menudo combinado con `NtDelayExecution` para sesgar los relojes que el harness usa para computar runtime.
Oportunidades de detección
`SetSystemPowerState` y su syscall subyacente son rastreados por el proveedor ETW Microsoft-Windows-Kernel-Power — cada transición Sleep/Hibernate/Shutdown emite eventos bien definidos que incluyen el proceso iniciador. Sysmon no tiene evento dedicado pero el log System registra 1074 (shutdown limpio iniciado) y 6008 (shutdown inesperado), ambos útiles para reconstrucción retroactiva. La regla individual más fuerte: un proceso no-sistema que invoca una POWER_ACTION de clase Shutdown habiendo escrito muchos ficheros en el minuto anterior es esencialmente una huella de wiper o ransomware. SeShutdownPrivilege debería estar desactivado para la mayoría de cuentas de servicio — alertar sobre el ajuste de privilegio inmediatamente anterior a la llamada.
Ejemplos de syscalls directos
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtSetSystemPowerState (SSN 0x1BD on Win11 24H2)
NtSetSystemPowerState PROC
mov r10, rcx ; syscall convention
mov eax, 1BDh ; SSN — varies per build
syscall
ret
NtSetSystemPowerState ENDPcWiper finale — force reboot into corrupted boot
// Final stage of a destructive payload: enable shutdown privilege then
// request an immediate Shutdown-Reset, bypassing user prompts.
#include <windows.h>
#include <winternl.h>
static VOID EnableShutdownPriv(VOID) {
HANDLE hTok; LUID luid; TOKEN_PRIVILEGES tp = { 0 };
OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hTok);
LookupPrivilegeValueW(NULL, SE_SHUTDOWN_NAME, &luid);
tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hTok, FALSE, &tp, sizeof(tp), NULL, NULL);
CloseHandle(hTok);
}
typedef NTSTATUS (NTAPI *pNtSetSystemPowerState)(ULONG, ULONG, ULONG);
VOID WiperReboot(VOID) {
EnableShutdownPriv();
pNtSetSystemPowerState NtSetSystemPowerState = (pNtSetSystemPowerState)
GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtSetSystemPowerState");
// PowerActionShutdownReset = 6, PowerSystemShutdown = 6,
// DISABLE_WAKES | CRITICAL = 0x40000000 | 0x80000000
NtSetSystemPowerState(6, 6, 0xC0000000);
}rustDirect-syscall sleep request (sandbox evasion attempt)
// Cargo: windows-sys = "0.59"
use std::arch::asm;
#[unsafe(naked)]
unsafe extern "system" fn nt_set_system_power_state_stub(
_action: u32, _min_state: u32, _flags: u32) -> i32 {
asm!(
"mov r10, rcx",
"mov eax, 0x1BD", // Win11 24H2 SSN
"syscall",
"ret",
options(noreturn),
);
}
fn try_sleep_evasion() {
// PowerActionSleep = 2, PowerSystemSleeping3 = 5, UI_ALLOWED=4
let _ = unsafe { nt_set_system_power_state_stub(2, 5, 4) };
}Mapeos MITRE ATT&CK
Last verified: 2026-05-20