Why do we always check for 500 response in shellshock exploitable request why not 200, 301 or others?
conn.request("GET", path, headers=headers)
res = conn.getresponse()
if res.status == 500:
print "Shell Shock Exploitable"
Why do we always check for 500 response in shellshock exploitable request why not 200, 301 or others?
conn.request("GET", path, headers=headers)
res = conn.getresponse()
if res.status == 500:
print "Shell Shock Exploitable"
Copyright © 2021 Jogjafile Inc.
Its a standard way to check if a server is vulnerable to the shellshock bug.
As an example, suppose we have a bash CGI script running on Apache, accessible via the URL
http://localhost/shellshock.cgi, and we make a request that passes some new custom header like this:The header itself is just a dummy header that looks like a function definition (with an empty statement as the body), followed by an ordinary
echocommand.Now, according to https://nvd.nist.gov/vuln/detail/CVE-2014-6271:
This means that a vulnerable server should return a 500 Internal Server Error in the above case.
The reason for this is that the request headers passed to the server are stored as environment variables, in which case the
echocommand after the function is executed unintentionally when the function is imported -- but before the CGI script gets to print its valid headers.In the Apache error logs, you would see something about a "malformed header" or "bad header" -- since in this case, the output from the
echocommand (vulnerable) is the first thing that gets printed and is therefore treated as a header.The fact that a 500 error occurs lets us know that something went wrong. Its not full-proof though, since an Internal Server Error could have occurred for any amount of other reasons. However, this approach gives a pretty good indication.
Of course, the above is just a simple way to demonstrate that the server is vulnerable. Once we know the server is vulnerable, we can try to exploit it like this:
Here we just add the necessary
Content-typeheader followed by a blank line before attempting to execute arbitrary malicious code. This prevents the 500 Internal Server Error, thereby enabling the output of the malicious code to be returned when the CGI script terminates.If our exploit succeeds, then we should get a 200 OK response from the server, and see the contents of the
/etc/passwdfile. So you could treat this a check for the shellshock vulnerability as well - one that doesn't rely on merely checking for a 500 error.Of course, in the above case we're just echoing back the contents of the
/etc/passwdfile, but we could easily exploit shellshock to do significant damage to the server and/or its users. There is a good Cloudflare article that explores various possibilities.Recommend Reading: