lib

package
v0.0.0-...-b90426b Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyringDataPath string

Functions

func AESEncrypt

func AESEncrypt(key, text []byte) (string, string, error)

AESEncrypt https://golang.org/src/crypto/cipher/example_test.go Returns base64 encoded ciphertext and base64 encoded IV Not returning both (iv:ciphertext) as includes too much js/vbs to detach

func Base64Encode

func Base64Encode(data []byte) string

Base64Encode basic wrapper around base64 encoding

func ConfigLintCheck

func ConfigLintCheck(config Config) (bool, []string)

ConfigLintCheck validates the config file

func GenerateDNSAKey

func GenerateDNSAKey(hostname string) (string, string, error)

GenerateDNSAKey requests DNS A record, hashes the response and returns the DNS response and the sha512 hash Note: Only works with the first response and ignores multiple responses

func GenerateDNSTXTKey

func GenerateDNSTXTKey(hostname string) (string, string, error)

GenerateDNSTXTKey requests DNS A record, hashes the response and returns the DNS response and the sha512 hash Note: Only works with the first response and ignores multiple responses

func GenerateHash

func GenerateHash(s []byte, hashType string) (string, error)

GenerateHash takes a string and hashType. Based on hashType calls the respected function or returns an error that the hashType isn't supported

func GenerateHttpKey

func GenerateHttpKey(url string) (string, error)

GenerateHttpKey reaches out to url, hashes the body and returns the sha512 hash

func GenerateSHA512

func GenerateSHA512(s []byte) string

GenerateSHA512 takes a string, generates a SHA512 hash and sends back as hex string

func GetCodeFiles

func GetCodeFiles(lang, section string) []string

GetCodeFiles gets all xml files under the specified code section directory

func GetKeyringDataPath

func GetKeyringDataPath()

GetKeyringDataPath finds out where keyring is running and where the ./data directory is

func GetLanguages

func GetLanguages() []string

GetLanguages returns all the langs based on directories in ./data

func PrintCodeFile

func PrintCodeFile(m string) string

PrintCodeFile shows the module path in a nicer format

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads a file given the path and returns a byte slice

func StrInSlice

func StrInSlice(s string, l []string) bool

StrInSlice checks if a string exists in a slice. No convenient "in" with Go https://stackoverflow.com/questions/15323767/does-go-have-if-x-in-construct-similar-to-python

func UpdateTemplate

func UpdateTemplate(code string, data interface{}) (string, error)

UpdateTemplate replaces placeholders within code files with structs

func WriteFile

func WriteFile(filename string, contents []byte)

WriteFile writes a file given the path and a byte slice

Types

type Config

type Config struct {
	Language    string        `yaml:"language"`
	PayloadFile string        `yaml:"payloadFile"`
	OutputFile  string        `yaml:"outputFile"`
	Keyers      []ConfigKeyer `yaml:"keyers"`
	Retries     string        `yaml:"retries"`
	Sleep       string        `yaml:"sleep"`
	BaseCode    string        `yaml:"baseCode"`
	// Used for C# payloads
	AssemblyType   string `yaml:"assemblyType"`
	AssemblyMethod string `yaml:"assemblyMethod"`
}

Config holds the settings chosen by the user

func ParseConfigFile

func ParseConfigFile(path string) (Config, error)

ParseConfigFile reads a provided config file and sets up the Config struct

type ConfigKeyer

type ConfigKeyer struct {
	Name   string   `yaml:"name"`
	Inputs []string `yaml:"inputs"`
	Output string   `yaml:"keydata"`
}

Keyer options provided within a config file

type FinalCodeTemplate

type FinalCodeTemplate struct {
	Functions       string
	Callers         string
	EncryptedBase64 string
	PayloadHash     string
	AESIVBase64     string
	MinusBytes      string
	Retries         string
	Sleep           string
	// Used for C# payloads
	AssemblyType   string
	AssemblyMethod string
}

FinalCodeTemplate holds the placeholders within the BaseCode of a language Updating these values results in the final code

type InputTemplate

type InputTemplate struct {
	Input []string
}

InputTemplate holds the Inputs so it can be sent to UpdateTemplate()

type Keyer

type Keyer struct {
	Name        string
	Title       string `xml:"title"`
	Description string `xml:"description"`
	Type        string `xml:"type"`
	InputNum    int    `xml:"inputnum"`
	InputHelp   string `xml:"inputhelp"`
	Function    string `xml:"function"`
	Caller      string `xml:"caller"`
}

Keyer stores information related to each keyer:

    Name: name of the keyer
    Description: brief description of the keyer
    Type: the type of keyer: combo or chain
    InputNum: number of inputs that need to be provided from user
    Function: primary function that will be called to return something to
				 use as a part of the decryption key
    Caller: additional code that will call the function and append to the
            relevant array to eventually build the decryption key

func ParseKeyer

func ParseKeyer(lang, keyer string) (Keyer, error)

ParseKeyer takes a given language and keyer name, appends '.xml' then calls ParseKeyerFile

func ParseKeyerFile

func ParseKeyerFile(lang, keyerFileName string) (Keyer, error)

ParseKeyerFile takes a given language and keyer filename, then returns the Keyer struct

type Language

type Language struct {
	Name      string `xml:"name"`
	Extension string `xml:"extension"`
	BaseCode  string `xml:"baseCode"`
}

Language object stores basic info for each language This data will come from the lang.xml file in the root directory of the language's directory

func ParseLanguage

func ParseLanguage(lang string) (Language, error)

ParseLanguage takes a given language, finds the filename and returns the Language struct

Jump to

Keyboard shortcuts

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