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.

Chapter 9 n Attacking Data Stores 333<br />

Requirement: Retrieve database version string<br />

Oracle: select banner from v$version<br />

MS-SQL: select @@version<br />

MySQL: select @@version<br />

Requirement: Retrieve current database<br />

Oracle: SELECT SYS_CONTEXT(‘USERENV’,’DB_NAME’) FROM dual<br />

MS-SQL: SELECT db_name()<br />

The server name can be retrieved using:<br />

SELECT @@servername<br />

MySQL: SELECT database()<br />

Requirement: Retrieve current user’s privilege<br />

Oracle: SELECT privilege FROM session_privs<br />

MS-SQL: SELECT grantee, table_name, privilege_type FROM<br />

INFORMATION_SCHEMA.TABLE_PRIVILEGES<br />

MySQL: SELECT * FROM information_schema.user_privileges<br />

WHERE grantee = ‘[user]’ where [user] is determined<br />

from <strong>the</strong> output of SELECT user()<br />

Requirement: Show all tables and columns in a single column of results<br />

Oracle: Select table_name||’<br />

‘||column_name from all_tab_columns<br />

MS-SQL: SELECT table_name+’<br />

‘+column_name from information_schema.columns<br />

MySQL: SELECT CONCAT(table_name,<br />

‘,column_name) from information_schema.columns<br />

Requirement: Show user objects<br />

Oracle: SELECT object_name, object_type FROM user_objects<br />

MS-SQL: SELECT name FROM sysobjects<br />

MySQL: SELECT table_name FROM information_schema.tables<br />

(or trigger_name from information_schema.triggers, etc.)<br />

Continued

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

Saved successfully!

Ooh no, something went wrong!