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.

446 Chapter 10 • References<br />

Table 10.20 Continued. Troubleshooting <strong>SQL</strong> <strong>Injection</strong> Reference<br />

Error/Challenge<br />

Error Message<br />

Illegal mix of collations<br />

(latin1_swedish_ci,IMPLICIT)<br />

<strong>and</strong> (utf8_general_ci,<br />

SYSCONST) for operation<br />

‘UNION’<br />

Challenge<br />

You receive a “collation<br />

conflict” message when<br />

performing a UNION<br />

SELECT attack against a<br />

Microsoft <strong>SQL</strong> Server<br />

database.<br />

Error Message<br />

Cannot resolve collation<br />

conflict for column 2 in<br />

SELECT statement.<br />

Solution<br />

One way to overcome this error is to read<br />

the Collation property from the database<br />

<strong>and</strong> then use it within the query. In the<br />

following example, we are performing a<br />

UNION ALL SELECT query to retrieve the<br />

name column from the sysobjects table.<br />

Step 1: Retrieve the collation value<br />

UNION ALL SELECT<br />

SERVERPROPERTY('Collation'),null FROM<br />

sysobjects<br />

In this example, the Collation property is<br />

set to <strong>SQL</strong>_Latin1_General_CP1_CI_AS.<br />

Step 2: Implement the collation value<br />

within the UNION SELECT<br />

UNION ALL SELECT 1,Name collate<br />

<strong>SQL</strong>_Latin1_General_CP1_CI_AS,null<br />

FROM sysobjects<br />

<strong>SQL</strong> <strong>Injection</strong> on Other Platforms<br />

This book focuses on the three most popular databases: Microsoft <strong>SQL</strong> Server, My<strong>SQL</strong>,<br />

<strong>and</strong> Oracle. This section is intended to provide a quick reference for other, less common<br />

platforms, such as Postgre<strong>SQL</strong>, DB2, Informix, <strong>and</strong> Ingres.<br />

Postgre<strong>SQL</strong> Cheat Sheet<br />

Postgre<strong>SQL</strong> is an open source database available for most operating system platforms.<br />

To download a comprehensive user manual visit www.postgresql.org/docs/manuals/.

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

Saved successfully!

Ooh no, something went wrong!