Manual SQL Injection Discovery Tips
Manual SQL Injection Discovery Tips
Gerben Javado
Discovery
The first part of finding a valid SQLi is the discovery of the
vulnerability. Here the most important thing is to know in
which SQL context your input can end up. Here some basic
examples:
https://gerbenjavado.com/manual-sql-injection-discovery-tips/ 1/6
5/3/22, 12:55 PM Manual SQL injection discovery tips
Once you are able to make the server return an error (mostly
HTTP 500 status) you have to confirm it is the SQL command
that is causing the error and not something like a date parser.
To do this you can use a range of tricks:
Example
To make this more clear we have the following URL:
https://www.example.com/php/sales_dash_poc_handle.php?
action=month-
breakdown&type_of_report=billing&city=all&month=8&year=2017&poc=3514100
https://gerbenjavado.com/manual-sql-injection-discovery-tips/ 2/6
5/3/22, 12:55 PM Manual SQL injection discovery tips
Exploitation
After you have found a SQLi you always have to try to proof at
least a difference in output (for boolean and sleep based) or
sensitive data in the output (for error and union based).
Unfortunately this is not always straightforward especially
with firewalls and blacklisting in the way. This section is to
help you get around those.
Firewall
The first thing you should try when dealing with a firewall is
see if you can find a misconfiguration in the setup. For most of
these firewalls and CDN's you can access the unprotected
website by visiting the original IP (which the firewall is
standing in front of) and then using the original domain name
as host value. The first step here is to find the original IP of
the website, this is often not too hard using services that keep
track of the IP's a website has used
(http://viewdns.info/iphistory/). Often the one used before
the firewall IP comes in is the one they still use (basically the
one after it says cloudflare or akamai). Shodan can also be
really usefull when it comes to finding an original IP.
After you have found the original IP address try to access the
website with the original Host header. In cURL this works like
this (adding a header also works in sqlmap):
https://gerbenjavado.com/manual-sql-injection-discovery-tips/ 3/6
5/3/22, 12:55 PM Manual SQL injection discovery tips
54.165.170.2 www.example.com
https://www.example.com/php/analyticsExcel.php?
action=res_unique_analytics&resid=2100935&start_date=2016-
https://gerbenjavado.com/manual-sql-injection-discovery-tips/ 4/6
5/3/22, 12:55 PM Manual SQL injection discovery tips
07-11 00:00:00&end_date=2017-08-11
23:59:59&action=res_unique_analytics&entity_type=restaurant
2100935' OR
IF(MID(@@version,1,1)='5',sleep(1),1)='2
Response:
2100935' OR
https://gerbenjavado.com/manual-sql-injection-discovery-tips/ 5/6
5/3/22, 12:55 PM Manual SQL injection discovery tips
IF(MID(@@version,1,1)='4',sleep(1),1)='2
Response:
HTTP/1.1 200 OK
Summary
If injecting a single quote leads to different output in the
response try the different techniques outlined in this blog to
see if you are dealing with a SQLi. After you have determined
in which SQL context you are working develop a POC that
either shows sensitive data (error and union based) or shows
a difference in output depending on whether the question
asked is true or false (boolean and time based).
https://gerbenjavado.com/manual-sql-injection-discovery-tips/ 6/6