Blind SQLi

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:

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

  • 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}.

  • 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:

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

Last updated