common

package
v0.0.0-...-656a664 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JOB_STATUS_WAITING  string = "WA"
	JOB_STATUS_ON_GOING string = "OG"
	JOB_STATUS_SUCCESS  string = "SU"
	JOB_STATUS_ERROR    string = "ER"
)
View Source
const (
	ContentTypeHeaderName = "Content-Type"
	AcceptHeaderName      = "Accept"
	ApplicationJSON       = "application/json"
)
View Source
const (
	FRINGE_HOME_DIRECTORY = ".fringe-runner"
)
View Source
const (
	FRINGE_RESSOURCE_DIRECTORY = "resources"
)

Variables

View Source
var AssetTypes = map[string]AssetType{
	"ip":       ASSET_IP,
	"hostname": ASSET_HOSTNAME,
	"url":      ASSET_URL,
	"raw":      ASSET_RAW,
}
View Source
var BRANCH = "HEAD"
View Source
var BUILT = "unknown"
View Source
var NAME = "fringe-runner"
View Source
var REVISION = "HEAD"
View Source
var VERSION = "development version"

Functions

func AppendIfMissing

func AppendIfMissing(slice []string, e string) []string

func CleanHostname

func CleanHostname(hostname string) string

func DefaultUserAgent

func DefaultUserAgent() string

func DownloadResource

func DownloadResource(resource ModuleResource, config *FringeConfig) error

func FileExists

func FileExists(filename string) bool

Check if a file exist on the specify path

func GenerateDialer

func GenerateDialer(allowIPAddresses []string) (func(string, string) (net.Conn, error), error)

func GetCommands

func GetCommands() []*cli.Command

func GetProxyFromEnv

func GetProxyFromEnv() (string, bool)

func GetRessourceFile

func GetRessourceFile(config *FringeConfig, filename string) (string, error)

func IsHostname

func IsHostname(host string) bool

func IsIPv4

func IsIPv4(rawString string) bool

func IsURL

func IsURL(url string) bool

func IsValidAddr

func IsValidAddr(addr string) bool

func LookupCName

func LookupCName(fqdn, serverAddr string) ([]string, error)

LookupName returns IPv4 addresses from A records or error.

func LookupNS

func LookupNS(domain, serverAddr string) ([]string, error)

LookupNS returns the names servers for a domain.

func LookupName

func LookupName(fqdn, serverAddr string) ([]string, error)

LookupName returns IPv4 addresses from A records or error.

func ParseYAMLFile

func ParseYAMLFile(filePath string, out interface{}) error

Parse a YAML file to a structure

func ReadJSONFile

func ReadJSONFile(path string, result interface{}) error

func RegisterCommand

func RegisterCommand(name, usage string, data Commander, flags []cli.Flag)

func SearchAllHostname

func SearchAllHostname(rawString string) []string

func SearchAllIP

func SearchAllIP(rawString string) []string

func StringInSlice

func StringInSlice(slice []string, e string) bool

Types

type AppVersionInfo

type AppVersionInfo struct {
	Name         string `json:"name"`
	Version      string `json:"version"`
	Revision     string `json:"revision"`
	Branch       string `json:"branch"`
	GOVersion    string `json:"go_version"`
	BuiltAt      string `json:"built_at"`
	OS           string `json:"os"`
	Architecture string `json:"architecture"`
}
var AppVersion AppVersionInfo

func (*AppVersionInfo) Extended

func (v *AppVersionInfo) Extended() string

func (*AppVersionInfo) Printer

func (v *AppVersionInfo) Printer(c *cli.Context)

func (*AppVersionInfo) ShortLine

func (v *AppVersionInfo) ShortLine() string

type Asset

type Asset struct {
	ID    string    `json:"id"`
	Value string    `json:"value"`
	Type  AssetType `json:"type"`
}

Represents an asset with a value and a type

type AssetType

type AssetType string

Define a custome type for an asset type

const (
	ASSET_IP       AssetType = "ip"
	ASSET_HOSTNAME AssetType = "hostname"
	ASSET_URL      AssetType = "url"
	ASSET_RAW      AssetType = "raw"
)

Set the values for the asset types

type Commander

type Commander interface {
	Execute(c *cli.Context, config *FringeConfig) error
}

type FringeClientModuleListRequest

type FringeClientModuleListRequest struct {
	Modules []Module `json:"modules"`
}

type FringeClientUpdateJobRequest

type FringeClientUpdateJobRequest struct {
	ID          string   `json:"id"`
	Status      string   `json:"status"`
	Assets      []Asset  `json:"datas"`
	Tags        []string `json:"tags"`
	Description string   `json:"description"`
	StartedAt   int64    `json:"startedAt"`
	EndedAt     int64    `json:"endedAt"`
}

func (FringeClientUpdateJobRequest) JSON

type FringeConfig

type FringeConfig struct {
	LogLevel            string            `yaml:"log_level"`
	Proxy               string            `yaml:"proxy"`
	VerifyCert          bool              `yaml:"verify_cert"`
	HomeDirectory       string            `yaml:"home_directory"`
	FringeCoordinator   string            `yaml:"fringe_coordinator"`
	FringeRunnerId      string            `yaml:"fringe_runner_id"`
	FringeRunnerToken   string            `yaml:"fringe_runner_token"`
	ModuleConfiguration map[string]string `yaml:"module_config"`
}

func ReadConfigFile

func ReadConfigFile(configPath string) (*FringeConfig, error)

type FringeWorkflow

type FringeWorkflow struct {
	Name string                `yaml:"name"`
	On   FringeWorkflowTrigger `yaml:"on"`
	Jobs []FringeWorkflowJob   `yaml:"jobs"`
}

func NewFringeWorkflow

func NewFringeWorkflow(filePath string) (*FringeWorkflow, error)

Parse a workflow YAML file, check the structure and returns the object

func (*FringeWorkflow) Run

func (w *FringeWorkflow) Run(asset Asset, sess *Session, config *FringeConfig) error

func (*FringeWorkflow) String

func (w *FringeWorkflow) String() string

type FringeWorkflowAssetType

type FringeWorkflowAssetType []AssetType

type FringeWorkflowJob

type FringeWorkflowJob struct {
	Name   string `yaml:"name"`
	Module string `yaml:"module"`
}

type FringeWorkflowNewAssetTrigger

type FringeWorkflowNewAssetTrigger struct {
	Types FringeWorkflowAssetType `yaml:"types"`
	Regex StringArray             `yaml:"regex"`
}

type FringeWorkflowTrigger

type FringeWorkflowTrigger struct {
	NewAsset FringeWorkflowNewAssetTrigger `yaml:"new_asset"`
}

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

Represents an HTTP client

func NewHTTPClient

func NewHTTPClient(c context.Context, opt *HTTPOptions) (*HTTPClient, error)

func (*HTTPClient) DoJson

func (client *HTTPClient) DoJson(method, target, host, cookie string, request interface{}, response interface{}) (*int, *[]byte, *http.Header, error)

func (*HTTPClient) DoRequest

func (client *HTTPClient) DoRequest(method, target, host, cookie string, data io.Reader) (*int, *[]byte, *http.Header, error)

func (*HTTPClient) DownloadFile

func (client *HTTPClient) DownloadFile(method, target, host, cookie, destination string, data io.Reader) (*int, *http.Header, error)

func (*HTTPClient) Get

func (client *HTTPClient) Get(target, host, cookie string, data io.Reader) (*int, *[]byte, *http.Header, error)

func (*HTTPClient) Post

func (client *HTTPClient) Post(target, host, cookie string, data io.Reader) (*int, *[]byte, *http.Header, error)

func (*HTTPClient) Put

func (client *HTTPClient) Put(target, host, cookie string, data io.Reader) (*int, *[]byte, *http.Header, error)

func (*HTTPClient) Trace

func (client *HTTPClient) Trace(target, host, cookie string, data io.Reader) (*int, *[]byte, *http.Header, error)

type HTTPHeader

type HTTPHeader struct {
	Name  string
	Value string
}

Represents a (custom) HTTP header

func GetBasicAuthHeader

func GetBasicAuthHeader(username string, password string) HTTPHeader

type HTTPOptions

type HTTPOptions struct {
	// We use a default User-Agent but a user may need a custom one to bypass
	// some verification
	UserAgent string
	// Custom headers
	Headers []HTTPHeader
	// Some use need a custom timeout, specially on a brute-force attack
	Timeout time.Duration
	// Do e follow redirection on 301/302 ?
	FollowRedirect bool
	// Set a proxy for the HTTP and HTTPS requests
	Proxy string
	// Do we need to check the SSL/TLS server certificate. Can be usefull when
	// you use a custom proxy like Burp
	VerifyCert bool
	// White list for IP addresses
	WhiteListIP []string
}

Represents options for the HTTP client By default a user pass a HTTP option to instanciate a HTTP client. This struct must contains every options the user needs to pass to configure the client.

type Job

type Job struct {
	ID     string `json:"id"`
	Module string `json:"module"`
	Asset  Asset  `json:"data"`
}

Represents a job: a module to execute with an asset

type Module

type Module struct {
	Name        string `json:"displayName"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
}

type ModuleContext

type ModuleContext struct {
	Asset     Asset
	NewAssets []Asset
	NewTags   []string
	// contains filtered or unexported fields
}

func NewModuleContext

func NewModuleContext(asset Asset, config *FringeConfig) (*ModuleContext, error)

func (*ModuleContext) AddTag

func (ctx *ModuleContext) AddTag(tag string) error

Add a tag to the current asset

func (*ModuleContext) CreateNewAssetAsHostname

func (ctx *ModuleContext) CreateNewAssetAsHostname(hostname string) error

Create a hostname from the current string without format verification

func (*ModuleContext) CreateNewAssetAsIP

func (ctx *ModuleContext) CreateNewAssetAsIP(ip string) error

Create an IP from the current string without format verification

func (*ModuleContext) CreateNewAssetAsRaw

func (ctx *ModuleContext) CreateNewAssetAsRaw(raw string) error

Create a raw asset

func (*ModuleContext) CreateNewAssetAsURL

func (ctx *ModuleContext) CreateNewAssetAsURL(url string) error

Create a URL from the current string without format verification

func (*ModuleContext) GetAssetAsHostname

func (ctx *ModuleContext) GetAssetAsHostname() (string, error)

Check if the asset is a hostname and return it

func (*ModuleContext) GetAssetAsIP

func (ctx *ModuleContext) GetAssetAsIP() (string, error)

Check if the asset is an IP and return it

func (*ModuleContext) GetAssetAsRawString

func (ctx *ModuleContext) GetAssetAsRawString() (string, error)

Get the current asset as a raw string

func (*ModuleContext) GetAssetAsURL

func (ctx *ModuleContext) GetAssetAsURL() (string, error)

Check if the asset is a URL and return it

func (*ModuleContext) GetBeaconAsURL

func (ctx *ModuleContext) GetBeaconAsURL() string

func (*ModuleContext) GetConfigurationValue

func (ctx *ModuleContext) GetConfigurationValue(key string) (string, error)

Get a configuration variable for the module

func (*ModuleContext) GetDefaultHTTPOptions

func (ctx *ModuleContext) GetDefaultHTTPOptions() *HTTPOptions

func (*ModuleContext) GetRessourceFile

func (ctx *ModuleContext) GetRessourceFile(filename string) (string, error)

Get the path for a resource file

func (*ModuleContext) HTTPRequestJson

func (ctx *ModuleContext) HTTPRequestJson(method string, target string, request interface{}, response interface{}, opts *HTTPOptions) (*int, *[]byte, *http.Header, error)

func (*ModuleContext) HttpRequest

func (ctx *ModuleContext) HttpRequest(method string, target string, data io.Reader, opts *HTTPOptions) (*int, *[]byte, *http.Header, error)

type ModuleInterface

type ModuleInterface interface {
	Name() string
	Slug() string
	Description() string
	ResourceURLs() []ModuleResource

	Run(*ModuleContext) error
}

type ModuleList

type ModuleList []ModuleInterface

type ModuleResource

type ModuleResource struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type RunnerClient

type RunnerClient interface {
	SendModuleList([]Module) error
	RequestJob() (*Job, error)
	UpdateJob(*Job, []Asset) error
}

Representeq a client that request next job and send update to a backend

type Session

type Session struct {
	Modules ModuleList
}

func NewSession

func NewSession() (*Session, error)

func (*Session) Close

func (s *Session) Close()

func (*Session) GetModules

func (s *Session) GetModules() ([]Module, error)

func (*Session) Module

func (s *Session) Module(name string) (mod ModuleInterface, err error)

func (*Session) RegisterModule

func (s *Session) RegisterModule(mod ModuleInterface)

type StringArray

type StringArray []string

func (*StringArray) UnmarshalYAML

func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error

From: https://github.com/go-yaml/yaml/issues/100

Jump to

Keyboard shortcuts

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