Documentation
¶
Index ¶
- Constants
- Variables
- func FTPHarvesterEnabled() bool
- func HTTPFormCredentials(form url.Values) (user, password string, found bool)
- func HarvestAdditionalConversation(c *core.ConversationInfo)
- func HarvestFTPConversation(c *core.ConversationInfo)
- func HarvestHTTPNTLMIdentity(header, src, dst string, srcPort, dstPort int32, at int64, community string)
- func HarvestNTLMIdentityToken(data []byte, src, dst string, srcPort, dstPort int32, at int64, ...)
- func HarvestSMTPConversation(c *core.ConversationInfo)
- func HarvestTelnetConversation(c *core.ConversationInfo)
- func InitBruteforceDetector(config *BruteforceConfig)
- func InitializeHarvesters(config *HarvestersConfigFile) error
- func ResetSecretStore()
- func RunHarvesters(banner []byte, transport gopacket.Flow, ident string, firstPacket time.Time, ...)
- func SaveHarvestersConfig(path string, config *HarvestersConfigFile) error
- func SecretEndpoints(flow string) (string, int32, string, int32, bool)
- func WriteSecret(creds *types.Secret)
- 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 = "Secret"
)
const IdentityService = "NTLMSSP Identity"
Variables ¶
var Decoder = &decoder.AbstractDecoder{ Name: DecoderName, Description: "Secrets to authenticate to a service, like a username and password combination, or a token, api key, etc.", Type: types.Type_NC_Secret, 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.Secret { matches := r.FindSubmatch(data) if len(matches) > 1 { var notes strings.Builder for _, m := range matches { notes.WriteString(" " + string(m) + " ") } return &types.Secret{ 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 FTPHarvesterEnabled ¶ added in v0.16.0
func FTPHarvesterEnabled() bool
FTPHarvesterEnabled also lets Secret-only captures select the FTP reader.
func HTTPFormCredentials ¶ added in v0.16.7
HTTPFormCredentials shares configured field names with the parsed HTTP reader.
func HarvestAdditionalConversation ¶
func HarvestAdditionalConversation(c *core.ConversationInfo)
func HarvestFTPConversation ¶ added in v0.16.0
func HarvestFTPConversation(c *core.ConversationInfo)
HarvestFTPConversation is called only by the selected FTP reader. Protocol evidence qualifies the exchange independently of HarvesterPortFilter.
func HarvestHTTPNTLMIdentity ¶
func HarvestNTLMIdentityToken ¶
func HarvestNTLMIdentityToken(data []byte, src, dst string, srcPort, dstPort int32, at int64, community string)
Call only for credentials carried in an explicitly parsed authentication field.
func HarvestSMTPConversation ¶
func HarvestSMTPConversation(c *core.ConversationInfo)
SMTP auth needs the full ordered exchange, not a truncated service banner.
func HarvestTelnetConversation ¶ added in v0.16.7
func HarvestTelnetConversation(c *core.ConversationInfo)
func InitBruteforceDetector ¶
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 ¶
func InitializeHarvesters(config *HarvestersConfigFile) error
InitializeHarvesters sets up the harvesters based on the provided configuration
func ResetSecretStore ¶
func ResetSecretStore()
ResetSecretStore remains for capture lifecycle compatibility. Occurrences are no longer deduplicated, so no credential-identity state survives a write.
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 ¶
func SaveHarvestersConfig(path string, config *HarvestersConfigFile) error
SaveHarvestersConfig saves harvester configuration to a YAML file
func WriteSecret ¶
WriteSecret retains each observed occurrence, including repeated credentials in the same flow. Identity deduplication must not discard transaction evidence.
Types ¶
type BruteforceAlert ¶
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 ¶
func (a *BruteforceAlert) String() string
String returns a human-readable description of the alert
type BruteforceConfig ¶
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 ¶
func DefaultBruteforceConfig() *BruteforceConfig
DefaultBruteforceConfig returns default bruteforce detection settings Similar to Zeek's FTP/SSH bruteforce detection defaults
type BruteforceDetector ¶
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 ¶
func GetBruteforceDetector() *BruteforceDetector
GetBruteforceDetector returns the global bruteforce detector instance
func NewBruteforceDetector ¶
func NewBruteforceDetector(config *BruteforceConfig) *BruteforceDetector
NewBruteforceDetector creates a new bruteforce detection instance
func (*BruteforceDetector) GetAlerts ¶
func (d *BruteforceDetector) GetAlerts() []BruteforceAlert
GetAlerts returns all currently tracked alerts
func (*BruteforceDetector) GetStats ¶
func (d *BruteforceDetector) GetStats() map[string]any
GetStats returns statistics about the detector
func (*BruteforceDetector) RecordFailure ¶
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 ¶
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 ¶
func (d *BruteforceDetector) SetAlertCallback(cb func(BruteforceAlert))
SetAlertCallback sets the function to call when a bruteforce alert is generated
func (*BruteforceDetector) Stop ¶
func (d *BruteforceDetector) Stop()
Stop stops the bruteforce detector and cleans up resources
type CustomHarvesterConfig ¶
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 HarvesterConfig ¶
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 ¶
HarvesterInfo contains metadata about a credential harvester for API responses
func GetHarvesters ¶
func GetHarvesters() []HarvesterInfo
GetHarvesters returns information about all registered credential harvesters including their names, descriptions, and associated port mappings
type HarvestersConfigFile ¶
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 ¶
func GetDefaultHarvestersConfig() *HarvestersConfigFile
GetDefaultHarvestersConfig returns the default harvester configuration
func GetHarvesterConfig ¶
func GetHarvesterConfig() *HarvestersConfigFile
GetHarvesterConfig returns the current harvester configuration
func LoadHarvestersConfig ¶
func LoadHarvestersConfig(path string) (*HarvestersConfigFile, error)
LoadHarvestersConfig loads harvester configuration from a YAML file
Source Files
¶
- bruteforce.go
- config.go
- creditcard.go
- ftp.go
- harvester.go
- http.go
- http_ntlm.go
- identity_conversation.go
- imap.go
- kerberos_asrep.go
- kerberos_asreq.go
- kerberos_common.go
- kerberos_tgsrep.go
- ldap.go
- mail_conversation.go
- mdns.go
- mongodb.go
- mqtt.go
- mysql.go
- nbns.go
- ntlmssp.go
- pop3.go
- postgres.go
- radius.go
- redis.go
- secret.go
- sip.go
- smtp.go
- smtp_conversation.go
- snmp.go
- socks.go
- teamviewer.go
- telnet.go
- telnet_conversation.go
- upnp.go
- vnc.go