2022-10-14 18:19:13 +00:00
|
|
|
-- Processes that do not exist on disk, running in osquery's namespace
|
2022-10-13 18:59:32 +00:00
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- false positives:
|
|
|
|
-- * none observed
|
|
|
|
--
|
2022-10-19 20:56:32 +00:00
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1070/004/ (Indicator Removal on Host: File Deletion)
|
|
|
|
--
|
2022-10-14 18:26:49 +00:00
|
|
|
-- tags: persistent process state
|
2022-10-14 13:36:28 +00:00
|
|
|
-- platform: linux
|
2022-09-24 15:07:34 +00:00
|
|
|
SELECT
|
|
|
|
p.pid,
|
2022-10-14 13:36:28 +00:00
|
|
|
p.euid,
|
2022-09-24 15:07:34 +00:00
|
|
|
p.cmdline,
|
|
|
|
p.path,
|
2022-11-23 12:10:03 +00:00
|
|
|
p.cgroup_path,
|
2022-09-24 15:07:34 +00:00
|
|
|
mnt_namespace,
|
|
|
|
p.cwd,
|
|
|
|
p.on_disk,
|
|
|
|
p.state,
|
2022-10-03 20:46:37 +00:00
|
|
|
file.inode,
|
2022-09-24 15:07:34 +00:00
|
|
|
pp.on_disk AS parent_on_disk,
|
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.cmdline AS parent_cmdline,
|
|
|
|
pp.cwd AS parent_cwd,
|
|
|
|
ph.sha256 AS parent_sha256
|
|
|
|
FROM
|
|
|
|
processes p
|
2022-10-03 20:46:37 +00:00
|
|
|
LEFT JOIN file ON p.path = file.path
|
2022-09-24 15:07:34 +00:00
|
|
|
LEFT JOIN process_namespaces ON p.pid = process_namespaces.pid
|
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN hash ph ON pp.path = ph.path
|
|
|
|
WHERE
|
|
|
|
p.on_disk != 1
|
2022-10-13 18:59:32 +00:00
|
|
|
AND p.path != ''
|
2022-09-24 15:07:34 +00:00
|
|
|
-- use osquery as the reference mount namespace
|
|
|
|
AND mnt_namespace IN (
|
|
|
|
SELECT DISTINCT
|
|
|
|
(mnt_namespace)
|
|
|
|
FROM
|
|
|
|
process_namespaces
|
|
|
|
JOIN processes ON processes.pid = process_namespaces.pid
|
|
|
|
WHERE
|
2022-10-13 18:59:32 +00:00
|
|
|
processes.name IN ('osqueryi', 'osqueryd')
|
2022-09-24 15:07:34 +00:00
|
|
|
)
|
2022-10-03 20:46:37 +00:00
|
|
|
-- This is truly a missing program, not just one that has been updated with a new binary.
|
2022-10-12 01:53:36 +00:00
|
|
|
AND file.inode IS NULL
|
2023-04-17 20:20:35 +00:00
|
|
|
AND p.path != '/bpfilter_umh'
|
2022-10-12 01:53:36 +00:00
|
|
|
-- Snap packages?
|
2022-10-13 18:59:32 +00:00
|
|
|
AND p.path NOT LIKE '/tmp/.mount_%'
|
2023-03-14 23:00:44 +00:00
|
|
|
AND p.path NOT LIKE '/home/%/.cache/yay/1password-cli/pkg/1password-cli/usr/bin/op'
|
2024-10-22 20:12:21 +00:00
|
|
|
-- Probably just an upgrade
|
|
|
|
AND p.path NOT LIKE '/usr/bin/%'
|
|
|
|
AND p.path NOT LIKE '/opt/%'
|