β Shocker (Easy)
Lesson Learn
Report-Penetration
Vulnerable Exploit: Misconfigured restricted access and vulnerable to Shellshock
System Vulnerable: 10.10.10.56
Vulnerability Explanation: The machine is misconfigured restricted access to file and it is vulnerable to shellshock which could allow us to gain initial foothold on the machine.
Privilege Escalation Vulnerability: Misconfigure on perl script that allow normal user to run with NOPASSWD require.
Vulnerability Fix: Upgrade or apply patched to the system and restrict access to all files and directory for unauthorized user.
Severity: High
Step to Compromise the Host:
Reconnaissance
Enumeration
Port 80 Apache/2.4.18 (ubuntu)
By browsing the webpage, we just found an image. Viewing source code also nothing is interest.

By finding hidden directory with gobuster as normal, we found only /server-status. It's suppose to have other file or directory existing.
Let try discover hidden directory with other tool as dirb. With dirb, we found /cgi-bin/ and index.html.
Let further enumerating on the web browser. By browsing /cgi-bin/ and /cgi-bin to see the different.
As we can see /cgi-bin/ it returns status code 403 (Forbidden) whereas /cgi-bin it returns 404 (Not Found). It seems like if we didn't add / at the end, it doesn't work.


Let try discover hidden directory again with gobuster with the options -f to add / at the end. As we are now can see the directory /cgi-bin/.
Let discover more on /cgi-bin/ if there is any file or directory we could access.
CGI (Common Gateway Interface) defines a way for a web server to interact with external content-generating programs, which are often referred to as CGI programs or CGI scripts. The script extension use pl (perl) and cgi. For this box is Ubuntu let check extension sh (shell).
We found file /user.sh. Viewing the content of the file, it seems like it is the result of execute bash script uptime.

To view the content easily, we can intercept traffic through burp,

Notice on server response, the Content-Type header is text/x-sh and the below script is trying to add Content-Type header text/plain but it's after the empty line, so it's in the body.
Let start checking, if this application is vulnerable to shellshock or not. Using nmap script to verify.
Seem like this application is vulnerable to shellshock.
https://blog.cloudflare.com/inside-shellshock/
Shellshock Exploitation
Viewing nmap script, we found that it's going to inject command to verify.
Let start manual testing and inject command into User-Agent. We can see, it seem likes include 1 more space on the body.

By adding ls to list current directory but it doesn't display anything.

But if we include the complete path, it's going to execute and display the current directory.
Let start inject bash reverse shell command on User-Agent and start netcat listener on 4444.


Privilege Escalation
First the first, run sudo -l whether there is any misconfiguration. We can run perl with root permission and without require password.

/usr/bin/perl
The best place for me to check for privilege escalation is https://gtfobins.github.io/.


Other method we can run netcat listener on our machine and execute perl reverse shell command.


Last updated