thelikes / rejig

Turn your VPS into an attack box
31 stars 9 forks source link
ansible bugbounty digitalocean hack infosec kali offsec pentest pwn ubuntu vps vultr

rejig

An ansible+terraform suite to spawn and provision a virtual machine for attack purposes.

Spawn

To launch a virtual server and install all tools, run the following command.

$ terraform apply # -auto-approve (to skip the prompt)

To view current state:

$ terraform show

To destroy current state:

$ terraform destroy # -auto-approve (to skip the prompt)

Setup

Software

  1. Terraform
  2. Ansible
  3. Python3
  4. This repo

Adjustments

Digital Ocean example follows. To use vultr, you'll need to install the vultr provider first.

provider "digitalocean" {
    token = ""
}

variable "mykey" {
    description = "digitalocean key id"
    default = [XXXXXXXX]
}

variable "myprivkey" {
    description = "my priv key file path"
    default = "/home/user/.ssh/priv.key"
}

variable "myvualtfile" {
    description = "my ansible vault file"
    default = "/home/user/.ansible-vault"
}
[defaults]
host_key_checking = False

How this Works

Terraform is used to spawn and destroy systems. Terraform can be used for many "providers", this repo currently supports digitalocean and vultr. Terraform will spawn systems upon execution of apply and will then use the remote-exec and local-exec to install python and execute ansible. Ansible is used to install crap. The list of crap installed can be found in various files under ansible/roles. Currently this includes core apt packages, git repositories, Go (the language) and go tools. To add, remove, or modify what is installed, edit the tasks/main.yml and vars/main.yml. (See below for a complete list of crap).

Terraform and ansible do not have to be used together. Should you want to only use terraform to spawn/destroy systems, remove the {remote,local}-exec calls from main.tf. Should you only want to use ansible, skip executing terraform and instead just run ansible. Ansible can be run on its own by feeding it a "playbook", a host, user, and SSH key. There are many ways to do this, one of the most straight forward being:

ansible-playbook -u <user> -i <ip addr>, --private-key <priv key> <playbook>.yml -e 'ansible_python_interpreter=/usr/bin/python3'
# for kali 2020.4 , python3 symlink appears to not be satisfactory for ansible
ansible-playbook -u <user> -i <ip addr>, --private-key <priv key> <playbook>.yml -e 'ansible_python_interpreter=/usr/bin/python3.9'

Specifics

Core packages

Hack packages

Go tools

Github repos