I fetched the result with metasploit and upgraded it to a meterpreter shell to make things easier
Internal Enum & Persistence
ss -tlpn revealed an interesting open port:
I created ssh keys for persistence:
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/app/.ssh/id_rsa): /tmp/appuser-rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /tmp/appuser-rsa
Your public key has been saved in /tmp/appuser-rsa.pub
This did not work as the app user cannot use ssh with pubkey auth.
According to /etc/passwd there is the user postgres (and the user josh).
I found the psql pw at cloudhosting-0.0.1/BOOT-INF/classes/htb/application.properties after extracting the file which I found at /app on the server:
Using this password I could log onto the server with ssh.
GTFOBin ssh
The user can execute ssh as root:
josh@cozyhosting:~$ sudo -l
[sudo] password for josh:
Matching Defaults entries for josh on localhost:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User josh may run the following commands on localhost:
(root) /usr/bin/ssh *
This is called a GTFObin. Using this source I found exploitation methods for it: