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.

312 Chapter 9 n Attacking Data Stores<br />

n When attempting to inject batched queries into an MS-SQL database,<br />

you do not need to use <strong>the</strong> semicolon separator. Provided that you fix<br />

<strong>the</strong> syntax of all queries in <strong>the</strong> batch, <strong>the</strong> query parser will interpret <strong>the</strong>m<br />

correctly, whe<strong>the</strong>r or not you include a semicolon.<br />

TRY IT!<br />

http://mdsec.net/addressbook/71/<br />

http://mdsec.net/addressbook/76/<br />

Circumventing Simple Validation<br />

Some input validation routines employ a simple blacklist and ei<strong>the</strong>r block or<br />

remove any supplied data that appears on this list. In this instance, you should<br />

try <strong>the</strong> standard attacks, looking for common defects in validation and canonicalization<br />

mechanisms, as described in Chapter 2. For example, if <strong>the</strong> SELECT<br />

keyword is being blocked or removed, you can try <strong>the</strong> following bypasses:<br />

SeLeCt<br />

%00SELECT<br />

SELSELECTECT<br />

%53%45%4c%45%43%54<br />

%2553%2545%254c%2545%2543%2554<br />

TRY IT!<br />

http://mdsec.net/addressbook/58/<br />

http://mdsec.net/addressbook/62/<br />

Using SQL Comments<br />

You can insert inline comments into SQL statements in <strong>the</strong> same way as for C++,<br />

by embedding <strong>the</strong>m between <strong>the</strong> symbols /* and */. If <strong>the</strong> <strong>application</strong> blocks<br />

or strips spaces from your input, you can use comments to simulate whitespace<br />

within your injected data. For example:<br />

SELECT/*foo*/username,password/*foo*/FROM/*foo*/users<br />

In MySQL, comments can even be inserted within keywords <strong>the</strong>mselves,<br />

which provides ano<strong>the</strong>r means of bypassing some input validation filters while<br />

preserving <strong>the</strong> syntax of <strong>the</strong> actual query. For example:<br />

SEL/*foo*/ECT username,password FR/*foo*/OM users

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

Saved successfully!

Ooh no, something went wrong!