Wall just retired today. I had lots of fun solving it and I enjoyed trying to bypass a webapp firewall. Its IP address is 10.10.10.157 and I added it to /etc/hosts as wall.htb. Without further ado, let’s jump right in!
Scanning
A light nmap scan was enough to get me started:
There were only 2 open ports and the SSH version didn’t look old, so I started enumerating port 80. However, the site looked like no-one has ever changed it from the default:
Dirb & Quick Grammar Lesson
Having no entry point at all, I decided to run dirb and let it finish:
The /monitoring URI looked interesting, so I tried accessing it in a browser. Unfortunately, the page required users to login:
I tried ‘exhaustively searching’ for a valid username&password combination, but I had no success.
It’s time for the grammar lesson I mentioned – HTTP Verb tampering. Here’s a quick definition:
HTTP Verb Tampering is an attack that exploits vulnerabilities in HTTP verb (also known as HTTP method) authentication and access control mechanisms. Many authentication mechanisms only limit access to the most common HTTP methods, thus allowing unauthorized access to restricted resources by other HTTP methods.
I wrote a small python script that can test a given URL for this misconfiguration (technically, it’s not a vulnerability):
Here’s the output I got for the first 3 methods:
I immediately saw that the server returned 200 OK when I tried accessing it with POST. The body of the page was very small and redirected the user to a new URI, /centreon:
Exploiting centreon
A quick google search of the product version (found under the login form) revealed that the app was indeed vulnerable to a RCE vulnerability. However, I first needed to log in. The default credentials didn’t work, so I wrote a python script that uses the centreon API to bruteforce the password:
The script found the password in about 5 seconds:
I used admin/password1 to log in to centreon:
I found this exploit on GitHub and tried to run it, but it didn’t work, so I decided to exploit the application manually. The method of exploitation was rather easy and I followed it step-by-step to see where the exploit failed. First, I went to the poll manager and created a new poll:
I used shellgenerator.gihub.io to craft a reverse shell payload. The idea was to change the ‘Monitoring Engine Binary’ to the command(s) I wanted to be executed:
However, after clicking the ‘Save’ button I hit… a wall:
Tearing Down the Wall
I was able to to create new polls with the default ‘Monitoring Engine Binary’ and to change it a bit, however, as soon as I added a space in the field, I got the ‘Forbidden’ page. This led me to believe that the application was protected by a WAF (Web Application Firewall). After a lot of trial-and-error, I was able to bypass it using the following payload:
I know it looks hard to understand, but I assure you it isn’t. The first thing that I noticed was that I wasn’t allowed to include spaces in the field, so I used ${IFS}, which is interpreted as a whitespace character by bash. If I were to replace that character sequence with spaces, the payload would just be
The base64 encoded string decodes to
I encoded the real payload with base64 just in case the firewall dropped all packets containing some specific phrases like ‘bash’ or ‘/dev/tcp’. After saving the new poll, I had to activate it. I needed o know the poll id, so I clicked on my newly-created poll and looked at the URL address:
The server_id GET parameter was the info I needed to activate the poll. I used python to craft the request:
What I forgot to mention is that the ‘Localhost?’ option of the poll needed to be set to ‘Yes’ for the exploit to work:
The python shell hung and a reverse shell connected on port 443:
The ‘user.txt’ file was located in the ‘/home/shelby’ directory, which I wasn’t able to read.
First root, then user
Yes, you read that right. I wasn’t able to escalate to user and then to root, but I was able to gain root privilege and then read the user.txt file. During my enumeration as www-data, I discovered an interesting SUID binary:
The ‘/bin/screen-4.5.0’ binary was new to me, so I googled it and immediately found an exploit:
The ExploitDB entry didn’t provide an actual working exploit, but I found this GitHub repo that did:
As the script was very short, I encoded it in base64 and transferred it to the remote machine via ‘echo [str]
base64 -d > file’:
I was then able to read both user.txt and root.txt:
The user proof starts with fe and the root proof starts with 1f 😉