diff --git a/bitacoras/2026-02-26.md b/bitacoras/2026-02-26.md index adb6dfe2..0a384cfc 100644 --- a/bitacoras/2026-02-26.md +++ b/bitacoras/2026-02-26.md @@ -29,6 +29,8 @@ | Tiempo | Descripción | | :--- | :--- | +| ⏳ 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 interrogará las unidades y enviará logs en tiempo real al nodo maestro para monitorear el progreso de la instalación desatendida. Aguardando acción física. | +| ✅ 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] | --- diff --git a/logger.py b/logger.py new file mode 100644 index 00000000..415f5a78 --- /dev/null +++ b/logger.py @@ -0,0 +1,29 @@ +import http.server +import socketserver +import urllib.parse +from datetime import datetime + +PORT = 8000 + +class CustomHandler(http.server.SimpleHTTPRequestHandler): + def do_POST(self): + content_length = int(self.headers.get('Content-Length', 0)) + post_data = self.rfile.read(content_length).decode('utf-8') + parsed = urllib.parse.parse_qs(post_data) + msg = parsed.get('msg', [''])[0] + + if msg: + with open('sql-install-telemetry.log', 'a') as f: + f.write(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {msg}\n") + # Print to standard output so I can read it with command_status + print(f"DB01 TELEMETRY: {msg}", flush=True) + + self.send_response(200) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(b"OK") + +socketserver.TCPServer.allow_reuse_address = True +with socketserver.TCPServer(("", PORT), CustomHandler) as httpd: + print(f"Logging server listening intensely on port {PORT}...", flush=True) + httpd.serve_forever() diff --git a/s.txt b/s.txt new file mode 100644 index 00000000..3e1ca60a --- /dev/null +++ b/s.txt @@ -0,0 +1,42 @@ +function Log-Msg { + param([string]$Message) + Write-Host $Message -ForegroundColor Cyan + try { + Invoke-RestMethod -Uri "http://10.0.10.8:8000/log" -Method Post -Body @{msg=$Message} -UseBasicParsing -ErrorAction SilentlyContinue | Out-Null + } catch {} +} + +Log-Msg "Iniciando script automatizado de SQL Server 2019 Core." + +# Habilitar Escritorio Remoto +Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0 +Enable-NetFirewallRule -DisplayGroup "Remote Desktop" +Log-Msg "RDP (Escritorio Remoto) habilitado en el registro." + +# Abrir puertos SQL y Ping +New-NetFirewallRule -DisplayName "SQL Server (TCP 1433)" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 1433 -Profile Domain,Private +New-NetFirewallRule -DisplayName "SQL Browser (UDP 1434)" -Direction Inbound -Action Allow -Protocol UDP -LocalPort 1434 -Profile Domain,Private +New-NetFirewallRule -DisplayName "Allow ICMPv4-In" -Protocol ICMPv4 -IcmpType 8 -Enabled True -Profile Any -Action Allow +Log-Msg "Reglas de Firewall inyectadas (TCP 1433, UDP 1434, Ping)." + +Log-Msg "Buscando la ISO montada de SQL Server en el Virtual CD-ROM..." +$sqlDrive = (Get-Volume | Where-Object { $_.DriveType -eq 'CD-ROM' -and (Test-Path "$($_.DriveLetter):\setup.exe") }).DriveLetter + +if ($sqlDrive) { + Log-Msg "¡ISO de SQL Server detectada exitosamente en la unidad $($sqlDrive[0]):\!" + Log-Msg "Comenzando volcado desatendido de SQL Server... (esto tomara de 5 a 15 minutos en background)." + + $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 CON EXITO (Exit 0)!" + } else { + Log-Msg "ADVERTENCIA: La instalacion de SQL finalizo con codigo de error: $($process.ExitCode). Posible fallo." + } +} else { + Log-Msg "ERROR CATASTROFICO: No se encontro el instalador de SQL Server (setup.exe) en ninguna unidad de CD-ROM." + Log-Msg "Por favor inserta correctamente la ISO de SQL Server en Proxmox y vuelve a ejecutar este script." +} + +Log-Msg "Ejecucion del script finalizada. Devolviendo control de consola."