Reconnaissance
First, I added the new host to my known ones:
Then, I performed a Nmap scan:
So I decided to take a look at the webpage:
Thereโs a misconfiguration on Shocker thatโs worth understanding. Typically, most webservers will handle a request to a directory without a trailing slash by sending a redirect to the same path but with the trailing slash. But in this case, there is a directory on Shocker that sends a 404 Not Found with visited without the trailing slash.
Tools likeย dirsearch ๐ย andย Dirb ๐ขย actually take the input wordlist and loop over each entry sending two requests, with and without the trailing slash. This is really helpful in a case like shocker, but will double the amount of requests sent (and thus time) each time thereโs a scan. Bothย Gobuster ๐ฆย andย feroxbuster
ย have aย -f
ย flag to force adding theย /
ย to the end of directories. For Shocker, running withย -f
ย does find something else:
So I checked that script:
It seems that this script outputs the linux command uptime
.
Exploitation
ShellShock, AKA Bashdoor or CVE-2014-6271, was a vulnerability in Bash discovered in 2014 which has to do with the Bash syntax for defining functions. It allowed an attacker to execute commands in places where it should only be doing something safe like defining an environment variable. An initial POC was this:
This was a big deal because lots of different programs would take user input and use it to define environment variables, the most famous of which was CGI-based web servers. For example, itโs very typically to store the User-Agent string in an environment variable. And since the UA string is completely attacker controlled, this led to remote code execution on these systems.
I got inspired by this website: sevenlayers.com, then I created this note
So I decided to intercept the request and send a shellshock payload. I tested this payload:
So itโs time for a reverse shell:
Got it!
I can now read the user flag:
Privilege escalation
if we run sudo -l
:
So we can run as sudo without password a perl privileged reverse shell. As GTFOBins says:
Info
If the binary is allowed to run as superuser byย
sudo
, it does not drop the elevated privileges and may be used to access the file system, escalate or maintain privileged access.
We are root now!:
Machine pwned!