Automatic SQL Injection and DB Takeover Tool – SQLmap

Last Release: 01/01/2020    

Automatic SQL Injection and DB Takeover Tool – SQLmap


SQLMap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers. It comes with a powerful detection engine and many features for penetration testers.

SQLMap is capable of databases fingerprinting, fetching data from the databases, accessing the database file systems, running different commands on the target server, etc.

SQLmap: Automatic SQL Injection Tool

This very powerful exploitation tool is developed in Python an it’s FREE to use. It requires Python version 2.6.x or 2.7.x. and comes preinstalled on Kali Linux, but can be run on any platform.


SQLmap have many features divided into 3 groups:


We’ll list some of them here:

  • Full support for:MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird, Sybase and SAP MaxDB database management systems.
  • Full support for six SQL injection techniques: boolean-based blind, time-based blind, error-based, UNION query, stacked queries and out-of-band.
  • Support to directly connect to the database without passing via a SQL injection, by providing DBMS credentials, IP address, port and database name.
  • Support to enumerate users, password hashes, privileges, roles, databases, tables and columns.
  • Automatic recognition of password hash formats and support for cracking them using a dictionary-based attack.
  • Support to dump database tables entirely, a range of entries or specific columns as per user’s choice. The user can also choose to dump only a range of characters from each column’s entry.
  • Support to search for specific database names, specific tables across all databases or specific columns across all databases’ tables. This is useful, for instance, to identify tables containing custom application credentials where relevant columns’ names contain string like name and pass.
  • Capable to download and upload any file from the database server underlying file system when the database software is MySQL, PostgreSQL or Microsoft SQL Server.
  • Support to execute arbitrary commands and retrieve their standard output on the database server underlying operating system when the database software is MySQL, PostgreSQL or Microsoft SQL Server.
  • Ability to establish an out-of-band stateful TCP connection between the attacker machine and the database server underlying operating system. This channel can be an interactive command prompt, a Meterpreter session or a graphical user interface (VNC) session as per user’s choice.
  • Support for database process’ user privilege escalation via Metasploit’s Meterpreter getsystem command.


SQLmap can detect and exploit different SQL injections:

  • Boolean-based blind: sqlmap replaces or appends to the affected parameter in the HTTP request, a syntatically valid SQL statement string containing a SELECT sub-statement, or any other SQL statement whose the user want to retrieve the output.
  • Time-based blind: replaces or appends to the affected parameter in the HTTP request, a syntatically valid SQL statement string containing a query which put on hold the back-end DBMS to return for a certain number of seconds.
  • Error-based: replaces or appends to the affected parameter a database-specific error message provoking statement and parses the HTTP response headers and body in search of DBMS error messages containing the injected pre-defined chain of characters and the subquery statement output within.
  • UNION query-based: sqlmap appends to the affected parameter a syntactically valid SQL statement starting with an UNION ALL SELECT.
  • Stacked queries, also known as piggy backing: sqlmap tests if the web application supports stacked queries and then, in case it does support, it appends to the affected parameter in the HTTP request, a semi-colon (;) followed by the SQL statement to be executed.

Given that these are just basic explanations of techniques, you can read a more detailed explanation on the official SQLmap wiki page.



  • Python version 2.6.x or 2.7.x.

If you want to connect directly to a database server, you need to install the following Python bindings:


  • NTLM: python-ntlm (for web application attack behind NTLM authentication)
  • Readline: PyReadline (Windows users)

SQLmap Install

Clone it form the Git repository:

git clone sqlmap-dev

You can also download the latest .tar.gz or .zip.

To update sqlmap run:

python --update


Type -h for basic options list:

python -h

or -hh to get a full list of options and switches:

python -hh

Sqlmap: Automatic Sql Injection example run

To see all of the sqlmap capabilities, list of supported features, all options, switches and examples click the DOCUMENTATION link bellow.

Documentation Box
Download Box