Skip to content
SQL injection Write-up Beginner

BSQL Injection Shenanigans 2

A shopping app's search parameter was vulnerable to SQL injection, allowing the author to use UNION-based queries to enumerate database tables and columns and extract usernames and passwords. The author also found that a time-based payload worked, confirming blind injection.

callgh0st Follow

Published on infosecwriteups.com

This is a lab from TCM Academy, and only those who have purchased the course can access the walkthrough for all the labs. I obtained the lab Docker file from the Cybermentor YouTube channel in an attempt to solve as much as I can.

callgh0st, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the search term was inserted directly into a database query without parameterisation, so injected SQL was executed.

Impact

An attacker could read the contents of the database, including usernames and passwords, through the search feature.

What the attacker needed

Access to the shopping app; none

How it was found

  1. Search for a product and append a comment sequence to the search term to see if the query is altered.
  2. Use ORDER BY with increasing column numbers to find the number of columns.
  3. Use ORDER BY with quoted strings to determine column data types.
  4. Use a time-based payload to confirm the injection works.
  5. Use UNION SELECT against information_schema.tables to list table names.
  6. Use UNION SELECT against information_schema.columns to list columns, then extract username and password from the users table.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The search box on a shopping site was built in a way that let a user sneak database commands into the search text. Because the site showed the results of those commands on the page, the author could list the database's tables and read stored usernames and passwords.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by callgh0st

View all

5 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.