sqlmap Command-Line Cheat Sheet

Photo by Cookiecutter on Pexels
Published 20 April 2024 Last updated 20 April 2024 An older guide that hasn't been re-checked yet, so commands or versions may have moved on. How guides are made and checked

This cheat sheet references some of the most commonly used sqlmap commands. Whether you’re a seasoned professional looking to brush up on your command-line skills or a newcomer eager to explore the possibilities of networking through sqlmap, you’ll find valuable insights and shortcuts here.

Installation

DistributionCommand
Debian/Ubuntusudo apt-get install sqlmap
CentOS/Fedora/Red Hatsudo yum install sqlmap
NixOSnix-env -iA nixos.sqlmap

Usage

TaskCommand
Basic SQL injection testsqlmap -u http://example.com

sqlmap Command Switches

SwitchDescription
--url or -uTarget URL to scan for SQL injection vulnerabilities.
--dataRetrieve the DBMS banner (version and other details).
--cookieUse specified HTTP Cookie header value for the requests.
--dbsEnumerate DBMS databases on the target.
--tablesEnumerate DBMS database tables from a specific database.
--dumpDump the contents of a database table.
--os-shellPrompt for an interactive operating system shell.
--batchNever ask for user input, use default behavior.
--bannerUse the Tor anonymity network to make all HTTP requests.
--torRetrieve DBMS’s current user.
--proxyUse a proxy to connect to the target URL.
--random-agentUse a randomly selected HTTP User-Agent header value.
--is-dbaDetect whether the DBMS current user is DBA (Database Admin).
--techniqueSQL injection techniques to use (e.g., B for Boolean-based).
--threadsNumber of concurrent HTTP(s) requests.
--levelLevel of tests to perform (1-5, default 1).
--riskRisk of tests to perform (1-3, default 1).
--current-userRetrieve DBMS’s current database.
--current-dbDump all databases’ table entries.
--countRetrieve the number of entries for tables.
--dump-allUse the given script(s) for tampering injection data.
--sql-shellPrompt for an interactive SQL shell.
--sql-queryExecute the given SQL statement against the database.
--tamperUse given script(s) for tampering injection data.

Wrapping Up

This sqlmap cheat sheet has highlighted the tool’s flexibility and power for everything from simple tasks to advanced operations. Mastering sqlmap can significantly boost your networking skills. Keep practising, exploring further resources, and share your findings to deepen your understanding and contribute to the community’s collective knowledge.

You May Also Be Interested In

References

This table lists some of the most frequently used switches in sqlmap. For a comprehensive list and detailed explanations, refer to the official sqlmap documentation.