# Script: test_privilegios.ps1 # Objetivo: Prueba irrefutable de privilegios (SYSTEM vs. Usuario). $LogPath = "C:\TEMP\safecloud_privilege_test.log" $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name # Definimos la clave de registro que SOLO SYSTEM puede tocar. $ProtectedRegPath = "HKLM:\SECURITY\SafeCloudPrivilegeTest" try { # --- LA PRUEBA --- # Intentamos crear una clave en HKLM:\SECURITY # Esto FALLARÁ para "RunAs User" (Acceso Denegado). # Esto FUNCIONARÁ para "RunAs System". New-Item -Path $ProtectedRegPath -Force -ErrorAction Stop # Si llegamos aquí, tuvimos éxito (somos SYSTEM) $Content = "PRUEBA EXITOSA (Ejecutado como $CurrentUser) - $Timestamp`nSe creó la clave de registro en HKLM:\SECURITY." # Limpiamos nuestra prueba Remove-Item -Path $ProtectedRegPath -Force } catch { # Si llegamos aquí, fallamos (somos Usuario) $Content = "PRUEBA FALLIDA (Ejecutado como $CurrentUser) - $Timestamp`nAcceso denegado a HKLM:\SECURITY, como se esperaba." } # Escribimos el resultado en un archivo de registro para que podamos verlo. Set-Content -Path $LogPath -Value $Content -Force