2022-10-14 18:19:13 +00:00
|
|
|
-- Find unexpected files in /dev
|
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://www.sandflysecurity.com/blog/bpfdoor-an-evasive-linux-backdoor-technical-analysis/
|
|
|
|
--
|
|
|
|
-- false positives:
|
2022-10-18 00:37:44 +00:00
|
|
|
-- * programs which have legimate uses for /dev/shm (Chrome, etc)
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
|
|
|
-- tags: persistent state filesystem
|
2022-10-20 11:59:06 +00:00
|
|
|
-- platform: posix
|
2022-10-12 01:53:36 +00:00
|
|
|
SELECT
|
|
|
|
file.path,
|
2022-09-24 15:12:23 +00:00
|
|
|
file.type,
|
2022-09-29 19:42:27 +00:00
|
|
|
file.size,
|
2022-09-24 15:12:23 +00:00
|
|
|
file.mtime,
|
|
|
|
file.uid,
|
|
|
|
file.ctime,
|
|
|
|
file.gid,
|
|
|
|
hash.sha256,
|
|
|
|
magic.data
|
2022-10-12 01:53:36 +00:00
|
|
|
FROM
|
|
|
|
file
|
2022-09-24 15:12:23 +00:00
|
|
|
LEFT JOIN hash ON file.path = hash.path
|
|
|
|
LEFT JOIN magic ON file.path = magic.path
|
2022-10-12 01:53:36 +00:00
|
|
|
WHERE
|
|
|
|
(
|
2022-10-13 18:59:32 +00:00
|
|
|
file.path LIKE '/dev/shm/%%'
|
|
|
|
OR file.path LIKE '/dev/%/.%'
|
|
|
|
OR file.path LIKE '/dev/.%'
|
|
|
|
OR file.path LIKE '/dev/.%/%'
|
|
|
|
OR file.path LIKE '/dev/%%/.%/%'
|
|
|
|
OR file.path LIKE '/dev/mqueue/%%'
|
2022-09-29 19:42:27 +00:00
|
|
|
) -- We should also use uid for making decisions here
|
|
|
|
AND NOT (
|
|
|
|
file.uid > 499
|
2023-04-17 20:20:35 +00:00
|
|
|
AND (
|
2023-03-30 22:44:01 +00:00
|
|
|
file.path LIKE '/dev/shm/.com.google.%'
|
2022-09-29 19:42:27 +00:00
|
|
|
OR file.path LIKE '/dev/shm/.org.chromium.%'
|
|
|
|
OR file.path LIKE '/dev/shm/wayland.mozilla.%'
|
2022-10-13 18:59:32 +00:00
|
|
|
OR file.path LIKE '/dev/shm/shm-%-%-%'
|
2023-03-30 22:44:01 +00:00
|
|
|
OR file.path LIKE '/dev/shm/pulse-shm-%'
|
|
|
|
OR file.path LIKE '/dev/shm/u1000-Shm%'
|
|
|
|
OR file.path LIKE '/dev/shm/u1000-Valve%'
|
2023-04-21 00:45:35 +00:00
|
|
|
OR file.path LIKE '/dev/shm/aomshm.%'
|
2022-10-13 18:59:32 +00:00
|
|
|
OR file.path LIKE '/dev/shm/jack_db%'
|
2022-09-29 19:42:27 +00:00
|
|
|
)
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2022-10-13 18:59:32 +00:00
|
|
|
AND file.path NOT LIKE '/dev/shm/lttng-ust-wait-%'
|
|
|
|
AND file.path NOT LIKE '/dev/shm/flatpak-%'
|
|
|
|
AND file.path NOT LIKE '/dev/shm/libpod_rootless_lock_%'
|
|
|
|
AND file.path NOT LIKE '%/../%'
|
|
|
|
AND file.path NOT LIKE '%/./%'
|
2022-10-12 01:53:36 +00:00
|
|
|
AND file.path NOT IN ('/dev/.mdadm/')
|