fix(sql): Carga útil autónoma con autodetección de locale, parche de compatibilidad y reinicio

This commit is contained in:
Ricardo Monla
2026-02-26 11:03:42 -03:00
parent 5f3e75d31e
commit 9307d3318a
2 changed files with 53 additions and 28 deletions
+3 -2
View File
@@ -30,8 +30,9 @@
| Tiempo | Descripción |
| :--- | :--- |
| ⏳ 10:54 | Despliegue de Bucle Operativo (C2 Automation). A fin de eliminar la fricción física constante de interactuar con la consola VNC ciega del Server Core, la IA y el Operador pergeñan un modelo de Command & Control (C2). Se instruye dejar corriendo en la VM el bucle infinito: `while($true){ iwr 10.0.10.8:8000/s.txt -useb\|iex; sleep 15 }`. Esto convierte a la base de datos en un nodo zombi que buscará y ejecutará órdenes dinámicas de la IA cada 15 segundos sin intervención humana adicional. Aguardando a que el operador lance el bucle. |
| 🔍 10:49 | Diseño de Sonda Diagnóstica (Language Mismatch). El análisis del código de error `-2067529714` revela incompatibilidad de idioma entre Windows Server y la ISO de SQL. La IA refactoriza la carga útil hacia una sonda de recolección de configuraciones regionales, lista para ser servida dinámicamente. |
| 🔍 10:38 | Análisis de Error en Instalación SQL. El script reporta una salida anómala en la consola de la VM. La IA procede inmediatamente a revisar los logs capturados por el servidor de telemetría para diagnosticar la causa raíz del fallo en el comando `setup.exe`. |
| ⚙️ 11:00 | Despliegue de Parche de Localización y Autómatas. A través del canal C2, la IA inyecta una nueva carga útil inteligente. El script `s.txt` ahora evalúa el locale (`Get-WinSystemLocale`). Si detecta incompatibilidad (`en-US`), fuerza el registro a `es-ES` e induce un reinicio (`Restart-Computer`). Si detecta compatibilidad (`es-ES`), procederá a inyectar el motor relacional de inmediato. El operador solo debe aguardar el reinicio automático y reactivar el bucle infinito al volver. |
| 10:49 | Ejecución de Sonda Diagnóstica (Language Mismatch). La telemetría captura la ejecución del bucle C2 confirmando fehacientemente la sospecha: `OS Locale: en-US` chocando con `ISO LP: 3082_ESN_LP` (Español). Diagnóstico resuelto exitosamente. |
| ✅ 10:38 | Análisis de Error en Instalación SQL. El script reportó previamente una salida anómala en la consola de la VM. La IA procedió a revisar los logs capturados por el servidor de telemetría diagnosticando la causa raíz del fallo en el comando `setup.exe` como un InvalidPlatformOSLanguage. |
| ❌ 10:33 | Inyección y Ejecución de SQL Server con Telemetría. Se instruye al operador a despachar el comando `iwr 10.0.10.8:8000/s.txt -useb\|iex` en la consola VNC. El script interroga las unidades y lanza el instalador, sin embargo, el proceso finaliza de manera prematura arrojando un código de error inesperado. |
| ✅ 10:25 | Implementación de Telemetría (VNC Bypass v2). Ante la imposibilidad de ver el estado de la red e instalación dentro del Server Core, la IA rediseña el stager (`s.txt`) y despliega un receptor efímero en Python (`logger.py` en srv-ns8) que consolida logs en vivo vía HTTP POST. |
| 👁️ 09:00 | Inicio de Sincronización Presencial (09:00 a 14:00). El operador asume guardia física en el nodo central. Inicia la jornada realizando el traspaso transversal de estado, rollover de bitácora y control de trazabilidad de métricas del Dashboard P2601. Se aguarda verificación de que el setup desatendido de SQL Server finalizó con éxito durante la noche. [Físico: 5 hs] |
+50 -26
View File
@@ -1,9 +1,3 @@
if (Test-Path "C:\diag_ran.txt") {
# Ya se ejecuto el payload actual, no hacemos nada para no espamear el log cada 15 segundos
exit
}
Set-Content -Path "C:\diag_ran.txt" -Value "Ejecutado"
function Log-Msg {
param([string]$Message)
Write-Host $Message -ForegroundColor Cyan
@@ -12,35 +6,65 @@ function Log-Msg {
} catch {}
}
$locale = Get-WinSystemLocale
if ($locale.Name -ne "es-ES") {
if (Test-Path "C:\reboot_pending.txt") { exit }
Set-Content -Path "C:\reboot_pending.txt" -Value "Yes"
Log-Msg "=========================================================="
Log-Msg "SISTEMA INCOMPATIBLE CONFIRMADO: OS = $($locale.Name), SQL ISO = ESN (es-ES)."
Log-Msg "APLICANDO PARCHE DE COMPATIBILIDAD (en-US -> es-ES)..."
Log-Msg "=========================================================="
Set-WinSystemLocale -SystemLocale es-ES
Set-WinUserLanguageList -LanguageList es-ES -Force
Log-Msg "Parche de registro inyectado. SE REQUIERE REINICIO."
Log-Msg "REINICIANDO EL SERVIDOR DB01..."
Log-Msg "Operador: Cuando la VM vuelva a iniciar, vuelve a lanzar el Bucle C2 en el VNC para continuar la instalacion de SQL."
Start-Sleep -Seconds 3
Restart-Computer -Force
exit
}
# Si llega aca, el locale ya es compatible!
if (Test-Path "C:\sql_installed.txt") { exit }
Log-Msg "=========================================================="
Log-Msg "Iniciando Sonda de Diagnostico de Idioma de OS y SQL Server"
Log-Msg "SISTEMA COMPATIBLE (es-ES). PROCEDIENDO CON INSTALACION SQL."
Log-Msg "=========================================================="
try {
$osLocale = Get-WinSystemLocale
Log-Msg "OS System Locale: $($osLocale.Name)"
} catch { Log-Msg "Fallo al leer OS System Locale" }
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
New-NetFirewallRule -DisplayName "SQL Server (TCP 1433)" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 1433 -Profile Domain,Private -ErrorAction SilentlyContinue
New-NetFirewallRule -DisplayName "SQL Browser (UDP 1434)" -Direction Inbound -Action Allow -Protocol UDP -LocalPort 1434 -Profile Domain,Private -ErrorAction SilentlyContinue
New-NetFirewallRule -DisplayName "Allow ICMPv4-In" -Protocol ICMPv4 -IcmpType 8 -Enabled True -Profile Any -Action Allow -ErrorAction SilentlyContinue
try {
$uiLang = Get-WinUILanguageSystem
Log-Msg "OS UI Language System: $($uiLang.Name)"
} catch { Log-Msg "Fallo al leer OS UI Language" }
Log-Msg "Buscando la ISO montada de SQL Server..."
$sqlDrive = (Get-Volume | Where-Object { $_.DriveType -eq 'CD-ROM' -and (Test-Path "$($_.DriveLetter):\setup.exe") }).DriveLetter
if ($sqlDrive) {
Log-Msg "ISO detectada en la unidad $($sqlDrive[0]):\"
# Las ISOs de SQL Server tienen carpetas como 1033_ENU_LP (Ingles) o 3082_ESN_LP (Espanol)
$isoLangs = Get-ChildItem -Path "$($sqlDrive[0]):\" -Directory | Where-Object { $_.Name -match '_LP$' } | Select-Object -ExpandProperty Name
Log-Msg "ISO SQL detectada en $($sqlDrive[0]):\. Comenzando Setup silencioso en background..."
if ($isoLangs) {
Log-Msg "Paquetes de idioma detectados en la ISO (LP_Folders): $($isoLangs -join ', ')"
$setupPath = "$($sqlDrive[0]):\setup.exe"
$process = Start-Process -FilePath $setupPath -ArgumentList "/Q /ACTION=INSTALL /FEATURES=SQLEngine /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=`"NT Service\MSSQLSERVER`" /SQLSYSADMINACCOUNTS=`"DASUTEN\Administrator`" /SECURITYMODE=SQL /SAPWD=`"Lhsurnm`$77NS8.`" /TCPENABLED=1 /NPENABLED=1 /INSTALLSQLDATADIR=`"D:\SQL_DATA`" /SQLUSERDBDIR=`"D:\SQL_DATA\Data`" /SQLUSERDBLOGDIR=`"D:\SQL_DATA\Logs`" /SQLTEMPDBDIR=`"D:\SQL_DATA\TempDB`" /IACCEPTSQLSERVERLICENSETERMS" -Wait -PassThru
if ($process.ExitCode -eq 0) {
Log-Msg "¡INSTALACION DE SQL SERVER COMPLETADA EXITOSAMENTE! (Exit 0)"
Set-Content -Path "C:\sql_installed.txt" -Value "OK"
} else {
Log-Msg "No se detectaron carpetas con sufijo _LP en la raiz de la ISO."
Log-Msg "ERROR FATAL: Instalacion fallida con codigo $($process.ExitCode)."
$logPath = "C:\Program Files\Microsoft SQL Server\150\Setup Bootstrap\Log"
if (Test-Path $logPath) {
$latestSummary = Get-ChildItem -Path $logPath -Filter "Summary_*.txt" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($latestSummary) {
$content = Get-Content $latestSummary.FullName -Tail 20 | Out-String
Invoke-RestMethod -Uri "http://10.0.10.8:8000/log" -Method Post -Body @{msg="DEBUG ERROR:`n$content"} -UseBasicParsing -ErrorAction SilentlyContinue | Out-Null
}
}
Set-Content -Path "C:\sql_installed.txt" -Value "FAILED"
}
} else {
Log-Msg "ERROR: No se encontro la ISO de SQL Server en ninguna lectora."
Log-Msg "ERROR CATASTROFICO: ISO SQL no encontrada."
}
Log-Msg "Finalizacion de diagnostico. Por favor aguarda nuevas instrucciones."