19.09.2017 Views

the-web-application-hackers-handbook

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

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

828 Chapter 21 n A Web Application Hacker’s Methodology<br />

As always, be sure to URL-encode characters such as + and space that<br />

have special meaning within HTTP requests.<br />

7.2.5 If <strong>the</strong> original input is numeric, try using a ma<strong>the</strong>matical expression that<br />

is equivalent to <strong>the</strong> original value. For example, if <strong>the</strong> original value was<br />

2, try submitting 1+1 or 3–1. If <strong>the</strong> <strong>application</strong> responds in <strong>the</strong> same way,<br />

it may be vulnerable, particularly if <strong>the</strong> value of <strong>the</strong> numeric expression<br />

has a systematic effect on <strong>the</strong> <strong>application</strong>’s behavior.<br />

7.2.6 If <strong>the</strong> preceding test is successful, you can gain fur<strong>the</strong>r assurance that<br />

a SQL injection vulnerability is involved by using SQL-specific ma<strong>the</strong>matical<br />

expressions to construct a particular value. If <strong>the</strong> <strong>application</strong>’s<br />

logic can be systematically manipulated in this way, it is almost certainly<br />

vulnerable to SQL injection. For example, both of <strong>the</strong> following items<br />

are equivalent to <strong>the</strong> number 2:<br />

67-ASCII(‘A’)<br />

51-ASCII(1)<br />

7.2.7 If ei<strong>the</strong>r of <strong>the</strong> fuzz test cases using <strong>the</strong> waitfor command resulted<br />

in an abnormal time delay before <strong>the</strong> <strong>application</strong> responded, this is a<br />

strong indicator that <strong>the</strong> database type is MS-SQL and <strong>the</strong> <strong>application</strong><br />

is vulnerable to SQL injection. Repeat <strong>the</strong> test manually, specifying different<br />

values in <strong>the</strong> waitfor parameter, and determine whe<strong>the</strong>r <strong>the</strong> time<br />

taken to respond varies systematically with this value. Note that your<br />

attack payload may be inserted into more than one SQL query, so <strong>the</strong><br />

time delay observed may be a fixed multiple of <strong>the</strong> value specified.<br />

7.2.8 If <strong>the</strong> <strong>application</strong> is vulnerable to SQL injection, consider what kinds<br />

of attacks are feasible and likely to help you achieve your objectives.<br />

Refer to Chapter 9 for <strong>the</strong> detailed steps needed to carry out any of <strong>the</strong><br />

following attacks:<br />

n Modify <strong>the</strong> conditions within a WHERE clause to change <strong>the</strong> <strong>application</strong>’s<br />

logic (for example, by injecting or 1=1-- to bypass a login).<br />

n Use <strong>the</strong> UNION operator to inject an arbitrary SELECT query and combine<br />

<strong>the</strong> results with those of <strong>the</strong> <strong>application</strong>’s original query.<br />

n Fingerprint <strong>the</strong> database type using database-specific SQL syntax.<br />

n If <strong>the</strong> database type is MS-SQL and <strong>the</strong> <strong>application</strong> returns ODBC error<br />

messages in its responses, leverage <strong>the</strong>se to enumerate <strong>the</strong> database<br />

structure and retrieve arbitrary data.<br />

n If you cannot find a way to directly retrieve <strong>the</strong> results of an arbitrary<br />

injected query, use <strong>the</strong> following advanced techniques to extract data:<br />

n Retrieve string data in numeric form, one byte at a time.<br />

n Use an out-of-band channel.

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

Saved successfully!

Ooh no, something went wrong!