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
|
|
|
|
p.name AS child_name,
|
2022-09-24 15:12:23 +00:00
|
|
|
p.pid AS child_pid,
|
|
|
|
p.path AS child_path,
|
|
|
|
p.cmdline AS child_cmd,
|
2022-10-14 13:36:28 +00:00
|
|
|
p.euid AS child_euid,
|
2022-09-24 15:12:23 +00:00
|
|
|
p.gid AS child_gid,
|
2022-11-23 12:10:03 +00:00
|
|
|
p.cgroup_path AS child_cgroup,
|
2022-09-30 15:14:20 +00:00
|
|
|
hash.path,
|
2022-09-24 15:12:23 +00:00
|
|
|
p.on_disk AS child_on_disk,
|
|
|
|
pp.pid AS parent_pid,
|
|
|
|
pp.name AS parent_name,
|
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.cmdline AS cmd,
|
|
|
|
pp.on_disk AS parent_on_disk,
|
2022-11-23 12:10:03 +00:00
|
|
|
pp.cgroup_path AS parent_cgroup,
|
2022-09-24 15:12:23 +00:00
|
|
|
pp.uid AS parent_uid,
|
|
|
|
pp.gid AS parent_gid
|
2022-10-12 01:53:36 +00:00
|
|
|
FROM
|
|
|
|
processes p
|
2022-09-24 15:12:23 +00:00
|
|
|
JOIN processes pp ON pp.pid = p.parent
|
2022-09-30 15:14:20 +00:00
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
2022-10-12 01:53:36 +00:00
|
|
|
WHERE
|
|
|
|
parent_on_disk != 1
|
2022-09-24 15:12:23 +00:00
|
|
|
AND child_on_disk = 1
|
|
|
|
AND NOT child_pid IN (1, 2)
|
|
|
|
AND NOT parent_pid IN (1, 2) -- launchd, kthreadd
|
|
|
|
AND NOT parent_path IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'/opt/google/chrome/chrome',
|
2023-01-03 13:50:19 +00:00
|
|
|
'/usr/bin/alacritty',
|
2022-10-25 15:39:51 +00:00
|
|
|
'/usr/bin/dockerd',
|
2023-01-04 16:03:38 +00:00
|
|
|
'/usr/bin/fusermount3',
|
2023-01-19 16:52:31 +00:00
|
|
|
'/usr/bin/osqueryd',
|
2023-01-18 19:10:33 +00:00
|
|
|
'/usr/bin/yay',
|
2023-01-23 13:13:04 +00:00
|
|
|
'/usr/bin/sudo',
|
2023-01-18 19:10:33 +00:00
|
|
|
'/usr/bin/doas',
|
2023-01-04 16:03:38 +00:00
|
|
|
'/usr/bin/gnome-shell',
|
|
|
|
'/usr/lib/systemd/systemd'
|
2022-09-29 20:19:30 +00:00
|
|
|
) -- long-running launchers
|
|
|
|
AND NOT parent_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 (
|
|
|
|
parent_path LIKE '/app/%'
|
|
|
|
AND child_cgroup LIKE '/user.slice/user-1000.slice/user@1000.service/app.slice/%'
|
|
|
|
)
|
2022-12-20 12:52:04 +00:00
|
|
|
AND child_cgroup NOT LIKE '/system.slice/docker-%'
|
2022-12-19 23:06:06 +00:00
|
|
|
AND parent_cgroup NOT LIKE '/system.slice/docker-%'
|
|
|
|
AND parent_cgroup NOT LIKE '/user.slice/user-1000.slice/user@1000.service/user.slice/nerdctl-%'
|
2022-10-13 18:59:32 +00:00
|
|
|
AND parent_path NOT LIKE '/opt/homebrew/Cellar/%'
|
2022-11-16 15:39:21 +00:00
|
|
|
AND parent_path NOT LIKE '/tmp/.mount_%/%'
|
2022-11-17 12:20:19 +00:00
|
|
|
AND parent_path NOT LIKE '%google-cloud-sdk/.install/.backup%'
|
2022-09-30 15:14:20 +00:00
|
|
|
AND NOT (
|
2022-10-13 18:59:32 +00:00
|
|
|
parent_name LIKE 'kworker/%+events_unbound'
|
|
|
|
AND child_name IN ('modprobe')
|
2022-10-12 01:53:36 +00:00
|
|
|
)
|