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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Blind <strong>SQL</strong> <strong>Injection</strong> Exploitation • Chapter 5 265<br />

lookups by prefixing the supplied domain with the output. These DNS queries will arrive<br />

at the attacker’s address <strong>and</strong> are decoded by sqlninja <strong>and</strong> displayed. Sqlninja includes a<br />

st<strong>and</strong>-alone DNS server component which answers queries for the purposes of eliminating<br />

timeouts. Figure 5.15 shows an instance of sqlninja that was used to retrieve the account<br />

under which <strong>SQL</strong> Server was running using the whoami comm<strong>and</strong>. Because sqlninja relies<br />

on both xp_cmdshell <strong>and</strong> file creation, privileged database access is a must.<br />

Figure 5.15 Executing sqlninja to Extract a Username via DNS<br />

Squeeza<br />

The final tool examined for automating blind <strong>SQL</strong> injection exploitation, squeeza is<br />

a comm<strong>and</strong>-line tool that supports multiple methods for extracting information from<br />

<strong>SQL</strong> Server databases, with particular emphasis placed on the DNS channel where<br />

a reliability layer is added.<br />

■■<br />

■■<br />

■■<br />

■■<br />

■■<br />

URL: www.sensepost.com/research/squeeza<br />

Requirements: Ruby, tcpdump for DNS channel (Linux/Mac), authoritative<br />

DNS server for any domain<br />

Scenarios: Generic error page, controlled output; generic error page, uncontrolled<br />

output; completely blind, no errors<br />

Supported database: <strong>SQL</strong> Server<br />

Methods: Inference time-based bit-by-bit; alternative channel = DNS<br />

Squeeza takes a slightly different approach to <strong>SQL</strong> injection in general by dividing injection<br />

into data creation (e.g., comm<strong>and</strong> execution, a file from the database’s file system, or an <strong>SQL</strong><br />

query) <strong>and</strong> data extraction (e.g., using classic errors, timing inference, <strong>and</strong> DNS). This enables<br />

the attacker to mix <strong>and</strong> match to a large degree: comm<strong>and</strong> execution using timing as the return<br />

channel, or file copy over DNS. We will focus solely on the DNS extraction channel combined<br />

with comm<strong>and</strong> execution for data generation for brevity’s sake.

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

Saved successfully!

Ooh no, something went wrong!