AWS

00. Basic

  • Configure AWS creds

## ------------------| Configure 
aws configure
# AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
# AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
# Default region name [None]: us-west-2
# Default output format [None]:

## ------------------| Export as env
export AWS_PROFILE=ProfileName
export AWS_REGION=<AWS_REGION>
export AWS_ACCESS_KEY_ID=<ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
export AWS_SESSION_TOKEN=<SESSION_TOKEN>

## ------------------| Use as file
aws configure import --csv file://credentials.csv

## ------------------| Set as .aws
### ~/.aws/credentials
[<ProfileName>]
aws_access_key_id = <ACCESS_KEY>
aws_secret_access_key = <SECRET_KEY>
aws_session_token = <SESSION_TOKEN>
### ~/.aws/config
[profile <ProfileName>]
region = <AWS_REGION>

## ------------------| List details
aws sts get-caller-identity
  • Credentials

01. IAM (Identity and Access Management)

01.0 Users

01.2 Groups

01.3 Roles

01.4 Policies

Required Permission
PrivilageEsc Methods

iam:AttachUserPolicy

Attaching a policy to a user

iam:AttachGroupPolicy

Attaching a policy to a group

iam:AttachRolePolicy

Attaching a policy to a role

iam:CreateAccessKey

Creating a new user access key

iam:CreateLoginProfile

Creating a new login profile

iam:UpdateLoginProfile

Updating an existing login profile

iam:PassRole

ec2:RunInstances

Creating an EC2 instance with an existing instance profile

iam:PutUserPolicy

Creating/updating an inline policy for a user

iam:PutGroupPolicy

Creating/updating an inline policy for a group

iam:PutRolePolicy

Creating/updating an inline policy for a role

iam:AddUserToGroup

Adding a user to a group

iam:UpdateAssumeRolePolicy sts:AssumeRole

Updating the AssumeRolePolicyDocument of a role

iam:PassRole

lambda:CreateFunction lambda:InvokeFunction

Passing a role to a new Lambda function, then invoking it

lambda:UpdateFunctionCode

Updating the code of an existing Lambda function

01.5.1 Overly Permissive Permission

  • iam:AttachUserPolicy

  • iam:CreateLoginProfile

  • sts:AssumeRole

  • iam:PassRole with lambda:CreateFunction

  • iam:PassRole with ec2:RunInstances

01.5.2 Dangerous policy combinations

02. S3 (Simple Storage Service)

03. VPC (Virtual Private Cloud)

04. EC2 (Elastic Compute Cloud)

05. EBS (Elastic Block Store)

06. EKS (Elastic Kubernetes Service)

07. RDS (Relational Database Service)

08. KMS (Key Management Server)

09. Lambda

  • Functions

  • API Gateway

10. DynamoDB

11. Secret Manager

12. pacu

  • Cross Account Enumerations

Last updated