# Blind SQLi

### Blind SQL Injection

Blind SQL injection (Blind SQLi) is a type of SQL injection attack where the attacker can exploit the database, but the application does not display the output. Instead, the attacker must "infer" data by sending payloads and observing the application's behavior or responses.

**A simple example:**&#x20;

* A vulnearble webapp uses an API for its search to return the number of results found.
* A user searches for a product, and the application returns with "X products found" without displaying product details.&#x20;
* The application uses the SQL query `SELECT COUNT(*) FROM products WHERE product_name LIKE '%{searchTerm}%'`.
* An attacker could exploit this by injecting SQL conditions into the `{searchTerm}`.&#x20;
* For exmaple, searching for `laptop' AND 1=1-- -` returns "1 product found" and searching for `laptop' AND 1=2-- -` returns "0 products found", this behavior can be an indicator of a potential Blind SQLi vulnerability.

Blind SQLi is more time-consuming than regular SQLi but is just as dangerous. It can lead to:

* Sensitive data exposure
* Data manipulation
* Authentication bypass
* Potential discovery of hidden data

### Other learning resources:

* OWASP: <https://owasp.org/www-community/attacks/Blind\\_SQL\\_Injection>
* SQLmap's guide on Blind SQLi: <http://sqlmap.org/>
* PenTestMonkey's Cheat Sheet: <http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet>

### Writeups:&#x20;

### Checklist:

* [ ] Identify potential vulnerable points:
  * [ ] URL parameters
  * [ ] Form fields
  * [ ] HTTP headers (e.g. cookies, user-agent)
  * [ ] Hidden fields
* [ ] Test for true/false conditions:
  * [ ] Can you get a "true" condition? E.g., `' AND 1=1-- -`
  * [ ] Can you get a "false" condition? E.g., `' AND 1=2-- -`
* [ ] Time-based Blind SQLi:
  * [ ] Introduce artificial delays using functions like `SLEEP()` or `BENCHMARK()`
  * [ ] Measure response times
* [ ] Error-based Blind SQLi:
  * [ ] Test a divide by zero payload
  * [ ] Can we trigger an error message?
    * [ ] Can we use `CAST()` to trigger an error and view the data?
* [ ] Content-based Blind SQLi:
  * [ ] Check for changes in page content based on payloads
* [ ] Out-of-band (OAST):
  * [ ] Can we trigger a DNS query?
  * [ ] Can we append some data to the subdomain of the URL to exfiltrate information?
* [ ] Binary search based extraction:
  * [ ] Exploit faster by dividing data and querying
* [ ] Backend specifics:
  * [ ] Are you dealing with MySQL, MSSQL, Oracle, PostgreSQL, SQLite?
  * [ ] Adjust your payloads accordingly
* [ ] Test with automated tools:
  * [ ] SQLmap with `--technique=B` flag
* [ ] Encoding and obfuscation:
  * [ ] Test with URL encoding, hex encoding, or other methods to bypass filters
* [ ] Bypassing filters:
  * [ ] Use comments, spaces, or alternative syntax
* [ ] Exploitation:
  * [ ] Extract database version, e.g., `AND (SELECT SUBSTRING(version(),1,1))='5'`
  * [ ] Fetch data character by character
  * [ ] Extract data from information\_schema


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://appsecexplained.gitbook.io/appsecexplained/common-vulns/sql-injection-overview/blind-sqli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
