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.

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

Table 2.2 Signatures for Inline <strong>Injection</strong> of Numeric Values<br />

Testing String Variations Expected Results<br />

‘ Error triggering. If successful,<br />

the database will return an error<br />

1+1 3-1 If successful, it returns the same value<br />

as the result of the operation<br />

value + 0<br />

If successful, it returns the same value<br />

as the original request<br />

1 or 1=1 1) or (1=1 Always true condition. If successful,<br />

it returns every row in the table<br />

value or 1=2 value) or (1=2 No condition. If successful, it returns<br />

the same result as the original value<br />

1 <strong>and</strong> 1=2 1) <strong>and</strong> (1=2 Always false condition. If successful,<br />

it returns no rows from the table<br />

1 or ‘ab’= ‘a’+’b’ 1) or (‘ab ‘= ‘a’+’b’ Microsoft <strong>SQL</strong> Server concatenation.<br />

This injection is valid for Microsoft <strong>SQL</strong><br />

Server. If successful, it returns the same<br />

information as an always true condition<br />

1 or ‘ab’=’a’ ‘b’ 1) or (‘ab’=’a’ ‘b My<strong>SQL</strong> concatenation. If successful,<br />

it returns the same information as an<br />

always true condition<br />

1 or ‘ ab’=’a’||’b’ 1) or (‘ab’=’a’||‘b’ Oracle concatenation. If successful,<br />

it returns the same information as an<br />

always true condition<br />

As you can see from Table 2.2, all the injection strings follow similar principles. Confirming<br />

the existence of an <strong>SQL</strong> injection vulnerability is just a matter of underst<strong>and</strong>ing what is being<br />

executed server-side <strong>and</strong> injecting the conditions that you need for each particular case.<br />

Terminating <strong>SQL</strong> <strong>Injection</strong><br />

There are several techniques for confirming the existence of <strong>SQL</strong> injection vulnerabilities. In<br />

the previous section you saw inline injection techniques, <strong>and</strong> in this section you will see<br />

how to create a valid <strong>SQL</strong> statement through its termination. <strong>Injection</strong>-terminating an <strong>SQL</strong><br />

statement is a technique whereby the attacker injects <strong>SQL</strong> code <strong>and</strong> successfully finalizes the<br />

statement by commenting the rest of the query. Figure 2.14 shows a diagram introducing the<br />

concept of <strong>SQL</strong> injection termination.

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

Saved successfully!

Ooh no, something went wrong!