Coder Social home page Coder Social logo

ezra-buckingham / terry-the-terraformer Goto Github PK

View Code? Open in Web Editor NEW
109.0 8.0 15.0 6.98 MB

A CLI for deploying red team infrastructure across mutliple cloud providers, all integrated with a virtual Nebula network, and full ELK integration

Home Page: https://github.com/ezra-buckingham/terry-the-terraformer/wiki

License: MIT License

Python 78.91% Jinja 21.03% Shell 0.06%
aws azure cli docker docker-compose elasticsearch filebeat google-cloud-platform logstash nebula

terry-the-terraformer's People

Contributors

ezra-buckingham avatar leebaird avatar linted avatar mrdomainadmin avatar natesubra avatar tecknicaltom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terry-the-terraformer's Issues

Nebula Subnet not working with ADD

the add command should look through the build manifest to check the nebula IPs that have been assigned and remove those from assignable IPs in the handler

Config file and SSH

Allow the user to provide a path to their public SSH key instead of making them paste the key into this file.

Excessive error message

If a user chooses to not deploy containers, they get two large errors when building.
Since containers are not required, suggest handling this another way and/or reducing the size of the error message.

Firewall rules

If Nebula is not being used, suggest the following:

  1. Configure /var/www/html/.htaccess on each redirector and set the first proxy rule with the IP address of the C2 server.
  2. Configure the C2 server firewall to allow port 443 from each redirector.

Issues Authenticating to AWS registry

Hi,

Thank you for creating this project, I am enjoying it so far.
I am having some difficulty configuring terry to login to my private AWS ECR. I had things working with public docker beforehand.

My repository URI is

repositoryUri": "123456.dkr.ecr.us-west-2.amazonaws.com/

aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 123456.dkr.ecr.us-west-2.amazonaws.com
results in a successful login in local testing, and i've pushed containers with this method.

my config.yml looks as such: (harcoding in the file while i troubleshooot)

container_registry_username: AWS 
container_registry_password: <AKIAR...>~<j...1>
container_registry_strategy: aws # If using AWS ECR, specify "aws"

output from terry on run:

TASK [Authenticate to the container registry] **********************************
skipping: [54.148.58.116]
included: /opt/terry-the-terraformer/playbooks/core/login-to-container-registry.yml for 35.92.206.208

TASK [Prepare the container registry URL for parsing] **************************
skipping: [35.92.206.208]

TASK [Extract the AWS Account ID and Region from ExtractCR URL] **********************
skipping: [35.92.206.208]

TASK [Authenticate to the container registry (aws strategy)] *******************
skipping: [35.92.206.208]

TASK [Authenticate to the container registry (default strategy)] ***************
fatal: [35.92.206.208]: FAILED! => {"changed": false, "msg": "Logging into https://123456.dkr.ecr.us-west-2.amazonaws.com for user AWS failed - 500 Server Error for http+docker://localhost/v1.41/auth: Internal Server Error (\"login attempt to https://123456.dkr.ecr.us-west-2.amazonaws.com/v2/ failed with status: 400 Bad Request\")"}

I see that it's a 400 bad request, and probably an issue with my config.yml - but I can't figure out what syntax it's looking for, if I've done something wrong.

I"ll make a PR to improve the config-example.yml once I know what I'm doing wrong.

"Only root can pass arbitrary filesystem paths" Terraform-Proxmox

Hi, ive populated config.yml and im using an API token associated with the root user, however I am still seeing the error below. Any ideas on how I can continue to troubleshoot?

Thank you

  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

proxmox_lxc.id-fa1ada82-8d8a-4dd0-9dcb-ce9e091b584b: Creating...

Error: error creating LXC container: 500 Only root can pass arbitrary filesystem paths. at /usr/share/perl5/PVE/Storage.pm line 541., error status: {"data":null} (params: {"arch":"amd64","cmode":"tty","console":true,"cores":2,"cpulimit":0,"cpuunits":1024,"features":"","hostname":"ratio-tisiphone","memory":4096,"net0":"bridge=vmbr0,ip=dhcp,name=eth0","onboot":false,"ostemplate":"ubuntu2204-4gb-template","protection":false,"rootfs":"zfs-pool1:24","ssh-public-keys":"ssh-rsa AAAA[redacted]","start":true,"storage":"local","swap":4096,"tags":"","tty":2,"unprivileged":false,"vmid":111})

  with proxmox_lxc.id-fa1ada82-8d8a-4dd0-9dcb-ce9e091b584b,
  on test2_plan.tf line 17, in resource "proxmox_lxc" "id-fa1ada82-8d8a-4dd0-9dcb-ce9e091b584b":
  17: resource "proxmox_lxc" "id-fa1ada82-8d8a-4dd0-9dcb-ce9e091b584b" {

[X] Fatal Error: Terraform returned an error: No stderr was returned, this is likely a logic issue or partial error within the plan. (Example: if AWS, a bad AMI given the region)```

suggestion: split redirector into multiple server types

A slight suggestion that you can feel free to close and ignore, but after getting familiar with the Terry code, it looks like it could be cleaner if the redirector server type were split into separate server types (e.g. dns_redirector). There are several places with conditional logic based on redirector_type and there's not much shared logic between these server types.

Thanks again for this great project. If you're not opposed to this idea, I may be able to quickly do it and submit a PR, though I'm not sure how it would handle upgrading existing operations' servers.

adding mailserver with namecheap domain not working

Attempting to add a mailserver to an existing operation using a namecheap domain is failing with an error.

command:

python3 terry.py --operation [redacted] --verbose --no_elastic add   server --provider aws --type mailserver --fqdn [redacted].com:namecheap

generates the following plan for dns resources:

  # namecheap_domain_records._dmarc-mx-TXT-id-6f170dfd-ba29-4af1-90f8-2308125247fa will be created
  + resource "namecheap_domain_records" "_dmarc-mx-TXT-id-6f170dfd-ba29-4af1-90f8-2308125247fa" {
      + domain     = "[redacted].com"
      + email_type = "NONE"
      + id         = (known after apply)
      + mode       = "MERGE"

      + record {
          + address  = "v=DMARC1; p=none"
          + hostname = "_dmarc.mx"
          + mx_pref  = 10
          + ttl      = 1799
          + type     = "TXT"
        }
    }

  # namecheap_domain_records.mx-A-id-6f170dfd-ba29-4af1-90f8-2308125247fa will be created
  + resource "namecheap_domain_records" "mx-A-id-6f170dfd-ba29-4af1-90f8-2308125247fa" {
      + domain     = "[redacted].com"
      + email_type = "NONE"
      + id         = (known after apply)
      + mode       = "MERGE"

      + record {
          + address  = (known after apply)
          + hostname = "mx"
          + mx_pref  = 10
          + ttl      = 1799
          + type     = "A"
        }
    }

  # namecheap_domain_records.mx-MX-id-6f170dfd-ba29-4af1-90f8-2308125247fa will be created
  + resource "namecheap_domain_records" "mx-MX-id-6f170dfd-ba29-4af1-90f8-2308125247fa" {
      + domain     = "[redacted].com"
      + email_type = "MX"
      + id         = (known after apply)
      + mode       = "MERGE"

      + record {
          + address  = "mx.[redacted].com."
          + hostname = "mx"
          + mx_pref  = 10
          + ttl      = 1799
          + type     = "MX"
        }
    }

After accepting the actions, it appears that the MX record is properly created, but the other two records fail, with errors such as:

Error: Records[1].RecordType MX is not allowed for EmailType=NONE

  with namecheap_domain_records.mx-A-id-6f170dfd-ba29-4af1-90f8-2308125247fa,
  on [redacted]_plan.tf line 176, in resource "namecheap_domain_records" "mx-A-id-6f170dfd-ba29-4af1-90f8-2308125247fa":
 176: resource "namecheap_domain_records" "mx-A-id-6f170dfd-ba29-4af1-90f8-2308125247fa" { 

[X] Fatal Error: Terraform returned an error: No stderr was returned, this is likely a logic issue or partial error within the plan. (Example: if AWS, a bad AMI given the region)

This is with the current github version of Terry, commit dcf6861

DigitalOcean

The DigitalOcean API key is not being read in from config.yml.

redirector not created if missing domain

The logic around the error message "No domains provided for redirector, this may cause issues with your redirector (depending on the protocol)" (in terry.py) results in no server being created for a redirector if there are no specified domains.

This behavior should be changed, or the error message should be more clear that the requested resource isn't going to be created, or it should be a more fatal error that stops the create/add request.

User output

Suggest the following simple output to the user once a successful build has completed.

for each server

Example:
1.1.1.1 https aws evil-corp.com
1.1.1.2 https aws nothing-here.com
1.1.1.3 team do

Refactor how Terry handles the custom objects

As it stands, there is no good structure for how the different resources are being passed into Jinja (making it really hard for a user to know what data is sent to a template, making custom templating damn near impossible)

Nebula Service Reload

fatal: [XX.XX.XX.XX]: FAILED! => {"changed": false, "msg": "Unable to reload service nebula: Failed to reload nebula.service: Job type reload is not applicable for unit nebula.service.\n"}
fatal: [XX.XX.XX.XX]: FAILED! => {"changed": false, "msg": "Unable to reload service nebula: Failed to reload nebula.service: Job type reload is not applicable for unit nebula.service.\n"}```

document example of remote config for team config

In the wiki, there's a comment that remote configurations are used by the developers to store user info in a git repo:

if you have remote configurations (which in our use case, we have a private git repository with JSON files for each user that contains each user's desired username, public IP address/CIDR, and public ssh key)

https://github.com/ezra-buckingham/terry-the-terraformer/wiki/Usage

Can you please document somewhere what the layout of the json files in that repo look like and how you merge their contents into the team config?

Thanks!

Destroy command not working.

Destroy command not working.

AWS: instances, security groups, and key pair still there.
DigitalOcean: droplets still there.

root@kali:/opt/terry-the-terraformer# ./terry.py -o test4 -v destroy -r
[+] Start of script run with command: "./terry.py -o test4 -v destroy -r"
[+] Destroying the "test4" plan
[] Parsing the build manifest
[+] Validating that we have all required credentials
[+] All required credentials found
[
] Successfully found "terraform" binary
[+] Destroying Terraform plan

Error: Missing required argument

on test4_plan.tf line 15, in provider "aws":
15: provider "aws" { }

The argument "region" is required, but no definition was found.

Error: Missing required argument

on test4_plan.tf line 16, in provider "namecheap":
16: provider "namecheap" { }

The argument "api_user" is required, but no definition was found.

Error: Missing required argument

on test4_plan.tf line 16, in provider "namecheap":
16: provider "namecheap" { }

The argument "user_name" is required, but no definition was found.

Error: Missing required argument

on test4_plan.tf line 16, in provider "namecheap":
16: provider "namecheap" { }

The argument "api_key" is required, but no definition was found.
[x] Fatal Error: Error when destroying "test4". Please try again.

Broken Wiki links

Broken Wiki links:
Adding to Terry > Terraform mappings file template folder
Adding to Terry > container mappings file
Adding to Terry > container mappings file
Resource Types > Terraform mappings file

sudo

When you run any command as sudo, you get a similar error:
sudo: unable to resolve host string-string: Name or service not known

string-string are the random names that terry assigns.

Kali Linux as a teamserver option

Suggest having Kali Linux as a teamserver option.

Could add a new line to config.yml so that the user can enter the AWS OS ID for their region.

AWS security groups

Using the -r switch with 'destroy' should delete all AWS security groups that were created.

Each AWS instance that is deployed has an attached security group.
These security groups all have the same rule: allow traffic on all ports and protocols. This seems redundant.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.