SQHell: Manually hunting SQL injection with detailed explanation
The write-up demonstrates five different SQL injection vulnerabilities in a CTF room, including login bypass, UNION-based extraction, boolean-based blind injection, a second-order injection, and time-based injection via the X-Forwarded-For header. An attacker could extract flags from the database using these techniques.
medium.com
Published on medium.com
In this write-up, my goal is to teach you how to hunt advanced SQL injections in a web application, and we will implement all the techniques in a CTF room, ‘SQHell’ on TryHackMe. On each injection technique, you will be able to know the expected backend logic that is vulnerable to SQLi & why this injection or payload…
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
Impact
An attacker could bypass authentication and extract sensitive data such as flags from the database.
What the attacker needed
Access to the target web application; Ability to intercept and modify HTTP requests
How it was found
- Access the login page and inject a payload to bypass authentication.
- In the post view, use ORDER BY to determine the number of columns returned.
- Use UNION SELECT to list databases, tables, and columns, then dump the flag.
- At the registration username check, use boolean-based injection to extract the database name, table name, column name, and flag character by character.
- In the user id parameter, use UNION SELECT to inject into a second query and extract the flag.
- Add an X-Forwarded-For header with a time-based SQL injection payload to extract the flag via response delays.
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.
SQL injection is when user input is inserted into a database query without proper handling, letting an attacker change the query's meaning. Here, the author shows several ways to trick the database into revealing hidden data, such as bypassing a login or extracting secret flags.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.