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.

442 Chapter 10 • References<br />

sub encode_sql{<br />

@subvar=@_;<br />

my $sqlstr =$subvar[0];<br />

@ASCII = unpack("C*", $sqlstr);<br />

foreach $line (@ASCII) {<br />

$encoded = sprintf('%lx',$line);<br />

$encoded_comm<strong>and</strong> .= $encoded;<br />

}<br />

return $encoded_comm<strong>and</strong>;<br />

}<br />

HTTP Encoding<br />

You can sometimes bypass input validation filters that reject known bad characters<br />

(often referred to as blacklisting) by encoding your input using exotic encoding st<strong>and</strong>ards<br />

or via double encoding. Table 10.19 lists common <strong>SQL</strong> metacharacters in a number of<br />

encoded formats.<br />

Table 10.19 Encoded <strong>SQL</strong> Metacharacters<br />

Character<br />

Encoded Variants<br />

' %27<br />

%2527<br />

%u0027<br />

%u02b9<br />

%ca%b9<br />

" %22<br />

%2522<br />

%u0022<br />

%uff02<br />

%ef%bc%82<br />

; %3b<br />

%253b<br />

%u003b<br />

%uff1b<br />

%ef%bc%9b<br />

( %28<br />

%2528<br />

%u0028<br />

%uff08<br />

%ef%bc%88<br />

Continued

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

Saved successfully!

Ooh no, something went wrong!