TechBizAcademy

04SQL Injection: From Error to Data

Confirm an injectable parameter, count columns, pivot to UNION SELECT and dump the credential table.

0 / 0
root@techbiz-lab — practice range
root@techbiz-lab:~#

About this lab

SQL injection happens when user input is concatenated into a database query instead of being passed as a parameter. The database cannot tell the difference between the developer's query and your addition to it, so it runs both.

The progression in this lab is the one used in real testing: prove the parameter is injectable, work out how many columns the query returns, find which of those columns are printed back to you, then use UNION SELECT to put data of your choosing into those columns.

What you will do

  1. Break the query with a single quote and read the error message that comes back.
  2. Count the columns the original query returns using ORDER BY.
  3. Identify which columns are actually rendered on the page.
  4. Pivot to UNION SELECT and read the database name and version.
  5. Enumerate table and column names, then dump the credential table.

Where this is used

SQL injection has been in the OWASP Top Ten since the list existed and still appears in real assessments, usually in an old internal application nobody wants to touch. Understanding the attack is also the only way to explain convincingly why parameterised queries are not optional.

Simulated environment — no real systems are contacted. Only ever test systems you own or are authorised in writing to test.