Expand TUI guidance and host detection coverage
This commit is contained in:
parent
3b037646d2
commit
8194d13734
20 changed files with 414 additions and 42 deletions
|
|
@ -30,6 +30,8 @@ class HostRule:
|
|||
peer_public: bool | None = None
|
||||
peer_ports: frozenset[int] = frozenset()
|
||||
peer_port_exclude: frozenset[int] = frozenset()
|
||||
local_ports: frozenset[int] = frozenset()
|
||||
local_port_exclude: frozenset[int] = frozenset()
|
||||
argv_regex: str | None = None
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
|
@ -37,7 +39,8 @@ class HostRule:
|
|||
raise ValueError(f"rule sid={self.sid} has no event types")
|
||||
if not any((
|
||||
self.comm, self.parent_comm, self.peer_public is not None,
|
||||
self.peer_ports, self.peer_port_exclude, self.argv_regex,
|
||||
self.peer_ports, self.peer_port_exclude, self.local_ports,
|
||||
self.local_port_exclude, self.argv_regex,
|
||||
)):
|
||||
raise ValueError(f"rule sid={self.sid} has no match conditions")
|
||||
if self.argv_regex is not None:
|
||||
|
|
@ -59,6 +62,10 @@ class HostRule:
|
|||
return False
|
||||
if self.peer_port_exclude and ev.peer_port in self.peer_port_exclude:
|
||||
return False
|
||||
if self.local_ports and ev.local_port not in self.local_ports:
|
||||
return False
|
||||
if self.local_port_exclude and ev.local_port in self.local_port_exclude:
|
||||
return False
|
||||
if self._argv_re is not None and not self._argv_re.search(ev.argv_str):
|
||||
return False
|
||||
return True
|
||||
|
|
@ -70,7 +77,8 @@ class HostRule:
|
|||
key=f"host:{self.sid}:{ev.event}:{ev.pid}:{ev.peer_ip}:{ev.peer_port}",
|
||||
detail=(
|
||||
f"sid={self.sid} {self.msg} - pid={ev.pid} ppid={ev.ppid} "
|
||||
f"comm={ev.comm} event={ev.event} peer={ev.peer_ip}:{ev.peer_port}"
|
||||
f"comm={ev.comm} event={ev.event} peer={ev.peer_ip}:{ev.peer_port} "
|
||||
f"local={ev.local_ip}:{ev.local_port}"
|
||||
),
|
||||
pids=(ev.pid,),
|
||||
sid=self.sid,
|
||||
|
|
@ -89,6 +97,15 @@ DEFAULT_HOST_RULES: tuple[HostRule, ...] = (
|
|||
peer_public=True,
|
||||
peer_port_exclude=_COMMON_PUBLIC_PORTS,
|
||||
),
|
||||
HostRule(
|
||||
sid=100068,
|
||||
msg="Interpreter opened a listener on an unusual local port",
|
||||
severity=Severity.HIGH,
|
||||
classtype="suspicious-listener",
|
||||
events=frozenset({"listen"}),
|
||||
comm=_INTERPRETERS,
|
||||
local_port_exclude=_COMMON_PUBLIC_PORTS,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue