config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config handles command-line flags, authentication, and runtime configuration for flashingestor.

Index

Constants

View Source
const DCERPC_EPM_TIMEOUT = 2 * time.Second // Timeout for DCE/RPC endpoint mapper
View Source
const DEFAULT_LDAP_SCHEME = "ldaps"
View Source
const DEFAULT_LDAP_TIMEOUT = 30 * time.Second
View Source
const DEFAULT_LDAP_WORKERS = 10
View Source
const DEFAULT_REMOTE_COMPUTER_TIMEOUT = 10 * time.Second
View Source
const DEFAULT_REMOTE_METHOD_TIMEOUT = 4 * time.Second
View Source
const DEFAULT_REMOTE_WORKERS = 50
View Source
const DNS_DIAL_TIMEOUT = 5 * time.Second // Timeout for dialing to DNS server
View Source
const DNS_LOOKUP_TIMEOUT = 10 * time.Second // Timeout for DNS lookups
View Source
const HTTP_TIMEOUT = 3 * time.Second // Timeout for HTTP
View Source
const KERBEROS_TIMEOUT = 2 * time.Second // Timeout for Kerberos
View Source
const MAX_VERBOSITY_LEVEL = 2 // Maximum verbosity level (0=normal, 1=verbose, 2=debug)
View Source
const NETBIOS_TIMEOUT = 2 * time.Second // Timeout for NetBIOS
View Source
const PORTCHECK_TIMEOUT = 2 * time.Second // Generic timeout for port checking

Timeout constants for various network operations

View Source
const SMB_TIMEOUT = 2 * time.Second // Timeout for SMB

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DomainController      string
	OutputDir             string
	LogFile               string
	RemoteWorkers         int
	PageSizeOverride      int
	LdapWorkers           int
	JobFilter             string
	RemoteComputerTimeout time.Duration
	RemoteMethodTimeout   time.Duration
	CustomDns             string
	DnsTcp                bool
	ConfigPath            string
	PprofEnabled          bool
	VerbosityLevel        int
	LdapAuthOptions       *ldapauth.Options
	RuntimeOptions        *RuntimeOptions

	IngestAuth       *CredentialMgr
	RemoteAuth       *CredentialMgr
	ChosenAuthIngest string
	ChosenAuthRemote string
	Resolver         *CustomResolver
	LdapxFilter      string
	LdapxAttrs       string
	LdapxBaseDN      string
}

Config holds all application configuration

func ParseFlags

func ParseFlags() (*Config, error)

ParseFlags parses command line flags and returns a configuration instance

type CredentialMgr

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

func NewCredentialMgr

func NewCredentialMgr(credential *adauth.Credential, useKerberos bool) *CredentialMgr

func ParseCredential

func ParseCredential(opts *adauth.Options, isEmptyPassword bool) (string, *CredentialMgr, error)

ParseCredential determines the authentication method based on provided options and returns a preliminary credential. It supports the following methods: [Via Kerberos] - User + Password - User + NTHash - User + AESKey - User + Certificate (PKINIT / Kerberos) ==> Certificate is either PFX or PEM/KEY pair - User + CCache ==> CCache is either from KRB5CCNAME or --ccache [Via regular methods] - User + Certificate (SChannel for LDAP, for RPC only PKINIT is possible) - User + Password (NTLM) - User + NTHash (NTLM) - Anonymous (LDAP only)

func (*CredentialMgr) Creds

func (a *CredentialMgr) Creds() *adauth.Credential

func (*CredentialMgr) Dialer

func (a *CredentialMgr) Dialer(timeout time.Duration) *CustomDialer

func (*CredentialMgr) Kerberos

func (a *CredentialMgr) Kerberos() bool

func (*CredentialMgr) NewTarget

func (a *CredentialMgr) NewTarget(protocol string, targetHost string) *adauth.Target

func (*CredentialMgr) Resolver

func (a *CredentialMgr) Resolver() *net.Resolver

func (*CredentialMgr) SetDC

func (a *CredentialMgr) SetDC(dc string)

type CustomDialer added in v0.3.0

type CustomDialer struct {
	net.Dialer
	// contains filtered or unexported fields
}

CustomDialer wraps a net.Dialer to use CustomResolver's cache

func (*CustomDialer) Dial added in v0.3.0

func (cd *CustomDialer) Dial(network, address string) (net.Conn, error)

func (*CustomDialer) DialContext added in v0.3.0

func (cd *CustomDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type CustomResolver added in v0.3.0

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

CustomResolver wraps net.Resolver with caching

func (*CustomResolver) LookupAddr added in v0.3.0

func (cr *CustomResolver) LookupAddr(ctx context.Context, addr string) ([]string, error)

LookupAddr performs a cached address lookup

func (*CustomResolver) LookupCNAME added in v0.3.0

func (cr *CustomResolver) LookupCNAME(ctx context.Context, host string) (string, error)

LookupCNAME performs a cached CNAME lookup

func (*CustomResolver) LookupHost added in v0.3.0

func (cr *CustomResolver) LookupHost(ctx context.Context, host string) ([]string, error)

LookupHost performs a cached host lookup

func (*CustomResolver) LookupIP added in v0.3.0

func (cr *CustomResolver) LookupIP(ctx context.Context, network, host string) ([]net.IP, error)

LookupIP performs a cached IP lookup

func (*CustomResolver) LookupIPAddr added in v0.3.0

func (cr *CustomResolver) LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)

LookupIPAddr performs a cached IPAddr lookup

func (*CustomResolver) LookupMX added in v0.3.0

func (cr *CustomResolver) LookupMX(ctx context.Context, name string) ([]*net.MX, error)

LookupMX performs a cached MX lookup

func (*CustomResolver) LookupNS added in v0.3.0

func (cr *CustomResolver) LookupNS(ctx context.Context, name string) ([]*net.NS, error)

LookupNS performs a cached NS lookup

func (*CustomResolver) LookupPort added in v0.3.0

func (cr *CustomResolver) LookupPort(ctx context.Context, network, service string) (int, error)

LookupPort performs a cached port lookup

func (*CustomResolver) LookupSRV added in v0.3.0

func (cr *CustomResolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*net.SRV, error)

LookupSRV performs a cached SRV lookup

func (*CustomResolver) LookupTXT added in v0.3.0

func (cr *CustomResolver) LookupTXT(ctx context.Context, name string) ([]string, error)

LookupTXT performs a cached TXT lookup

type DialerWithResolver

type DialerWithResolver struct {
	Resolver *CustomResolver
	Timeout  time.Duration
}

DialerWithResolver implements custom LDAP dialing with DNS resolver override. TODO: Review if there's a better way (shouldn't ConnectTo respect my specified Resolver?)

func (*DialerWithResolver) Dial

func (d *DialerWithResolver) Dial(network, addr string) (net.Conn, error)

Dial implements the Dialer interface with a default context timeout.

func (*DialerWithResolver) DialContext

func (d *DialerWithResolver) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext resolves the address using the custom resolver and dials using TCP.

type QueryDefinition

type QueryDefinition struct {
	Name       string   `yaml:"name"`
	Filter     string   `yaml:"filter"`
	Attributes []string `yaml:"attributes"`
	PageSize   int      `yaml:"page_size"`
}

QueryDefinition represents a single LDAP query configuration

type RuntimeOptions

type RuntimeOptions struct {
	Ingestion struct {
		RecurseTrusts          bool              `yaml:"recurse_trusts"`
		RecurseFeasibleOnly    bool              `yaml:"recurse_feasible_only"`
		IncludeACLs            bool              `yaml:"include_acls"`
		SearchForest           bool              `yaml:"search_forest"`
		LdapsToLdapFallback    bool              `yaml:"ldaps_to_ldap_fallback"`
		PromptMsgpackOverwrite bool              `yaml:"prompt_msgpack_overwrite"`
		AppendForestDomains    bool              `yaml:"append_forest_domains"`
		Queries                []QueryDefinition `yaml:"queries"`
	} `yaml:"ingestion"`

	RemoteCollection struct {
		Methods            []string `yaml:"methods"`
		AvailabilityChecks []string `yaml:"availability_checks"`
	} `yaml:"remote_collection"`

	Conversion struct {
		MergeRemote             bool `yaml:"merge_remote"`
		WriterBufsize           int  `yaml:"writer_bufsize"`
		CompressOutput          bool `yaml:"compress_output"`
		CleanupAfterCompression bool `yaml:"cleanup_after_compression"`
	} `yaml:"conversion"`
	// contains filtered or unexported fields
}

RuntimeOptions holds configurable runtime options that can be changed while running

func FallbackOptions

func FallbackOptions() *RuntimeOptions

FallbackOptions returns default runtime options

func LoadOptions

func LoadOptions(configPath string) (*RuntimeOptions, error)

LoadOptions loads options from a YAML file, or returns defaults if file doesn't exist

func (*RuntimeOptions) DisableMethod

func (opts *RuntimeOptions) DisableMethod(method string)

DisableMethod removes a specific collection method from the enabled list

func (*RuntimeOptions) GetAppendForestDomains

func (opts *RuntimeOptions) GetAppendForestDomains() bool

func (*RuntimeOptions) GetAvailabilityChecks added in v0.2.0

func (opts *RuntimeOptions) GetAvailabilityChecks() map[string]bool

GetAvailabilityChecks returns a map of availability checks to run Returns empty map if not configured (meaning no checks run)

func (*RuntimeOptions) GetCleanupAfterCompression

func (opts *RuntimeOptions) GetCleanupAfterCompression() bool

func (*RuntimeOptions) GetCompressOutput

func (opts *RuntimeOptions) GetCompressOutput() bool

func (*RuntimeOptions) GetEnabledMethods

func (opts *RuntimeOptions) GetEnabledMethods() []string

GetEnabledMethods returns a copy of the enabled methods list

func (*RuntimeOptions) GetIncludeACLs

func (opts *RuntimeOptions) GetIncludeACLs() bool

func (*RuntimeOptions) GetLdapsToLdapFallback

func (opts *RuntimeOptions) GetLdapsToLdapFallback() bool

func (*RuntimeOptions) GetMergeRemote

func (opts *RuntimeOptions) GetMergeRemote() bool

func (*RuntimeOptions) GetPromptMsgpackOverwrite

func (opts *RuntimeOptions) GetPromptMsgpackOverwrite() bool

func (*RuntimeOptions) GetQueries

func (opts *RuntimeOptions) GetQueries() []QueryDefinition

GetQueries returns a copy of the query definitions

func (*RuntimeOptions) GetRecurseFeasibleOnly

func (opts *RuntimeOptions) GetRecurseFeasibleOnly() bool

func (*RuntimeOptions) GetRecurseTrusts

func (opts *RuntimeOptions) GetRecurseTrusts() bool

func (*RuntimeOptions) GetSearchForest

func (opts *RuntimeOptions) GetSearchForest() bool

func (*RuntimeOptions) GetWriterBufsize

func (opts *RuntimeOptions) GetWriterBufsize() int

func (*RuntimeOptions) HasAnyMethodsEnabled added in v0.3.0

func (opts *RuntimeOptions) HasAnyMethodsEnabled() bool

HasAnyMethodsEnabled checks if any remote collection methods are enabled

func (*RuntimeOptions) IsAnyCAMethodEnabled added in v0.3.0

func (opts *RuntimeOptions) IsAnyCAMethodEnabled() bool

IsAnyCAMethodEnabled checks if any Enterprise CA collection methods are enabled

func (*RuntimeOptions) IsAnyComputerMethodEnabled added in v0.3.0

func (opts *RuntimeOptions) IsAnyComputerMethodEnabled() bool

IsAnyComputerMethodEnabled checks if any computer collection methods are enabled

func (*RuntimeOptions) IsMethodEnabled

func (opts *RuntimeOptions) IsMethodEnabled(method string) bool

IsMethodEnabled checks if a specific collection method is enabled

func (*RuntimeOptions) SaveOptions

func (opts *RuntimeOptions) SaveOptions(configPath string) error

SaveOptions saves current options to a YAML file

func (*RuntimeOptions) SetAppendForestDomains

func (opts *RuntimeOptions) SetAppendForestDomains(enabled bool)

func (*RuntimeOptions) SetAvailabilityChecks added in v0.2.0

func (opts *RuntimeOptions) SetAvailabilityChecks(checks []string)

func (*RuntimeOptions) SetCleanupAfterCompression

func (opts *RuntimeOptions) SetCleanupAfterCompression(enabled bool)

func (*RuntimeOptions) SetCompressOutput

func (opts *RuntimeOptions) SetCompressOutput(enabled bool)

func (*RuntimeOptions) SetIncludeACLs

func (opts *RuntimeOptions) SetIncludeACLs(enabled bool)

func (*RuntimeOptions) SetLdapsToLdapFallback

func (opts *RuntimeOptions) SetLdapsToLdapFallback(enabled bool)

func (*RuntimeOptions) SetMergeRemote

func (opts *RuntimeOptions) SetMergeRemote(enabled bool)

func (*RuntimeOptions) SetPromptMsgpackOverwrite

func (opts *RuntimeOptions) SetPromptMsgpackOverwrite(enabled bool)

func (*RuntimeOptions) SetRecurseTrusts

func (opts *RuntimeOptions) SetRecurseTrusts(enabled bool)

Thread-safe setters

func (*RuntimeOptions) SetSearchForest

func (opts *RuntimeOptions) SetSearchForest(enabled bool)

func (*RuntimeOptions) SetWriterBufsize

func (opts *RuntimeOptions) SetWriterBufsize(size int)

Jump to

Keyboard shortcuts

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