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.

416 Chapter 10 • References<br />

Introduction<br />

This chapter contains a number of topics that should be useful reference items for<br />

underst<strong>and</strong>ing <strong>SQL</strong> injection. These range from a simple introduction to the basic<br />

Structured Query Language (<strong>SQL</strong>) itself, to helping you underst<strong>and</strong> how <strong>SQL</strong> works<br />

under normal circumstances, therefore helping you to rewrite <strong>SQL</strong> statements in a way<br />

that continues to be syntactically correct.<br />

Additionally, the chapter provides a series of <strong>SQL</strong> injection cheat sheets for quickly<br />

jumping to the material you’re interested in, perhaps just to remind you how <strong>SQL</strong> injection<br />

works or what the syntax is. I have also provided a table of troubleshooting tips which will<br />

assist you in overcoming the most commonly encountered problems when exploiting <strong>SQL</strong><br />

injection vulnerabilities. Finally, you’ll find some information about databases not discussed<br />

in this book—we’ve used Microsoft <strong>SQL</strong> Server, Oracle, <strong>and</strong> My<strong>SQL</strong> in our examples so<br />

far, largely due to their widespread adoption in the real world. Check out “<strong>SQL</strong> <strong>Injection</strong><br />

on Other Platforms” for information about exploiting <strong>SQL</strong> injection on platforms other<br />

than those.<br />

Structured Query<br />

Language (<strong>SQL</strong>) Primer<br />

<strong>SQL</strong> was originally developed at IBM in the early 1970s but was not officially formalized until<br />

1986 by the American National St<strong>and</strong>ards Institute (ANSI). <strong>SQL</strong> was initially designed as a<br />

data query <strong>and</strong> manipulation language with limited functionality when compared to today’s<br />

feature-rich <strong>SQL</strong> dialects. In this section, I’ll provide a brief overview of the common <strong>SQL</strong><br />

queries, operators, <strong>and</strong> features. If you are already familiar with <strong>SQL</strong>, you can skip this section.<br />

Each major database vendor has extended the <strong>SQL</strong> st<strong>and</strong>ard to introduce features specific<br />

to their own product. For our purposes, we will use the <strong>SQL</strong> st<strong>and</strong>ard defined by the<br />

International Organization for St<strong>and</strong>ardization (ISO) since this will be valid for most database<br />

platforms. Where necessary I will highlight platform-specific variations to the st<strong>and</strong>ard.<br />

<strong>SQL</strong> Queries<br />

<strong>SQL</strong> queries are made up of one or more <strong>SQL</strong> statements that are effectively instructions<br />

for the database server to carry out. The most common <strong>SQL</strong> statements you will encounter<br />

when working with a database or performing <strong>SQL</strong> injection are SELECT, INSERT,<br />

UPDATE, CREATE, UNION SELECT, <strong>and</strong> DELETE.<br />

<strong>SQL</strong> queries that are designed to read, delete, or update table data will often include a<br />

conditional clause to target specific rows in a table. A conditional clause begins with<br />

WHERE followed by the condition. The OR <strong>and</strong> AND operators are used when multiple<br />

conditions are to be evaluated.

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

Saved successfully!

Ooh no, something went wrong!