Skip to content
SQL injection Write-up Beginner

Microsoft Sql Injection

A SQL injection in a Microsoft SQL Server-backed web application allowed an attacker to enumerate databases, tables and columns and then dump usernames and passwords from a users table. The author demonstrates the full manual exploitation chain against a lab machine.

S12 - 0x12Dark Development Follow

Published on systemweakness.com

Welcome to a new article, today I will show you how to exploit a SQL injection in a Microsoft database, first of all, many of the options are the same as in a normal SQL database, but the time to create and use most payloads if they have difference, but the methodology would be the same as in any other basic SQL…

S12 - 0x12Dark Development, on systemweakness.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 application concatenated user input directly into a SQL query without parameterisation, and its blacklist of keywords was incomplete.

Impact

An attacker could read arbitrary data from the database, including user credentials, which could lead to account compromise.

What the attacker needed

A vulnerable input field; no authentication needed beyond reaching the page

The fix

The application should build queries with parameterised statements instead of concatenating input, and should not rely on keyword blacklists.

How it was found

  1. Find the number of columns in the query, first with an ORDER BY technique and then with UNION SELECT because ORDER was blacklisted.
  2. Use UNION SELECT to find which column positions are reflected in the page output.
  3. Enumerate the current user, the database version and the current database name.
  4. List all databases, then list the tables in the target database and note the users table.
  5. List the columns of the users table by its object id.
  6. Dump the username and password columns 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.

A SQL injection happens when a website puts whatever you type into a database query without cleaning it, so you can sneak in extra database commands. Here the attacker added their own query parts to make the site reveal the names of databases, tables and columns, and finally the stored usernames and passwords. Anyone who can reach that input could read the same data.

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 S12 - 0x12Dark Development

View all

13 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.