[P2602][F1] sysacadweb SSH 7022 verified, nodo updated (IP 10.0.10.12), Win32-OpenSSH legacy
This commit is contained in:
@@ -0,0 +1 @@
|
||||
OpenSSH-Win64.zip
|
||||
@@ -1,46 +1,27 @@
|
||||
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 "=========================================================="
|
||||
Log-Msg "CONFIGURANDO SSH EN PUERTO 7022"
|
||||
Log-Msg "=========================================================="
|
||||
|
||||
$cfg = "C:\ProgramData\ssh\sshd_config"
|
||||
Write-Host "=== Cambiando SSH a puerto 7022 ===" -ForegroundColor Green
|
||||
Write-Host "Config: $cfg"
|
||||
|
||||
try {
|
||||
# Leer config, quitar cualquier linea Port anterior
|
||||
$lines = Get-Content $cfg | Where-Object { $_ -notmatch '^\s*#?\s*Port\s+\d+' }
|
||||
|
||||
# Agregar Port 7022 al inicio
|
||||
$lines = @("Port 7022") + $lines
|
||||
|
||||
# Escribir config limpia
|
||||
$lines | Set-Content $cfg -Force
|
||||
Log-Msg "sshd_config actualizado: Port 7022"
|
||||
# Backup
|
||||
Copy-Item $cfg "$cfg.bak" -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# Firewall: agregar 7022, quitar 22
|
||||
New-NetFirewallRule -Name 'SSH-7022' -DisplayName 'SSH 7022' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 7022 -ErrorAction SilentlyContinue | Out-Null
|
||||
Remove-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue
|
||||
Log-Msg "Firewall actualizado: 7022 abierto, 22 cerrado"
|
||||
# Leer, reemplazar, escribir
|
||||
$content = Get-Content $cfg
|
||||
$content = $content -replace '^\s*#?\s*Port\s+\d+', 'Port 7022'
|
||||
$found = $content | Select-String '^Port 7022'
|
||||
if (-not $found) { $content = @("Port 7022") + $content }
|
||||
$content | Set-Content $cfg -Force
|
||||
|
||||
# Reiniciar servicio
|
||||
Stop-Service sshd -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 2
|
||||
Start-Service sshd
|
||||
Log-Msg "Servicio sshd reiniciado OK"
|
||||
Write-Host "Verificacion:" -ForegroundColor Yellow
|
||||
Get-Content $cfg | Select-String "Port"
|
||||
|
||||
$port = (Get-Content $cfg | Select-String "^Port").ToString().Trim()
|
||||
Log-Msg "Verificacion: $port"
|
||||
} catch {
|
||||
Log-Msg "ERROR: $_"
|
||||
}
|
||||
Write-Host "`nReiniciando sshd..." -ForegroundColor Yellow
|
||||
Stop-Service sshd -Force
|
||||
Start-Sleep -Seconds 3
|
||||
Start-Service sshd
|
||||
|
||||
Log-Msg "=========================================================="
|
||||
Log-Msg "OPERACION COMPLETADA"
|
||||
Log-Msg "=========================================================="
|
||||
exit
|
||||
Write-Host "`n=== netstat ===" -ForegroundColor Yellow
|
||||
netstat -an | Select-String "LISTEN" | Select-String "7022"
|
||||
|
||||
Write-Host "`n=== LISTO ===" -ForegroundColor Green
|
||||
Read-Host "Presione ENTER"
|
||||
|
||||
@@ -37,4 +37,4 @@ try {
|
||||
Log-Msg "=========================================================="
|
||||
Log-Msg "OPERACION COMPLETADA. Ahora SSH esta disponible."
|
||||
Log-Msg "=========================================================="
|
||||
exit
|
||||
return
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
$ErrorActionPreference = "Continue"
|
||||
$logFile = "C:\ssh_install.log"
|
||||
|
||||
function Log($msg) {
|
||||
$ts = Get-Date -Format "HH:mm:ss"
|
||||
$line = "[$ts] $msg"
|
||||
Write-Host $line -ForegroundColor Cyan
|
||||
Add-Content -Path $logFile -Value $line
|
||||
try { (New-Object Net.WebClient).DownloadString("http://10.0.10.8:8000/log?msg=$msg") | Out-Null } catch {}
|
||||
}
|
||||
|
||||
Log "=========================================="
|
||||
Log "OPENSSH LEGACY INSTALLER (2008R2+)"
|
||||
Log "=========================================="
|
||||
|
||||
$sshDir = "C:\OpenSSH-Win64"
|
||||
$zipPath = "C:\OpenSSH-Win64.zip"
|
||||
$sshUrl = "http://10.0.10.8:8000/payloads/OpenSSH-Win64.zip"
|
||||
|
||||
try {
|
||||
if (Test-Path "$sshDir\sshd.exe") {
|
||||
Log "OpenSSH ya instalado en $sshDir"
|
||||
} else {
|
||||
Log "Paso 1: Descargando ZIP..."
|
||||
$wc = New-Object System.Net.WebClient
|
||||
$wc.DownloadFile($sshUrl, $zipPath)
|
||||
Log "Descarga OK ($zipPath)"
|
||||
|
||||
Log "Paso 2: Extrayendo ZIP..."
|
||||
$shell = New-Object -ComObject Shell.Application
|
||||
$zip = $shell.NameSpace($zipPath)
|
||||
$dest = $shell.NameSpace("C:\")
|
||||
$dest.CopyHere($zip.Items(), 0x14)
|
||||
Log "Extraido en $sshDir"
|
||||
}
|
||||
|
||||
Log "Paso 3: Instalando servicio sshd..."
|
||||
cd $sshDir
|
||||
powershell -ExecutionPolicy Bypass -File "$sshDir\install-sshd.ps1"
|
||||
Log "Servicio instalado"
|
||||
|
||||
Log "Paso 4: Generando host keys..."
|
||||
if (!(Test-Path "$sshDir\ssh_host_rsa_key")) {
|
||||
& "$sshDir\ssh-keygen.exe" -A
|
||||
Log "Host keys generadas"
|
||||
} else {
|
||||
Log "Host keys ya existen"
|
||||
}
|
||||
|
||||
Log "Paso 5: Configurando puerto 7022..."
|
||||
$cfg = "$sshDir\sshd_config"
|
||||
if (Test-Path "$sshDir\sshd_config_default") {
|
||||
Copy-Item "$sshDir\sshd_config_default" $cfg -Force
|
||||
}
|
||||
if (Test-Path $cfg) {
|
||||
$lines = Get-Content $cfg | Where-Object { $_ -notmatch '^\s*#?\s*Port\s+\d+' }
|
||||
$newContent = @("Port 7022") + $lines
|
||||
$newContent | Set-Content $cfg -Force
|
||||
} else {
|
||||
"Port 7022" | Set-Content $cfg
|
||||
}
|
||||
Log "Config: Port 7022"
|
||||
|
||||
Log "Paso 6: Firewall..."
|
||||
netsh advfirewall firewall add rule name="SSH-7022" dir=in action=allow protocol=TCP localport=7022
|
||||
Log "Firewall actualizado"
|
||||
|
||||
Log "Paso 7: Iniciando servicio..."
|
||||
Set-Service sshd -StartupType Automatic -ErrorAction SilentlyContinue
|
||||
Start-Service sshd -ErrorAction Stop
|
||||
Log "Servicio sshd INICIADO en puerto 7022"
|
||||
|
||||
} catch {
|
||||
Log "ERROR: $($_.Exception.Message)"
|
||||
Log "LINEA: $($_.InvocationInfo.ScriptLineNumber)"
|
||||
}
|
||||
|
||||
Log "=========================================="
|
||||
Log "FIN. Log guardado en $logFile"
|
||||
Log "=========================================="
|
||||
Write-Host ""
|
||||
Write-Host "Presiona ENTER para cerrar..." -ForegroundColor Yellow
|
||||
Read-Host
|
||||
@@ -43,4 +43,4 @@ try {
|
||||
Log-Msg "=========================================================="
|
||||
Log-Msg "OPERACION COMPLETADA"
|
||||
Log-Msg "=========================================================="
|
||||
exit
|
||||
return
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
@echo off
|
||||
chcp 65001 >nul 2>&1
|
||||
title W-ZOMBI Agent - Conectado a srv-ns8
|
||||
color 0A
|
||||
|
||||
echo ======================================================
|
||||
echo W-ZOMBI Agent — Esperando ordenes de srv-ns8
|
||||
echo ======================================================
|
||||
echo.
|
||||
echo Este agente se queda abierto y ejecuta lo que
|
||||
echo srv-ns8 le envie. NO cerrar esta ventana.
|
||||
echo.
|
||||
echo Servidor: http://10.0.10.8:8000
|
||||
echo ======================================================
|
||||
echo.
|
||||
|
||||
:LOOP
|
||||
echo [%TIME%] Consultando payload activo...
|
||||
|
||||
REM Descargar y ejecutar el payload activo via PowerShell
|
||||
powershell -ExecutionPolicy Bypass -Command ^
|
||||
"$ErrorActionPreference='Continue'; " ^
|
||||
"try { " ^
|
||||
" $script = (New-Object Net.WebClient).DownloadString('http://10.0.10.8:8000/payloads/activo.ps1'); " ^
|
||||
" if ($script -and $script.Trim() -ne '') { " ^
|
||||
" Write-Host '[ZOMBI] Ejecutando payload...' -ForegroundColor Green; " ^
|
||||
" Invoke-Expression $script " ^
|
||||
" } else { " ^
|
||||
" Write-Host '[ZOMBI] Sin payload pendiente.' -ForegroundColor DarkGray " ^
|
||||
" } " ^
|
||||
"} catch { " ^
|
||||
" Write-Host '[ZOMBI] Sin conexion a srv-ns8, reintentando...' -ForegroundColor Yellow " ^
|
||||
"}"
|
||||
|
||||
echo.
|
||||
echo [%TIME%] Esperando 15 segundos... (CTRL+C para salir)
|
||||
timeout /t 15 /nobreak >nul
|
||||
goto LOOP
|
||||
Reference in New Issue
Block a user