2022-10-19 20:56:32 +00:00
|
|
|
-- A program where the parent PID is not on disk
|
|
|
|
--
|
2022-09-11 19:07:54 +00:00
|
|
|
-- Reveals boopkit if a child is spawned
|
2022-09-29 20:19:30 +00:00
|
|
|
-- TODO: Make mount namespace aware
|
2022-10-19 20:56:32 +00:00
|
|
|
--
|
|
|
|
-- false positives:
|
|
|
|
-- * none observed
|
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1070/004/ (Indicator Removal on Host: File Deletion)
|
|
|
|
--
|
|
|
|
-- false positives:
|
|
|
|
-- * none observed
|
|
|
|
--
|
2022-10-14 18:26:49 +00:00
|
|
|
-- tags: persistent daemon
|
2022-10-12 01:53:36 +00:00
|
|
|
SELECT
|
2023-02-01 18:55:55 +00:00
|
|
|
-- Child
|
2023-02-09 22:01:29 +00:00
|
|
|
p0.pid AS p0_pid,
|
2023-02-01 18:55:55 +00:00
|
|
|
p0.path AS p0_path,
|
|
|
|
p0.name AS p0_name,
|
|
|
|
p0.cmdline AS p0_cmd,
|
|
|
|
p0.cwd AS p0_cwd,
|
|
|
|
p0.cgroup_path AS p0_cgroup,
|
|
|
|
p0.euid AS p0_euid,
|
|
|
|
p0_hash.sha256 AS p0_sha256,
|
|
|
|
-- Parent
|
|
|
|
p0.parent AS p1_pid,
|
2023-03-14 20:05:16 +00:00
|
|
|
p1.cgroup_path AS p1_cgroup,
|
2023-02-01 18:55:55 +00:00
|
|
|
p1.path AS p1_path,
|
|
|
|
p1.name AS p1_name,
|
|
|
|
p1.cmdline AS p1_cmd,
|
|
|
|
p1_hash.sha256 AS p1_sha256,
|
|
|
|
-- Grandparent
|
|
|
|
p1.parent AS p2_pid,
|
|
|
|
p2.name AS p2_name,
|
|
|
|
p2.path AS p2_path,
|
|
|
|
p2.cmdline AS p2_cmd,
|
|
|
|
p2_hash.sha256 AS p2_sha256
|
2022-10-12 01:53:36 +00:00
|
|
|
FROM
|
2023-02-01 18:55:55 +00:00
|
|
|
processes p0
|
|
|
|
LEFT JOIN hash p0_hash ON p0.path = p0_hash.path
|
|
|
|
LEFT JOIN processes p1 ON p0.parent = p1.pid
|
|
|
|
LEFT JOIN hash p1_hash ON p1.path = p1_hash.path
|
|
|
|
LEFT JOIN processes p2 ON p1.parent = p2.pid
|
|
|
|
LEFT JOIN hash p2_hash ON p2.path = p2_hash.path
|
2022-10-12 01:53:36 +00:00
|
|
|
WHERE
|
2023-02-01 18:55:55 +00:00
|
|
|
p1.on_disk != 1
|
|
|
|
AND p0.on_disk = 1
|
|
|
|
AND NOT p0.pid IN (1, 2)
|
|
|
|
AND NOT p1.pid IN (1, 2) -- launchd, kthreadd
|
|
|
|
AND NOT p1.path IN (
|
2023-05-03 20:28:00 +00:00
|
|
|
'/opt/brave.com/brave/brave',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/opt/google/chrome/chrome',
|
2023-01-03 13:50:19 +00:00
|
|
|
'/usr/bin/alacritty',
|
2023-01-30 19:58:47 +00:00
|
|
|
'/usr/bin/doas',
|
2022-10-25 15:39:51 +00:00
|
|
|
'/usr/bin/dockerd',
|
2023-01-04 16:03:38 +00:00
|
|
|
'/usr/bin/fusermount3',
|
2023-01-30 19:58:47 +00:00
|
|
|
'/usr/bin/gnome-shell',
|
2023-05-03 20:28:00 +00:00
|
|
|
'/usr/bin/ibus-daemon',
|
2023-04-17 20:20:35 +00:00
|
|
|
'/usr/bin/kitty',
|
2023-01-19 16:52:31 +00:00
|
|
|
'/usr/bin/osqueryd',
|
2023-01-23 13:13:04 +00:00
|
|
|
'/usr/bin/sudo',
|
2023-05-03 20:28:00 +00:00
|
|
|
'/usr/bin/tmux',
|
2023-01-30 19:58:47 +00:00
|
|
|
'/usr/bin/yay',
|
2023-05-03 20:28:00 +00:00
|
|
|
'/usr/libexec/gdm-wayland-session',
|
|
|
|
'/usr/libexec/gdm-x-session',
|
2023-01-30 19:58:47 +00:00
|
|
|
'/usr/libexec/gnome-terminal-server',
|
2023-01-04 16:03:38 +00:00
|
|
|
'/usr/lib/systemd/systemd'
|
2023-05-03 20:28:00 +00:00
|
|
|
'/usr/sbin/auditd',
|
|
|
|
'/usr/sbin/gdm3',
|
|
|
|
'/usr/sbin/sshd',
|
|
|
|
'/usr/share/code/code',
|
2022-09-29 20:19:30 +00:00
|
|
|
) -- long-running launchers
|
2023-02-01 18:55:55 +00:00
|
|
|
AND NOT p1.name IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'lightdm',
|
|
|
|
'nvim',
|
|
|
|
'gnome-shell',
|
2023-01-20 14:08:45 +00:00
|
|
|
'fish',
|
|
|
|
'bash',
|
2022-10-13 18:59:32 +00:00
|
|
|
'slack',
|
|
|
|
'kube-proxy',
|
|
|
|
'kubelet'
|
2022-09-29 20:19:30 +00:00
|
|
|
) -- These alerts were unfortunately useless - lots of spam on macOS
|
2022-12-15 21:51:58 +00:00
|
|
|
AND NOT (
|
2023-02-01 18:55:55 +00:00
|
|
|
p1.path LIKE '/app/%'
|
2023-03-14 20:05:16 +00:00
|
|
|
AND p1.cgroup_path LIKE '/user.slice/user-1000.slice/user@1000.service/app.slice/%'
|
2022-12-15 21:51:58 +00:00
|
|
|
)
|
2023-03-20 21:05:02 +00:00
|
|
|
AND NOT p2.name = 'bwrap'
|
2023-02-01 18:55:55 +00:00
|
|
|
AND p1.cgroup_path NOT LIKE '/system.slice/docker-%'
|
2023-03-20 21:05:02 +00:00
|
|
|
AND p1.cgroup_path != '/system.slice/docker.service'
|
2023-02-01 18:55:55 +00:00
|
|
|
AND p1.cgroup_path NOT LIKE '/user.slice/user-1000.slice/user@1000.service/user.slice/nerdctl-%'
|
2023-03-14 20:05:16 +00:00
|
|
|
AND p1.cgroup_path NOT LIKE '/user.slice/user-1000.slice/user@1000.service/user.slice/libpod-%'
|
2023-02-01 18:55:55 +00:00
|
|
|
AND p1.path NOT LIKE '/opt/homebrew/Cellar/%'
|
|
|
|
AND p1.path NOT LIKE '/tmp/.mount_%/%'
|
|
|
|
AND p1.path NOT LIKE '%google-cloud-sdk/.install/.backup%'
|
2022-09-30 15:14:20 +00:00
|
|
|
AND NOT (
|
2023-02-01 18:55:55 +00:00
|
|
|
p1.name LIKE 'kworker/%+events_unbound'
|
|
|
|
AND p0.name IN ('modprobe')
|
2022-10-12 01:53:36 +00:00
|
|
|
)
|