|
| 1 | +package detectors |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + "github.com/aquasecurity/tracee/api/v1beta1" |
| 7 | + "github.com/aquasecurity/tracee/api/v1beta1/detection" |
| 8 | +) |
| 9 | + |
| 10 | +func init() { |
| 11 | + register(&SyscallTableHooking{}) |
| 12 | +} |
| 13 | + |
| 14 | +// SyscallTableHooking detects syscall table hooking (rootkit behavior). |
| 15 | +// Origin: "*" (triggers on both host and containers - no container=started filter). |
| 16 | +type SyscallTableHooking struct { |
| 17 | + logger detection.Logger |
| 18 | +} |
| 19 | + |
| 20 | +func (d *SyscallTableHooking) GetDefinition() detection.DetectorDefinition { |
| 21 | + return detection.DetectorDefinition{ |
| 22 | + ID: "TRC-1030", |
| 23 | + Requirements: detection.DetectorRequirements{ |
| 24 | + Events: []detection.EventRequirement{ |
| 25 | + { |
| 26 | + Name: "hooked_syscall", |
| 27 | + Dependency: detection.DependencyRequired, |
| 28 | + // Note: Origin "*" from original - no container filter |
| 29 | + }, |
| 30 | + }, |
| 31 | + }, |
| 32 | + ProducedEvent: v1beta1.EventDefinition{ |
| 33 | + Name: "syscall_hooking", |
| 34 | + Description: "Syscall table hooking detected", |
| 35 | + Version: &v1beta1.Version{Major: 1, Minor: 0, Patch: 0}, |
| 36 | + }, |
| 37 | + ThreatMetadata: &v1beta1.Threat{ |
| 38 | + Name: "Syscall table hooking detected", |
| 39 | + Description: "Syscall table hooking detected. Syscalls (system calls) are the interface between user applications and the kernel. By hooking the syscall table an adversary gains control on certain system function, such as file writing and reading or other basic function performed by the operation system. The adversary may also hijack the execution flow and execute it's own code. Syscall table hooking is considered a malicious behavior that is performed by rootkits and may indicate that the host's kernel has been compromised. Hidden modules are marked as hidden symbol owners and indicate further malicious activity of an adversary.", |
| 40 | + Severity: v1beta1.Severity_HIGH, |
| 41 | + Mitre: &v1beta1.Mitre{ |
| 42 | + Tactic: &v1beta1.MitreTactic{Name: "Defense Evasion"}, |
| 43 | + Technique: &v1beta1.MitreTechnique{Id: "T1014", Name: "Rootkit"}, |
| 44 | + }, |
| 45 | + Properties: map[string]string{"Category": "defense-evasion"}, |
| 46 | + }, |
| 47 | + AutoPopulate: detection.AutoPopulateFields{Threat: true, DetectedFrom: true}, |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +func (d *SyscallTableHooking) Init(params detection.DetectorParams) error { |
| 52 | + d.logger = params.Logger |
| 53 | + d.logger.Debugw("SyscallTableHooking detector initialized") |
| 54 | + return nil |
| 55 | +} |
| 56 | + |
| 57 | +func (d *SyscallTableHooking) OnEvent(ctx context.Context, event *v1beta1.Event) ([]detection.DetectorOutput, error) { |
| 58 | + // Every hooked_syscall event is a detection |
| 59 | + d.logger.Debugw("Syscall table hooking detected") |
| 60 | + return detection.Detected(), nil |
| 61 | +} |
| 62 | + |
| 63 | +func (d *SyscallTableHooking) Close() error { |
| 64 | + d.logger.Debugw("SyscallTableHooking detector closed") |
| 65 | + return nil |
| 66 | +} |
0 commit comments