Documentation
¶
Index ¶
- Constants
- Variables
- func InitBruteforceDetector(config *BruteforceConfig)
- func InitializeHarvesters(config *HarvestersConfigFile) error
- func ResetCredStore()
- func RunHarvesters(banner []byte, transport gopacket.Flow, ident string, firstPacket time.Time, ...)
- func SaveHarvestersConfig(path string, config *HarvestersConfigFile) error
- func WriteCredentials(creds *types.Credentials)
- type BruteforceAlert
- type BruteforceConfig
- type BruteforceDetector
- func (d *BruteforceDetector) GetAlerts() []BruteforceAlert
- func (d *BruteforceDetector) GetStats() map[string]any
- func (d *BruteforceDetector) RecordFailure(sourceIP, targetIP, service, username string, ts time.Time)
- func (d *BruteforceDetector) RecordSuccess(sourceIP, targetIP, service, username string, ts time.Time)
- func (d *BruteforceDetector) SetAlertCallback(cb func(BruteforceAlert))
- func (d *BruteforceDetector) Stop()
- type CustomHarvesterConfig
- type Harvester
- type HarvesterConfig
- type HarvesterInfo
- type HarvestersConfigFile
Constants ¶
const ( EtypeAES128CTS = 17 // AES128-CTS-HMAC-SHA1-96 EtypeAES256CTS = 18 // AES256-CTS-HMAC-SHA1-96 EtypeRC4HMAC = 23 // RC4-HMAC )
Kerberos encryption type constants
const (
// DecoderName is the name for the credentials decoder
DecoderName = "Credentials"
)
Variables ¶
var Decoder = &decoder.AbstractDecoder{ Name: DecoderName, Description: "Credentials to authenticate to a service, like a username and password combination, or a token, api key, etc.", Type: types.Type_NC_Credentials, PostInit: func(d *decoder.AbstractDecoder) (err error) { useHarvesters = true credLog, _, err = logging.InitZapLogger( decoderconfig.Instance.Out, "credentials", decoderconfig.Instance.Debug, ) if err != nil { return err } // Load harvesters configuration var config *HarvestersConfigFile if decoderconfig.Instance.HarvestersConfigPath != "" { config, err = LoadHarvestersConfig(decoderconfig.Instance.HarvestersConfigPath) if err != nil { log.Printf("Failed to load harvesters config from %s: %v. Using default configuration.\n", decoderconfig.Instance.HarvestersConfigPath, err) config = nil } } if err := InitializeHarvesters(config); err != nil { return err } if decoderconfig.Instance.CustomRegex != "" { r, errCompile := regexp.Compile(decoderconfig.Instance.CustomRegex) if errCompile != nil { return errCompile } customRegexHarvester := Harvester{ Name: "Custom Regex", Description: "Custom regex pattern: " + decoderconfig.Instance.CustomRegex, HarvesterFunc: func(data []byte, ident string, ts time.Time) *types.Credentials { matches := r.FindSubmatch(data) if len(matches) > 1 { var notes strings.Builder for _, m := range matches { notes.WriteString(" " + string(m) + " ") } return &types.Credentials{ Notes: notes.String(), } } return nil }, } tcpConnectionHarvesters = append(tcpConnectionHarvesters, customRegexHarvester) } return nil }, DeInit: func(sd *decoder.AbstractDecoder) error { return credLog.Sync() }, }
Decoder for protocol analysis and writing audit records to disk.
Functions ¶
func InitBruteforceDetector ¶ added in v0.9.0
func InitBruteforceDetector(config *BruteforceConfig)
InitBruteforceDetector initializes the global bruteforce detector with custom config This should be called before any calls to GetBruteforceDetector for proper configuration
func InitializeHarvesters ¶ added in v0.9.0
func InitializeHarvesters(config *HarvestersConfigFile) error
InitializeHarvesters sets up the harvesters based on the provided configuration
func ResetCredStore ¶ added in v0.7.6
func ResetCredStore()
ResetCredStore clears the credentials deduplication store This should be called when resetting state between processing different files
func RunHarvesters ¶
func RunHarvesters(banner []byte, transport gopacket.Flow, ident string, firstPacket time.Time, communityID string)
RunHarvesters will use the service probes to determine the service type based on the provided banner. The banner parameter contains at most HarvesterBannerSize bytes from the stream conversation, which is pre-truncated to prevent performance issues when processing large data streams (e.g., file transfers, database dumps, video streaming, etc.). The communityID parameter is the Corelight Community ID v1 for the connection, calculated once at the stream level and available for all harvesters to use for cross-tool correlation.
func SaveHarvestersConfig ¶ added in v0.9.0
func SaveHarvestersConfig(path string, config *HarvestersConfigFile) error
SaveHarvestersConfig saves harvester configuration to a YAML file
func WriteCredentials ¶
func WriteCredentials(creds *types.Credentials)
WriteCredentials is a util that should be used to write credential audit to disk it will deduplicate the audit records to avoid repeating information on disk.
Types ¶
type BruteforceAlert ¶ added in v0.9.0
type BruteforceAlert struct {
Timestamp time.Time
SourceIP string
Service string
FailedAttempts int
TargetServers []string // Unique servers targeted
Duration time.Duration
FirstAttempt time.Time
LastAttempt time.Time
}
BruteforceAlert represents a detected bruteforce attack
func (*BruteforceAlert) String ¶ added in v0.9.0
func (a *BruteforceAlert) String() string
String returns a human-readable description of the alert
type BruteforceConfig ¶ added in v0.9.0
type BruteforceConfig struct {
// FailureThreshold is the number of failed attempts before alerting
FailureThreshold int `yaml:"failure_threshold"`
// MeasurementInterval is the time window for counting failures
MeasurementInterval time.Duration `yaml:"measurement_interval"`
// PerSourceTracking tracks failures per source IP
PerSourceTracking bool `yaml:"per_source_tracking"`
// PerServiceTracking tracks failures per service type
PerServiceTracking bool `yaml:"per_service_tracking"`
// Enabled controls whether bruteforce detection is active
Enabled bool `yaml:"enabled"`
}
BruteforceConfig holds configuration for bruteforce detection
func DefaultBruteforceConfig ¶ added in v0.9.0
func DefaultBruteforceConfig() *BruteforceConfig
DefaultBruteforceConfig returns default bruteforce detection settings Similar to Zeek's FTP/SSH bruteforce detection defaults
type BruteforceDetector ¶ added in v0.9.0
type BruteforceDetector struct {
// contains filtered or unexported fields
}
BruteforceDetector tracks failed authentication attempts and detects bruteforce attacks Similar to Zeek's SumStats-based approach
func GetBruteforceDetector ¶ added in v0.9.0
func GetBruteforceDetector() *BruteforceDetector
GetBruteforceDetector returns the global bruteforce detector instance
func NewBruteforceDetector ¶ added in v0.9.0
func NewBruteforceDetector(config *BruteforceConfig) *BruteforceDetector
NewBruteforceDetector creates a new bruteforce detection instance
func (*BruteforceDetector) GetAlerts ¶ added in v0.9.0
func (d *BruteforceDetector) GetAlerts() []BruteforceAlert
GetAlerts returns all currently tracked alerts
func (*BruteforceDetector) GetStats ¶ added in v0.9.0
func (d *BruteforceDetector) GetStats() map[string]any
GetStats returns statistics about the detector
func (*BruteforceDetector) RecordFailure ¶ added in v0.9.0
func (d *BruteforceDetector) RecordFailure(sourceIP, targetIP, service, username string, ts time.Time)
RecordFailure records a failed authentication attempt This should be called whenever AuthSuccessSet is true and AuthSuccess is false
func (*BruteforceDetector) RecordSuccess ¶ added in v0.9.0
func (d *BruteforceDetector) RecordSuccess(sourceIP, targetIP, service, username string, ts time.Time)
RecordSuccess records a successful authentication (can be used to track password guessers who succeeded)
func (*BruteforceDetector) SetAlertCallback ¶ added in v0.9.0
func (d *BruteforceDetector) SetAlertCallback(cb func(BruteforceAlert))
SetAlertCallback sets the function to call when a bruteforce alert is generated
func (*BruteforceDetector) Stop ¶ added in v0.9.0
func (d *BruteforceDetector) Stop()
Stop stops the bruteforce detector and cleans up resources
type CustomHarvesterConfig ¶ added in v0.9.0
type CustomHarvesterConfig struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Enabled bool `yaml:"enabled" json:"enabled"`
Ports []int `yaml:"ports" json:"ports"`
Regex string `yaml:"regex" json:"regex"`
Parameters map[string]any `yaml:"parameters,omitempty" json:"parameters,omitempty"`
}
CustomHarvesterConfig represents configuration for a custom regex-based harvester
type Harvester ¶ added in v0.9.0
Harvester represents a credential harvester with its function and metadata
type HarvesterConfig ¶ added in v0.9.0
type HarvesterConfig struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Enabled bool `yaml:"enabled" json:"enabled"`
Ports []int `yaml:"ports" json:"ports"`
Parameters map[string]any `yaml:"parameters,omitempty" json:"parameters,omitempty"`
}
HarvesterConfig represents the configuration for a single credential harvester
type HarvesterInfo ¶ added in v0.9.0
HarvesterInfo contains metadata about a credential harvester for API responses
func GetHarvesters ¶ added in v0.9.0
func GetHarvesters() []HarvesterInfo
GetHarvesters returns information about all registered credential harvesters including their names, descriptions, and associated port mappings
type HarvestersConfigFile ¶ added in v0.9.0
type HarvestersConfigFile struct {
Harvesters []HarvesterConfig `yaml:"harvesters" json:"harvesters"`
CustomHarvesters []CustomHarvesterConfig `yaml:"custom_harvesters,omitempty" json:"custom_harvesters,omitempty"`
}
HarvestersConfigFile represents the entire harvesters configuration file structure
func GetDefaultHarvestersConfig ¶ added in v0.9.0
func GetDefaultHarvestersConfig() *HarvestersConfigFile
GetDefaultHarvestersConfig returns the default harvester configuration
func GetHarvesterConfig ¶ added in v0.9.0
func GetHarvesterConfig() *HarvestersConfigFile
GetHarvesterConfig returns the current harvester configuration
func LoadHarvestersConfig ¶ added in v0.9.0
func LoadHarvestersConfig(path string) (*HarvestersConfigFile, error)
LoadHarvestersConfig loads harvester configuration from a YAML file
Source Files
¶
- bruteforce.go
- config.go
- credentials.go
- creditcard.go
- ftp.go
- harvester.go
- http.go
- http_ntlm.go
- imap.go
- kerberos_asrep.go
- kerberos_asreq.go
- kerberos_common.go
- kerberos_tgsrep.go
- ldap.go
- mdns.go
- mongodb.go
- mqtt.go
- mysql.go
- nbns.go
- ntlmssp.go
- pop3.go
- postgres.go
- radius.go
- redis.go
- sip.go
- smtp.go
- snmp.go
- socks.go
- teamviewer.go
- telnet.go
- upnp.go
- vnc.go