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.

Contents xi<br />

LAPSE. .................................................. 127<br />

Security Compass Web Application Analysis Tool (SWAAT).. . . . . . . . . . . . 128<br />

Microsoft Source Code Analyzer for <strong>SQL</strong> <strong>Injection</strong>................... 128<br />

Microsoft Code Analysis Tool .NET (CAT.NET)..................... 129<br />

Commercial Source Code Review Tools.. . . . . . . . . . . . . . . . . . . . . . . . . . 129<br />

Ounce.................................................... 131<br />

Source Code Analysis.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131<br />

CodeSecure.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132<br />

Summary. ................................................... 133<br />

Solutions Fast Track.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133<br />

Frequently Asked Questions.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135<br />

Chapter 4 Exploiting <strong>SQL</strong> <strong>Injection</strong> .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137<br />

Introduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138<br />

Underst<strong>and</strong>ing Common Exploit Techniques. ......................... 139<br />

Using Stacked Queries.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141<br />

Identifying the Database.......................................... 142<br />

Non-Blind Fingerprint........................................ 142<br />

Banner Grabbing.......................................... 144<br />

Blind Fingerprint............................................ 146<br />

Extracting Data through UNION Statements.. . . . . . . . . . . . . . . . . . . . . . . . . 148<br />

Matching Columns. ......................................... 149<br />

Matching Data Types .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151<br />

Using Conditional Statements. .................................... 156<br />

Approach 1: Time-based....................................... 157<br />

Approach 2: Error-based....................................... 159<br />

Approach 3: Content-based. ................................... 161<br />

Working with Strings......................................... 161<br />

Extending the Attack .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163<br />

Using Errors for <strong>SQL</strong> <strong>Injection</strong>. ................................ 164<br />

Error Messages in Oracle .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167<br />

Enumerating the Database Schema.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170<br />

<strong>SQL</strong> Server .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171<br />

My<strong>SQL</strong>................................................... 177<br />

Oracle.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180<br />

Escalating Privileges............................................. 183<br />

<strong>SQL</strong> Server .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184<br />

Privilege Escalation on Unpatched Servers.. . . . . . . . . . . . . . . . . . . . . . 189<br />

Oracle.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

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

Saved successfully!

Ooh no, something went wrong!