Skip to content

Commit cba2e74

Browse files
committed
refactor(evasion): Simplify module condition in direct syscall detection
evasion
1 parent 11ab687 commit cba2e74

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

internal/evasion/direct_syscall.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
package evasion
2020

2121
import (
22-
"github.com/rabbitstack/fibratus/pkg/event"
2322
"path/filepath"
2423
"strings"
24+
25+
"github.com/rabbitstack/fibratus/pkg/event"
2526
)
2627

2728
// directSyscall direct syscall evasion refers to a technique where
@@ -54,11 +55,16 @@ func (d *directSyscall) Eval(e *event.Event) (bool, error) {
5455

5556
mod := filepath.Base(strings.ToLower(frame.Module))
5657

57-
// check if the last userspace frame is originated
58+
// check if the last user space frame is originated
5859
// from the allowed modules such as the native NTDLL
5960
// module. If that's not the case, the process is
60-
// invoking a direct syscall
61-
return mod != "ntdll.dll" && mod != "win32.dll" && mod != "win32u.dll" && mod != "wow64win.dll" && mod != "wow64cpu.dll", nil
61+
// likely invoking a direct syscall
62+
switch mod {
63+
case "ntdll.dll", "win32.dll", "win32u.dll", "wow64win.dll", "wow64cpu.dll":
64+
return false, nil
65+
default:
66+
return true, nil
67+
}
6268
}
6369

64-
func (d *directSyscall) Type() Type { return DirectSyscall }
70+
func (*directSyscall) Type() Type { return DirectSyscall }

0 commit comments

Comments
 (0)