deployer

package
v0.0.0-...-980509c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 28 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AWSCloudFrontDestroy

func AWSCloudFrontDestroy(output DomainFrontOutput, configFile string) error

AWSCloufFrontDestroy uses the deleteCloudFront function to delete the specified cloudfront due to the problems with terraforms destruction process

func AskForConfirmation

func AskForConfirmation() bool

func CheckForEmptyEC2Module

func CheckForEmptyEC2Module(namesToDelete []string, state State) (names []string)

CheckForEmptyEC2Module is a hack to ensure EC2 data resources are destroyed as they cannot be destroyed individually

func ContainsInt

func ContainsInt(s []int, e int) bool

ContainsInt checks to see if the array contains the target int

func ContainsString

func ContainsString(s []string, e string) bool

ContainsString checks to see if the array contains the target string

func CreateMasterFile

func CreateMasterFile(wrappers ConfigWrappers) (masterString string)

CreateMasterList takes a MasterList object as input and maps it to the corresponding templates, executes them, then adds the resulting string to a complete string containing the main.tf file for terraform

func CreateSingleSOCKS

func CreateSingleSOCKS(privateKey string, username string, ipv4 string, port int) (err error)

createSingleSOCKS initiates a SOCKS Proxy on the local host with the specifed ipv4 address

func CreateTerraformMain

func CreateTerraformMain(masterString string, configFile string)

CreateTerraformMain takes in a string containing all the necessary calls for the main.tf file

func DestroySOCKS

func DestroySOCKS(ip string)

func ExecAnsible

func ExecAnsible(hostsFile string, playbook string)

func ExpandNumberInput

func ExpandNumberInput(input string) []int

ExpandNumberInput expands input string and returns a list of ints

func FindLargestNumber

func FindLargestNumber(nums []int) int

func GenerateHostFile

func GenerateHostFile(instances []ListStruct, domain string, burpFile string,
	hostFilePath string, remoteFilePath string, execCommand string, socatPort string, socatIP string, nmapOutput string, nmapCommands map[int][]string,
	cobaltStrikeLicense string, cobaltStrikePassword string, cobaltStrikeC2Path string, cobaltStrikeFile string, cobaltStrikeKillDate string,
	ufwAction string, ufwTcpPort []string, ufwUdpPort []string) string

GenerateHostsFile generates an ansible host file

func GeneratePlaybookFile

func GeneratePlaybookFile(apps []string) string

GeneratePlaybookFile generates an ansible playbook

func GetDoRegions

func GetDoRegions(configFile string) (regions []string)

GetDoRegions returns the list of available regions for digital ocean

func GetEC2DataToDestroy

func GetEC2DataToDestroy(instanceNames []string) (newInstanceNames []string)

func InitializeTerraformFiles

func InitializeTerraformFiles(configFile string)

InitializeTerraformFiles Creates the base templates for the terraform infrastructure

func IsValidNumberInput

func IsValidNumberInput(input string) error

IsValidNumberInput takes in a string and checks if the numbers are valid

func ListProxies

func ListProxies(instances []ListStruct) (output string)

func ParseIPFile

func ParseIPFile(path string) ([]string, error)

func PosString

func PosString(slice []string, element string) int

posString returns the first index of element in slice. If slice does not contain element, returns -1.

func PrintProxyChains

func PrintProxyChains(socksList string) (proxies string)

func PrintSocksd

func PrintSocksd(socksList string) (proxies string)

func ProviderCheck

func ProviderCheck(providerArray []string) bool

ProviderCheck takes in a user-defined array of providers and validates they are supported

func RetrieveConfig

func RetrieveConfig(configFilePath string) (config configStruct)

func SplitNmapCommandsIntoHosts

func SplitNmapCommandsIntoHosts(ports []string, hostFile string, command string, count int, evasive bool) (commandList map[int][]string)

func TerraformApply

func TerraformApply(configFile string)

TerraformApply runs the init, plan, and apply commands for our generated terraform templates

func TerraformDestroy

func TerraformDestroy(nameList []string, configFile string)

func TerraformFirstInitialize

func TerraformFirstInitialize(awsAccessID string, awsSecretKey string) string

func UpdateConfig

func UpdateConfig(configFilePath string, config configStruct)

func ValidateNumberOfInstances

func ValidateNumberOfInstances(numberInput []int, listType string, configFile string) error

ValidateNumberOfInstances makes sure that the number input is actually available in our list of active instances

func ValidatePorts

func ValidatePorts(ports []string) (allports []string, err error)

func WriteToFile

func WriteToFile(path string, content string)

WriteToFile opens, clears and writes to file

Types

type APIOutput

type APIOutput struct {
	TargetURI string
	InvokeURI string
	Provider  string
	Name      string
}

func ListAPIs

func ListAPIs(state State) (apiOutputs []APIOutput)

func (APIOutput) String

func (output APIOutput) String() string

type AWSApiConfigWrapper

type AWSApiConfigWrapper struct {
	ModuleName string
	Name       string
	TargetURI  string
	InvokeURI  string
}

type AWSDomainFront

type AWSDomainFront struct{}

type AWSSecurityGroup

type AWSSecurityGroup struct{}

type AzureDomainFront

type AzureDomainFront struct{}

type AzureInstance

type AzureInstance struct {
	Count int
}

type AzureProvider

type AzureProvider struct {
	Instances   []AzureInstance    `json:"instances"`
	DomainFront []AzureDomainFront `json:"domain_front"`
}

type CloudfrontConfigWrapper

type CloudfrontConfigWrapper struct {
	ModuleName string
	ID         string
	Provider   string
	URL        string
	Origin     string
	Status     string
	Enabled    string
	Etag       string
}

type ConfigWrappers

type ConfigWrappers struct {
	EC2                    []EC2ConfigWrapper
	EC2ModuleCount         int
	DO                     []DOConfigWrapper
	DropletModuleCount     int
	AWSAPI                 []AWSApiConfigWrapper
	AWSAPIModuleCount      int
	Cloudfront             []CloudfrontConfigWrapper
	CloudfrontModuleCount  int
	Googlefront            []GooglefrontConfigWrapper
	GooglefrontModuleCount int
}

func APIDeploy

func APIDeploy(provider string, targetURI string, wrappers ConfigWrappers) ConfigWrappers

APIDeploy takes argruments to deploy an API Gateway

func CreateWrappersFromState

func CreateWrappersFromState(state State, configFile string) (wrappers ConfigWrappers)

func DomainFrontDeploy

func DomainFrontDeploy(provider string, origin string, restrictUA string,
	functionName string, frontedDomain string, wrappers ConfigWrappers) ConfigWrappers

func InstanceDeploy

func InstanceDeploy(providers []string, awsRegions []string, doRegions []string, azureRegions []string,
	googleRegions []string, count int, keyName string, wrappers ConfigWrappers, configFile string) ConfigWrappers

InstanceDeploy takes input from the user interface in order to divide and deploy appropriate regions it takes in a TerraformOutput struct, makes the appropriate edits, and returns that same struct

type DOConfigWrapper

type DOConfigWrapper struct {
	ModuleName  string
	Image       string
	PrivateKey  string
	Fingerprint string
	Size        string
	DefaultUser string
	RegionMap   map[string]int
}

type DomainFrontOutput

type DomainFrontOutput struct {
	Name         string
	Origin       string
	ID           string
	Invoke       string
	Provider     string
	Etag         string
	Status       string
	FunctionName string
	RestrictUA   string
}

func ListDomainFronts

func ListDomainFronts(state State) (domainFronts []DomainFrontOutput)

func (DomainFrontOutput) String

func (output DomainFrontOutput) String() string

type EC2ConfigWrapper

type EC2ConfigWrapper struct {
	ModuleName   string
	InstanceType string
	DefaultUser  string
	DefaultSG    string
	SgID         string
	PrivateKey   string
	PublicKey    string
	KeyPairName  string
	RegionMap    map[string]int
}

type GooglefrontConfigWrapper

type GooglefrontConfigWrapper struct {
	ModuleName          string
	FrontedDomain       string
	InvokeURI           string
	Host                string
	HostURL             string
	FunctionName        string
	SourceFile          string
	PackageFile         string
	RestrictUA          string
	RestrictSubnet      string
	RestrictHeader      string
	RestrictHeaderValue string
	Enabled             bool
}

type InstanceState

type InstanceState struct {
	// A unique ID for this resource. This is opaque to Terraform
	// and is only meant as a lookup mechanism for the providers.
	ID string `json:"id"`

	// Attributes are basic information about the resource. Any keys here
	// are accessible in variable format within Terraform configurations:
	// ${resourcetype.name.attribute}.
	Attributes map[string]interface{} `json:"attributes"`

	// Meta is a simple K/V map that is persisted to the State but otherwise
	// ignored by Terraform core. It's meant to be used for accounting by
	// external client code. The value here must only contain Go primitives
	// and collections.
	Meta map[string]interface{} `json:"meta"`

	// Tainted is used to mark a resource for recreation.
	Tainted bool `json:"tainted"`
}

type ListStruct

type ListStruct struct {
	IP         string
	Provider   string
	Region     string
	Name       string
	Place      int
	Username   string
	PrivateKey string
}

func InstanceDiff

func InstanceDiff(instancesOld []ListStruct, instancesNew []ListStruct) (instancesOut []ListStruct)

InstanceDiff takes the old list of instances and the new list of instances and proceeds to check each instance in the new list against the old list. If its not in the old list, it appends it to output.

func ListInstances

func ListInstances(state State, configFile string) (hostOutput []ListStruct)

func (*ListStruct) String

func (listStruct *ListStruct) String() string

type ModuleState

type ModuleState struct {
	// Path is the import path from the root module. Modules imports are
	// always disjoint, so the path represents amodule tree
	Path []string `json:"path"`

	// Locals are kept only transiently in-memory, because we can always
	// re-compute them.
	Locals map[string]interface{} `json:"-"`

	// Outputs declared by the module and maintained for each module
	// even though only the root module technically needs to be kept.
	// This allows operators to inspect values at the boundaries.
	Outputs map[string]*OutputState `json:"outputs"`

	// Resources is a mapping of the logically named resource to
	// the state of the resource. Each resource may actually have
	// N instances underneath, although a user only needs to think
	// about the 1:1 case.
	Resources map[string]ResourceState `json:"resources"`

	// Dependencies are a list of things that this module relies on
	// existing to remain intact. For example: an module may depend
	// on a VPC ID given by an aws_vpc resource.
	//
	// Terraform uses this information to build valid destruction
	// orders and to warn the user if they're destroying a module that
	// another resource depends on.
	//
	// Things can be put into this list that may not be managed by
	// Terraform. If Terraform doesn't find a matching ID in the
	// overall state, then it assumes it isn't managed and doesn't
	// worry about it.
	Dependencies []string `json:"depends_on"`
}

type OutputState

type OutputState struct {
	// Sensitive describes whether the output is considered sensitive,
	// which may lead to masking the value on screen in some cases.
	Sensitive bool `json:"sensitive"`
	// Type describes the structure of Value. Valid values are "string",
	// "map" and "list"
	Type string `json:"type"`
	// Value contains the value of the output, in the structure described
	// by the Type field.
	Value interface{} `json:"value"`
}

type ResourceState

type ResourceState struct {
	// This is filled in and managed by Terraform, and is the resource
	// type itself such as "mycloud_instance". If a resource provider sets
	// this value, it won't be persisted.
	Type string `json:"type"`

	// Dependencies are a list of things that this resource relies on
	// existing to remain intact. For example: an AWS instance might
	// depend on a subnet (which itself might depend on a VPC, and so
	// on).
	//
	// Terraform uses this information to build valid destruction
	// orders and to warn the user if they're destroying a resource that
	// another resource depends on.
	//
	// Things can be put into this list that may not be managed by
	// Terraform. If Terraform doesn't find a matching ID in the
	// overall state, then it assumes it isn't managed and doesn't
	// worry about it.
	Dependencies []string `json:"depends_on"`

	// Primary is the current active instance for this resource.
	// It can be replaced but only after a successful creation.
	// This is the instances on which providers will act.
	Primary InstanceState `json:"primary"`

	// Provider is used when a resource is connected to a provider with an alias.
	// If this string is empty, the resource is connected to the default provider,
	// e.g. "aws_instance" goes with the "aws" provider.
	// If the resource block contained a "provider" key, that value will be set here.
	Provider string `json:"provider"`
}

type State

type State struct {
	// Version is the state file protocol version.
	Version int `json:"version"`

	// TFVersion is the version of Terraform that wrote this state.
	TFVersion string `json:"terraform_version,omitempty"`

	// Serial is incremented on any operation that modifies
	// the State file. It is used to detect potentially conflicting
	// updates.
	Serial int64 `json:"serial"`

	// Modules contains all the modules in a breadth-first order
	Modules []ModuleState `json:"modules"`
}

func TerraformStateMarshaller

func TerraformStateMarshaller() (outputStruct State)

TerraforrmOutputMarshaller runs the terraform output command and marshalls the resulting JSON into a TerraformOutput struct

type Token

type Token struct {
	AccessToken string
}

func (*Token) Token

func (t *Token) Token() (*oauth2.Token, error)

Token provides a function to retrieve a new digitalocean token for the service to make API calls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL