AWS Penetration Testing – AWS Command Line Interface

The AWS Command Line Interface (AWS CLI) is a powerful tool provided by Amazon Web Services for programmatic access with AWS services. It allows users to manage and automate AWS resources directly from the command line.

Available for the 3 most common operating systems Windows, OSX and Linux. AWS CLI enables cloud access from virtually any computer. To help its users get up and running Amazon has also produced some great reading material, which can be accessed through the following link.

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html

Configuration and Usage

Throughout this series, unless specified otherwise, AWS CLI will be the go-to tool for enumerating any AWS environment.

To access an AWS account through the AWS CLI tool access keys would be needed, this is essentially a username and password which can be assigned to AWS user accounts. Example #1 shows some sample AWS access keys.

aws_access_key_id = AKDSKFAKE34WFNJK7X2
aws_secret_access_key = SshHuiX1FAk3Va+Ki+tv0dksoUI/lCZNSonRLOLp

Before any commands can be run against AWS services, the AWS CLI would need to be configured. This is where the access keys are specified. Once configured, the access keys would be saved to a local credentials file and can be used with the profile command line argument, an example of configuration can be seen in Example #2.

terminal$ aws configure --profile jessie
AWS Access Key ID [None]: AKDSKFAKE34WFNJK7X2
AWS Secret Access Key [None]: SshHuiX1FAk3Va+Ki+tv0dksoUI/lCZNSonRLOLp
Default region name [None]: 
Default output format [None]:

As soon as configuration is complete then the AWS CLI will be able to interact with any permitted services within the cloud environment. When a command is run it’ll return the resulting output in JSON format, this can be seen in the following example.

terminal$ aws --profile jessie sts get-caller-identity
{
    "UserId": "237641155662",
    "Account": "237641155662",
    "Arn": "arn:aws:iam::237641155662:user/jessie"
}

We’ll explain more about running AWS CLI commands throughout this series but for now, Example #3 shows a “whoami” type command on AWS. This returns the user ID, Account ID and Amazon Resource Name (ARN) for the user to whom the access keys are assigned.




Up Next “AWS S3 Buckets”

Spread the love