mirror of
https://github.com/chainguard-dev/osquery-defense-kit
synced 2024-12-13 09:34:34 +00:00
48 lines
1.3 KiB
SQL
48 lines
1.3 KiB
SQL
-- Designed for execution every 30 seconds (where the parent may still be around)
|
|
--
|
|
-- interval: 30
|
|
SELECT
|
|
p.pid AS child_pid,
|
|
p.path AS child_path,
|
|
REGEX_MATCH (RTRIM(file.path, '/'), '.*/(.*?)$', 1) AS child_name,
|
|
p.cmdline AS child_cmdline,
|
|
p.euid AS child_euid,
|
|
file.mode AS child_mode,
|
|
hash.sha256 AS child_hash,
|
|
p.parent AS parent_pid,
|
|
pp.path AS parent_path,
|
|
pp.name AS parent_name,
|
|
pp.cmdline AS parent_cmdline,
|
|
pp.euid AS parent_euid,
|
|
pfile.mode AS parent_mode,
|
|
hash.sha256 AS parent_hash
|
|
FROM
|
|
process_events p
|
|
JOIN processes pp ON p.parent = pp.pid
|
|
LEFT JOIN file ON p.path = file.path
|
|
LEFT JOIN hash ON p.path = hash.path
|
|
LEFT JOIN file AS pfile ON pp.path = file.path
|
|
LEFT JOIN hash AS phash ON pp.path = hash.path
|
|
WHERE
|
|
p.time > (strftime('%s', 'now') -30)
|
|
AND p.euid < pp.euid
|
|
AND p.path NOT IN (
|
|
'/usr/bin/fusermount',
|
|
'/usr/bin/fusermount3',
|
|
'/usr/bin/login',
|
|
'/usr/bin/sudo',
|
|
'/usr/bin/doas',
|
|
'/bin/ps',
|
|
'/usr/bin/top'
|
|
)
|
|
AND p.path NOT LIKE '/nix/store/%/bin/sudo'
|
|
AND p.path NOT LIKE '/nix/store/%/bin/dhcpcd'
|
|
AND NOT (
|
|
child_name = 'polkit-agent-helper-1'
|
|
AND parent_path = '/usr/bin/gnome-shell'
|
|
)
|
|
AND NOT (
|
|
child_name = 'fusermount3'
|
|
AND parent_path = '/usr/lib/xdg-document-portal'
|
|
)
|