AWS

Amazon Web Service

The ARN (Amazon Resource Namearrow-up-right) is a unique global identifier for every AWS resource. THe IAM (Identity and Access Managementarrow-up-right) is the service that manages users and their permissions within the AWS cloud environment.

Route 53

Managed DNS service. Allows you to register domains, resolve DNS names, and route traffic (latency-based, geolocation-based, failover, etc.) to AWS resources or on-prem environments.

EC2

Compute service based on virtual machine instances. The cloud equivalent of traditional servers—choose instance type, CPU, memory, storage, networking, and OS, then deploy applications.

S3

Object storage. Suitable for files, documents, images, backups, archives, and datasets. Highly scalable and durable; widely used as a data lake or backend storage for applications and content distribution.

RDS

Managed relational database service. Supports engines like MySQL, PostgreSQL, SQL Server, Oracle, and Aurora; handles provisioning, patching, backups, scaling, and high availability (Multi-AZ, read replicas)

Configuration

We can interact with AWS with awscli (DOCarrow-up-right).

sudo apt install awscli

Let's start awscli and configure it with a profile IAM, a user of your own AWS account.

aws configure --profile <NAME>
# Access Key & Secret Key
# ~/.aws/credentials
# ~/.aws/config

Enumeration Credentials

aws --profile <NAME> sts get-caller-identity
chevron-rightMore stealthy than get-caller-identityhashtag

In case of compromised credentials, more stealthy enumeration whose event should not be logged by default.

aws --profile <NAME> sts get-access-key-info --access-key-id <ACCESS_KEY> # ID ACCOUNT
aws --profile <NAME> lambda invoke --function-name arn:aws:lambda:us-east-1:123456789012:function:nonexistent-function outfile # In Error: ACCOUNT ID, type of identity (IAM user or role), name of the identity

We can also try with different region --region (logs event are recorded in the region used and may not be notice).

Query JMESPath

We should always try to reduce the number of requests we send by saving all output to a local file and then using an external tool like jparrow-up-right to filter that output with JMESPath expressions.

Policy

List inline policies and managed policiesarrow-up-right.

Group

Role

View a policy

If the compromised credentials don't have the privileges to query for IAM-related information, we need to adopt a brute-force approach using pacuarrow-up-right (iam__bruteforce_permissions).

Backdoor account

Create user

Attach the AWS managed AdministratorAccess policy (or other)

Create the access key and secret key for the user

Automated Enumeration

With pacuarrow-up-right.

S3

Cloud-based object storage service. Allows objects to be stored in containers called buckets.

Enumeration

Search for resources (ex. in website requests):

To find the S3 bucket region, we can check the HTTP response (X-Amz-Bucket-Region) or with /?location on the bucket.

We can use cloudbrutearrow-up-right or cloud-enumarrow-up-right

Note:

  1. S3 buckets are commonly misconfigured so that the bucket ACL blocks public access, but allows access to any AWS authenticated user, even if they're in a different AWS account

  2. If we have a private bucket without permission to listing its contents ("Access Denied"), it is still possible that the files inside it are accessible. We can therefore try a brute force attack on the files.

Interaction

It is possible to use arbitrary values for all fields in IAM Configuration because sometimes the target server is configured not to check authentication.

We list all S3 buckets hosted by the server.

We list the common objects and prefixes in the specified bucket.

We can download objects from the buckets.

We can upload object into the buckets.

Account IDs from S3 Buckets

chevron-rightDetailshashtag

in your AWS account create ROLE with Custom Trust Policy

chevron-right1. In your AWS account create ROLE with Custom Trust Policyhashtag
chevron-right2. Add the following Authorization to the ROLEhashtag
chevron-right3. Add the following authorization policy to your IAM userhashtag

Now we can run s3-account-searcharrow-up-right

Users & Role from Account IDs

Similar to the "Account IDs from S3 Buckets" approach.

Add the “AdministratorAccess” managed policy to your IAM user and use pacuarrow-up-right.

EC2

AMI

Publicly shared Amazon Machine Imagesarrow-up-right (AMIs) AMIs are virtual machine images containing a pre-installed operating system along with software and files.

EBS

Publicly shared Elastic Block Storagearrow-up-right (EBS) snapshots

Last updated