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.