Skip to main content

Advisory Infrastructure Setup Toolset - The Python Package

Project description

aws-kommandos

Advisory Infrastructure Setup Scripts

About

Have you ever been bothered with setting up your C2 infrastructure on AWS prior to/during a red team engagement? Having to deal with logging in, configuring security groups, going through the process of creating DNS record sets and such?

If you hate doing this time after time and just wanna have a script that does everything for you - you've come to the right place.

AWS Kommandos automates the process of creating cloud instances for various purposes - as C2 servers, for example. It also helps you to manage your AWS console - from changing firewall rules and managing your SSH access keys to adjusting the DNS record sets. All in one damn script.

You're only expected to create an AWS account and configure the access keys for running Kommandos locally.

See the Usage section for getting an idea how to use it.

Kommandos automatically creates its directory under the ~/.aws-kommandos path to store SSH private keys it creates.

Installation

Install the toolset

apt install python3 python3-pip
pip3 install aws-kommandos

Configure the AWS credentials

The first option is to use the awscli client to configure your AWS credentials used by Kommandos. aws configure

The second options is to export the AWS credentials as environment variables

export AWS_ACCESS_KEY_ID=key_id
export AWS_ACCESS_KEY_SECRET=secret
export AWS_REGION=region

The third option is to use the command-line arguments to pass credentials to Kommandos aws-kommandos --access-key-id <key_id> --access-key-secret <secret> --region-name <region>

Usage

Print Kommandos options

aws-kommandos --help

aws-kommandos -h

Print AWS stats (instances, security groups, ssh keys, DNS hosted zones)

aws-kommandos --stats

Print detailed AWS stats

aws-kommandos --stats --verbose

aws-kommandos --stats -v

Terminate all running EC2 instances

╰$ aws-kommandos --terminate-all
Terminating all running instances
Terminating i-0df15af122876dd62

Search AMI images

╰$ aws-kommandos --search-ami "ubuntu*server*20.04*"
{'CreationDate': '2021-07-27T16:45:08.000Z',
 'ImageId': 'ami-06e715bf46b6caf71',
 'State': 'available',
 'Name': 'ubuntu-pro-server/images/hvm-ssd/ubuntu-focal-20.04-amd64-pro-serve-ae7ed378-8838-4fcf-842d-d1d09b34f116-ami-005f184e361f78579.4',
 'ImageLocation': 'aws-marketplace/ubuntu-pro-server/images/hvm-ssd/ubuntu-focal-20.04-amd64-pro-serve-ae7ed378-8838-4fcf-842d-d1d09b34f116-ami-005f184e361f78579.4',
 'Description': 'Canonical, Ubuntu Server Pro, 20.04 LTS, amd64 focal image '
                'build on 2021-07-20',
 'ImageOwnerAlias': 'aws-marketplace'}
1 AMI images found

Start a new instance (minimal configuration)

╰$ aws-kommandos --security-group sg-66666666661488666 --start
Creating a new SSH key pair: proxy-key
The SSH key pair with the name 'proxy-key' already exists
Starting a new instance: ami-0746eb3cb5c684ae6 proxy-key sg-030abb524637009f3 t2.micro proxy-instance
The instance has been created
Waiting for the server boot...
The server is up and running at 18.197.229.100
Waiting until the SSH service is available...
The default user of the AMI 'ami-0746eb3cb5c684ae6' has been identified as 'ubuntu'
Use the following command for connecting to the instance: ssh ubuntu@18.197.229.100 -i proxy-key.pem

Oh, and did I mention that if you don't have an SSH access key the script automatically creates one for you? Use --force-recreate-key to force the script into creating a new key even if one with the same name exists.

Start a new instance and autoconfigure the DNS record sets

This command starts a new instance and uses the domain name supplied with the --fqdn argument to create A and MX record sets pointing to the IP address of the newly created EC2 instance.

╰$ aws-kommandos --security-group sg-66666666661488666 --start --link-fqdn --fqdn virtualsquad.ninja
Creating a new SSH key pair: proxy-key
The SSH key pair with the name 'proxy-key' already exists
Starting a new instance: ami-0746eb3cb5c684ae6 proxy-key sg-030abb524637009f3 t2.micro proxy-instance
The instance has been created
Waiting for the server boot...
The server is up and running at 18.184.218.238
Waiting until the SSH service is available...
The default user of the AMI 'ami-0746eb3cb5c684ae6' has been identified as 'ubuntu'
Use the following command for connecting to the instance: ssh ubuntu@18.184.218.238 -i proxy-key.pem
A new record set virtualsquad.ninja. A 18.184.218.238 has been created
A new record set virtualsquad.ninja. MX 1 18.184.218.238 has been created

Create an inbound firewall rule

╰$ aws-kommandos --security-group sg-66666666661488666 --allow-inbound 443/tcp:0.0.0.0/0         
Authorizing ingress '[443/tcp -> 0.0.0.0/0] - ' on 'sg-66666666661488666'
Operation performed successfully

Revoke an inbound firewall rule

╰$ aws-kommandos --security-group sg-66666666661488666 --delete-inbound 443/tcp:0.0.0.0/0
Revoking ingress '[443/tcp -> 0.0.0.0/0] - ' on 'sg-66666666661488666'
Operation performed successfully

Create an outbound firewall rule

╰$ aws-kommandos --security-group sg-66666666661488666 --allow-outbound 443/tcp:0.0.0.0/0         
Authorizing egress '[443/tcp -> 0.0.0.0/0] - ' on 'sg-66666666661488666'
Operation performed successfully

Revoke an outbound firewall rule

╰$ aws-kommandos --security-group sg-66666666661488666 --delete-outbound 443/tcp:0.0.0.0/0
Revoking egress '[443/tcp -> 0.0.0.0/0] - ' on 'sg-66666666661488666'
Operation performed successfully

Create a security group w/o description

╰$ aws-kommandos --create-security-group NinjaGroup                                         
A new security group with the name 'NinjaGroup' has been created

Create a security group w description

╰$ aws-kommandos --create-security-group "NinjaGroup: My Awesome Security Group"
A new security group with the name 'NinjaGroup' has been created

Delete a security group

╰$ aws-kommandos --delete-security-group --security-group-id sg-0b2d1b55354c531bd
The security group with id 'sg-0b2d1b55354c531bd' has been deleted

Create a new A record set for domain

╰$ aws-kommandos --fqdn virtualsquad.ninja --add-record --record-type A --record-value 55.55.55.55
A new record set virtualsquad.ninja. A 55.55.55.55 has been created

Delete a record set from domain

╰$ aws-kommandos --fqdn virtualsquad.ninja --delete-record --record-type A --record-value 55.55.55.55
The record set virtualsquad.ninja. A 55.55.55.55 has been deleted

And many more! Please use --help to see what else you could do with Kommandos.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-kommandos-1.0.14.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_kommandos-1.0.14-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file aws-kommandos-1.0.14.tar.gz.

File metadata

  • Download URL: aws-kommandos-1.0.14.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for aws-kommandos-1.0.14.tar.gz
Algorithm Hash digest
SHA256 fc515969fa8646ebe075b23a790a7db7a2ff6a372523d2ecaac9f0ffde8742a4
MD5 a0a7d1b149f60c7345faee41cb655429
BLAKE2b-256 b98e5a9930a13ff92ca59cd9147af306851811cb3049d6744af3df8ef7e652ac

See more details on using hashes here.

File details

Details for the file aws_kommandos-1.0.14-py3-none-any.whl.

File metadata

  • Download URL: aws_kommandos-1.0.14-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for aws_kommandos-1.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 717bb8806de308cf398e2da309d1013b06876dce560acb98f2b0e36db21566e3
MD5 6ee41670b07937bbc7dfd737d055453e
BLAKE2b-256 7b7a2aff69e6d46bdc41831f63fe4af07e001012c2cf7a81cc7d5049a7597708

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page