aws-penetration-testing
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.
By sickn33 · 388 installs
npx skills add sickn33/agentic-awesome-skills --skill aws-penetration-testing
Source repository · Upstream listing
⚠️ AUTHORIZED USE ONLY
This skill is for educational purposes or authorized security assessments only.
You must have explicit, written permission from the system owner before using this tool.
Misuse of this tool is illegal and strictly prohibited.
Mandatory confirmation gate
Before running any command that probes, exploits, changes, persists on, extracts data from, or attempts credential access against a target:
1. Ask the user to state the exact target URL, IP, account, or resource.
2. Ask the user to confirm written authorization and the permitted scope.
3. Show the exact command(s) and explain their expected effect.
4. Wait for explicit confirmation in the current conversation.
Without that confirmation, remain read only and provide defensive guidance only. Prefer a sandbox, disposable VM, or controlled lab.
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:
Step 2: IAM Enumeration
Step 3: Metadata SSRF (EC2)
Exploit SSRF to access metadata endpoint (IMDSv1):
For IMDSv2 (token required):
Fargate Container Credentials:
Privilege Escalation Techniques
Shadow Admin Permissions
These permissions can enable escalation only when their allowed resources, conditions and effective policies permit the chain. They are not inherently administrator equivalent:
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
Attach Admin Policy
Add Inline Admin Policy
Lambda Privilege Escalation
S3 Bucket Exploitation
Bucket Discovery
Bucket Enumeration
Public Bucket Search
Lambda Exploitation
SSM Command Execution
Systems Manager allows command execution on EC2 instances:
EC2 Exploitation
Mount EBS Volume
Shadow Copy Attack (Windows DC)
Console Access from API Keys
Convert CLI credentials to console access:
Logging control validation in a disposable lab
Preserve audit evidence
Do not change user agents or disable logging to evade detection. A user agent alone does not establish whether GuardDuty alerts will fire; validate detections with the monitoring owner. The commands above are destructive configuration examples for a separately approved disposable lab, not cleanup steps.
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
Troubleshooting
Issue Solution
Access Denied on all commands Enumerate permissions with enumerate iam
Metadata endpoint blocked Check for IMDSv2, try container metadata
GuardDuty alerts Coordinate expected test alerts and preserve evidence with the monitoring owner
Expired credentials Re fetch from metadata (temp creds rotate)
CloudTrail logging actions Preserve logging and review test events with the monitoring owner
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](references/advanced aws pentesting.md).
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Effective access and evidence limits
Inventory commands are not proof of exploitability. Account for explicit denies, SCPs/RCPs, boundaries, session policies, resource policies, conditions and service prerequisites. Updating Lambda code uses its execution role only when the code is actually invoked; iam:PassRole needs a compatible trusted service and a usable role. IMDSv2 requires the SSRF primitive to support the token PUT and required headers; the local curl example does not establish a remote bypass. A role name such as AdminRole proves no permission level.
Use named short lived profiles or approved credential providers. Do not pass secrets as command line arguments, retain real keys in shell history, dump all bucket/table data by default or upload artifacts to a different account. Prefer owner created canary objects and bounded listings. Snapshot/volume creation, invocation, image pushes, credential creation and policy changes have cost and state effects; record exact resources and approved rollback. Mount only a disposable copy with filesystem specific read only/no recovery precautions. Preserve CloudTrail and evidence throughout. Tool names and CLI fragments are leads, not a tested interoperable toolchain; no assessment was run.