feat(go): port memory-map detector tranche
This commit is contained in:
parent
c6f7219de8
commit
6a27e6e770
13 changed files with 377 additions and 41 deletions
|
|
@ -44,19 +44,27 @@ var defaultStealthNetworkAllowComms = []string{
|
|||
"tcpdump", "dumpcap", "wireshark", "suricata", "zeek",
|
||||
}
|
||||
|
||||
var defaultMemoryObfuscationAllowComms = []string{
|
||||
"java", "node", "firefox", "chromium", "chrome", "google-chrome",
|
||||
"brave", "brave-browser", "WebKitWebProcess", "dotnet", "qemu-system-x86",
|
||||
"qemu-system-x86_64", "wine", "wasmtime",
|
||||
}
|
||||
|
||||
// Config mirrors the Phase 1 settings consumed by the Go sweep loop. More
|
||||
// fields are added as their detectors are ported.
|
||||
type Config struct {
|
||||
SampleInterval time.Duration
|
||||
HeartbeatMaxAge int
|
||||
Detectors map[string]bool
|
||||
InputSnooperAllowComms map[string]bool
|
||||
CredentialAccessAllowComms map[string]bool
|
||||
CredentialAccessExtraPaths []string
|
||||
Interpreters map[string]bool
|
||||
EgressAllowCIDRs []string
|
||||
StealthNetworkAllowComms map[string]bool
|
||||
StealthNetworkAllowKinds map[string]bool
|
||||
SampleInterval time.Duration
|
||||
HeartbeatMaxAge int
|
||||
Detectors map[string]bool
|
||||
InputSnooperAllowComms map[string]bool
|
||||
CredentialAccessAllowComms map[string]bool
|
||||
CredentialAccessExtraPaths []string
|
||||
Interpreters map[string]bool
|
||||
EgressAllowCIDRs []string
|
||||
StealthNetworkAllowComms map[string]bool
|
||||
StealthNetworkAllowKinds map[string]bool
|
||||
MemoryObfuscationAllowComms map[string]bool
|
||||
MemoryObfuscationAllowPaths []string
|
||||
}
|
||||
|
||||
// Default returns Python-compatible defaults for the fields currently used.
|
||||
|
|
@ -66,16 +74,18 @@ func Default() Config {
|
|||
detectors[name] = true
|
||||
}
|
||||
return Config{
|
||||
SampleInterval: 4 * time.Second,
|
||||
HeartbeatMaxAge: 120,
|
||||
Detectors: detectors,
|
||||
InputSnooperAllowComms: stringSet(defaultInputSnooperAllowComms),
|
||||
CredentialAccessAllowComms: stringSet(defaultCredentialAccessAllowComms),
|
||||
CredentialAccessExtraPaths: []string{},
|
||||
Interpreters: stringSet(defaultInterpreters),
|
||||
EgressAllowCIDRs: []string{},
|
||||
StealthNetworkAllowComms: stringSet(defaultStealthNetworkAllowComms),
|
||||
StealthNetworkAllowKinds: map[string]bool{},
|
||||
SampleInterval: 4 * time.Second,
|
||||
HeartbeatMaxAge: 120,
|
||||
Detectors: detectors,
|
||||
InputSnooperAllowComms: stringSet(defaultInputSnooperAllowComms),
|
||||
CredentialAccessAllowComms: stringSet(defaultCredentialAccessAllowComms),
|
||||
CredentialAccessExtraPaths: []string{},
|
||||
Interpreters: stringSet(defaultInterpreters),
|
||||
EgressAllowCIDRs: []string{},
|
||||
StealthNetworkAllowComms: stringSet(defaultStealthNetworkAllowComms),
|
||||
StealthNetworkAllowKinds: map[string]bool{},
|
||||
MemoryObfuscationAllowComms: stringSet(defaultMemoryObfuscationAllowComms),
|
||||
MemoryObfuscationAllowPaths: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +183,18 @@ func Load(path string) (Config, error) {
|
|||
return Config{}, fmt.Errorf("stealth_network_allow_kinds: %w", err)
|
||||
}
|
||||
cfg.StealthNetworkAllowKinds = stringSet(kinds)
|
||||
case "memory_obfuscation_allow_comms":
|
||||
comms, err := stringArray(value)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("memory_obfuscation_allow_comms: %w", err)
|
||||
}
|
||||
cfg.MemoryObfuscationAllowComms = stringSet(comms)
|
||||
case "memory_obfuscation_allow_paths":
|
||||
paths, err := stringArray(value)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("memory_obfuscation_allow_paths: %w", err)
|
||||
}
|
||||
cfg.MemoryObfuscationAllowPaths = paths
|
||||
}
|
||||
}
|
||||
return cfg, nil
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ interpreters = ["bash", "python3"]
|
|||
egress_allow_cidrs = ["203.0.113.0/24"]
|
||||
stealth_network_allow_comms = ["tcpdump"]
|
||||
stealth_network_allow_kinds = ["mptcp"]
|
||||
memory_obfuscation_allow_comms = ["jit-runtime"]
|
||||
memory_obfuscation_allow_paths = ["/tmp/known-profiler/"]
|
||||
unknown_future_key = true
|
||||
`)
|
||||
if err := os.WriteFile(path, raw, 0o600); err != nil {
|
||||
|
|
@ -64,6 +66,11 @@ unknown_future_key = true
|
|||
t.Fatalf("unexpected stealth tuning: %#v %#v",
|
||||
cfg.StealthNetworkAllowComms, cfg.StealthNetworkAllowKinds)
|
||||
}
|
||||
if !cfg.MemoryObfuscationAllowComms["jit-runtime"] || len(cfg.MemoryObfuscationAllowPaths) != 1 ||
|
||||
cfg.MemoryObfuscationAllowPaths[0] != "/tmp/known-profiler/" {
|
||||
t.Fatalf("unexpected memory tuning: %#v %#v",
|
||||
cfg.MemoryObfuscationAllowComms, cfg.MemoryObfuscationAllowPaths)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMissingFileKeepsDefaults(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue