Skip to content

Commit 1c33341

Browse files
committed
feat(detectors): migrate syscall_table_hooking signature to detector
Migrated from signatures/golang/syscall_table_hooking.go Detector ID: TRC-1030
1 parent 8e2ed44 commit 1c33341

File tree

5 files changed

+101
-167
lines changed

5 files changed

+101
-167
lines changed

detectors/syscall_table_hooking.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package detectors
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
9+
10+
"github.com/aquasecurity/tracee/api/v1beta1"
11+
"github.com/aquasecurity/tracee/api/v1beta1/detection"
12+
)
13+
14+
func TestSyscallTableHooking(t *testing.T) {
15+
t.Parallel()
16+
17+
detector := &SyscallTableHooking{}
18+
err := detector.Init(detection.DetectorParams{Logger: &mockLogger{}})
19+
require.NoError(t, err)
20+
21+
event := &v1beta1.Event{
22+
Id: v1beta1.EventId_hooked_syscall,
23+
Name: "hooked_syscall",
24+
Workload: &v1beta1.Workload{
25+
Process: &v1beta1.Process{
26+
Executable: &v1beta1.Executable{Path: "/usr/bin/test"},
27+
},
28+
},
29+
Data: []*v1beta1.EventValue{},
30+
}
31+
32+
output, err := detector.OnEvent(context.Background(), event)
33+
require.NoError(t, err)
34+
assert.Len(t, output, 1, "Expected detection for hooked_syscall event")
35+
}

signatures/golang/export.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import "github.com/aquasecurity/tracee/types/detect"
66
// this is a list of signatures that this plugin exports
77
var ExportedSignatures = []detect.Signature{
88
&SystemRequestKeyConfigModification{},
9-
&SyscallTableHooking{},
109
}
1110

1211
// ExportedDataSources fulfills the goplugins contract required by the rule-engine

signatures/golang/syscall_table_hooking.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

signatures/golang/syscall_table_hooking_test.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)