ストーリー
佐
佐藤CTO
自動スキャンでは見つからない脆弱性がある。攻撃者と同じ思考プロセスで、能動的に脆弱性を探す — それがペネトレーションテストだ
佐藤CTOがBurp Suiteの画面を見せました。
佐
佐藤CTO
ペンテストは闇雲にやるものじゃない。PTES(Penetration Testing Execution Standard)に従って体系的に行う。スコープの定義から報告書の作成まで、プロフェッショナルな方法論を学ぼう
ペネトレーションテストとは
脆弱性スキャンとの違い
| 観点 | 脆弱性スキャン | ペネトレーションテスト |
|---|
| 目的 | 既知の脆弱性の検出 | 脆弱性の実際の悪用可能性を検証 |
| 手法 | 自動化ツール | 人間の判断 + ツール |
| 深さ | 広く浅く | 狭く深く |
| 頻度 | 継続的(CI/CD統合) | 定期的(四半期〜年1回) |
| 成果物 | 脆弱性リスト | 攻撃シナリオ + 影響評価 + 対策提案 |
テスト種別
| 種別 | 説明 | 攻撃者の情報 |
|---|
| Black Box | 外部攻撃者を模擬 | 公開情報のみ |
| Gray Box | 一般ユーザーの権限あり | 認証情報 + 基本的なドキュメント |
| White Box | 内部者を模擬 | ソースコード + アーキテクチャ図 |
PTES(Penetration Testing Execution Standard)
7フェーズの方法論
graph LR
S1["1. 事前交渉"] --> S2["2. 情報収集"]
S2 --> S3["3. 脅威モデリング"]
S3 --> S4["4. 脆弱性分析"]
S4 --> S5["5. 実際の攻撃"]
S5 --> S6["6. ポストエクスプロイト"]
S6 --> S7["7. 報告書作成"]
classDef planning fill:#0d6efd,stroke:#0a58ca,color:#fff
classDef recon fill:#198754,stroke:#146c43,color:#fff
classDef attack fill:#e94560,stroke:#c23050,color:#fff
classDef report fill:#f5a623,stroke:#c47d10,color:#fff
class S1 planning
class S2,S3,S4 recon
class S5,S6 attack
class S7 report
| フェーズ | 内容 | 成果物 |
|---|
| 事前交渉 | スコープ、ルール、日程の合意 | テスト計画書 |
| 情報収集 | OSINT、ポートスキャン、技術特定 | 情報収集レポート |
| 脅威モデリング | 攻撃シナリオの策定 | 脅威モデル |
| 脆弱性分析 | スキャン結果の分析と検証 | 脆弱性リスト |
| 攻撃実施 | 脆弱性の悪用と影響確認 | 攻撃ログ |
| ポストエクスプロイト | 権限昇格、データアクセス検証 | 影響範囲レポート |
| 報告書作成 | 結果の文書化と対策提案 | 最終報告書 |
情報収集(Reconnaissance)
パッシブ情報収集
// パッシブ情報収集の自動化例
interface ReconResult {
domain: string;
subdomains: string[];
technologies: string[];
endpoints: string[];
emails: string[];
dnsRecords: DNSRecord[];
}
// サブドメイン列挙(パッシブ)
// ツール: subfinder, amass
// subfinder -d example.com -silent -o subdomains.txt
// 技術スタック特定
// ツール: Wappalyzer, whatweb
// whatweb https://example.com
// DNS情報収集
// dig example.com ANY
// nslookup -type=mx example.com
アクティブ情報収集
# ポートスキャン(Nmap)
# nmap -sV -sC -p- -T4 target.example.com
# -sV: バージョン検出
# -sC: デフォルトスクリプト実行
# -p-: 全65535ポートスキャン
# -T4: アグレッシブなタイミング
# Webアプリケーションのディレクトリ列挙
# gobuster dir -u https://target.example.com -w /usr/share/wordlists/dirb/common.txt
Burp Suite の活用
Burp Suite のコア機能
| 機能 | 用途 |
|---|
| Proxy | HTTPリクエスト/レスポンスの傍受・改変 |
| Scanner | 自動脆弱性スキャン |
| Repeater | リクエストの手動再送・改変 |
| Intruder | パラメータのファジング(ブルートフォース) |
| Decoder | エンコード/デコード(Base64, URL等) |
| Comparer | レスポンスの比較 |
テストシナリオ例
// ペンテストのチェックリストをコード化
interface PenTestChecklist {
category: string;
tests: {
id: string;
name: string;
method: string;
expectedResult: string;
severity: 'Critical' | 'High' | 'Medium' | 'Low' | 'Info';
}[];
}
const authenticationTests: PenTestChecklist = {
category: '認証テスト',
tests: [
{
id: 'AUTH-001',
name: 'ブルートフォース耐性',
method: '同一アカウントに対して100回連続でログイン失敗を試行',
expectedResult: '5回失敗後にアカウントロックまたはCAPTCHA表示',
severity: 'High',
},
{
id: 'AUTH-002',
name: 'パスワードポリシー',
method: '弱いパスワード("password", "123456")でアカウント作成を試行',
expectedResult: '弱いパスワードが拒否される',
severity: 'Medium',
},
{
id: 'AUTH-003',
name: 'セッション固定攻撃',
method: 'ログイン前後でセッションIDが変更されるか確認',
expectedResult: 'ログイン後に新しいセッションIDが発行される',
severity: 'High',
},
{
id: 'AUTH-004',
name: 'JWTアルゴリズム変更攻撃',
method: 'JWTのalgをnoneまたはHS256に変更してリクエスト',
expectedResult: '不正なアルゴリズムが拒否される',
severity: 'Critical',
},
{
id: 'AUTH-005',
name: 'パスワードリセットフロー',
method: 'リセットトークンの予測可能性、有効期限、再利用を検証',
expectedResult: 'トークンはランダムで期限付き、1回限り使用可能',
severity: 'High',
},
],
};
const authorizationTests: PenTestChecklist = {
category: '認可テスト',
tests: [
{
id: 'AUTHZ-001',
name: 'IDOR(Insecure Direct Object Reference)',
method: '他ユーザーのリソースIDを使ってアクセスを試行',
expectedResult: 'アクセスが拒否される(403 or 404)',
severity: 'Critical',
},
{
id: 'AUTHZ-002',
name: '水平権限昇格',
method: '一般ユーザーAの認証情報でユーザーBのリソースにアクセス',
expectedResult: 'アクセスが拒否される',
severity: 'High',
},
{
id: 'AUTHZ-003',
name: '垂直権限昇格',
method: '一般ユーザーの認証情報で管理者APIエンドポイントにアクセス',
expectedResult: 'アクセスが拒否される',
severity: 'Critical',
},
{
id: 'AUTHZ-004',
name: 'HTTPメソッド改ざん',
method: 'GETのみ許可のエンドポイントにPUT/DELETEリクエスト送信',
expectedResult: '405 Method Not Allowedが返される',
severity: 'Medium',
},
],
};
OWASP ZAP の活用
# ZAPの自動スキャン設定
# Active Scan Policy の設定例
scanPolicy:
name: "Production Scan Policy"
defaultStrength: MEDIUM
defaultThreshold: MEDIUM
rules:
# 高リスクのルールは強力にスキャン
- id: 40012 # Cross Site Scripting (Reflected)
strength: HIGH
threshold: LOW
- id: 40014 # Cross Site Scripting (Persistent)
strength: HIGH
threshold: LOW
- id: 40018 # SQL Injection
strength: INSANE
threshold: LOW
- id: 40032 # Server Side Request Forgery
strength: HIGH
threshold: MEDIUM
# 情報漏洩系は中程度
- id: 10021 # X-Content-Type-Options Header Missing
strength: MEDIUM
threshold: MEDIUM
ペネトレーションテスト報告書
報告書テンプレート
報告書の構成
| セクション | 内容 |
|---|
| エグゼクティブサマリー | 非技術者向けの概要(リスクレベル、主要な発見事項) |
| スコープと方法論 | テスト対象、テスト種別、使用ツール |
| 発見事項一覧 | 脆弱性の一覧(重要度順) |
| 詳細分析 | 各脆弱性の説明、再現手順、影響範囲、対策 |
| 対策の優先順位 | 短期・中期・長期の改善ロードマップ |
| 付録 | スキャン結果の生データ、スクリーンショット |
発見事項のフォーマット
interface Finding {
id: string;
title: string;
severity: 'Critical' | 'High' | 'Medium' | 'Low' | 'Info';
cvss: number;
affectedComponent: string;
description: string;
reproductionSteps: string[];
impact: string;
recommendation: string;
references: string[];
evidence: string; // スクリーンショットやリクエスト/レスポンスのログ
}
まとめ
| ポイント | 内容 |
|---|
| ペネトレーションテスト | 脆弱性の実際の悪用可能性を人間の判断で検証 |
| PTES | 7フェーズの体系的な方法論 |
| 情報収集 | パッシブ(OSINT)とアクティブ(ポートスキャン)の2段階 |
| Burp Suite | HTTPプロキシベースの手動テストツール |
| 報告書 | エグゼクティブサマリーから技術的詳細まで構造化 |
チェックリスト
次のステップへ
次は「APIセキュリティ診断」を学びます。OWASP API Security Top 10に基づくAPIの脆弱性と、その対策を身につけましょう。
推定読了時間: 40分