2022-10-14 18:19:13 +00:00
|
|
|
-- Applications setting environment variables to bypass security protections
|
|
|
|
--
|
2022-09-08 21:58:56 +00:00
|
|
|
-- Inpsired by BPFdoor and other intrusions
|
|
|
|
-- https://www.sandflysecurity.com/blog/compromised-linux-cheat-sheet/
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
2022-10-17 21:10:51 +00:00
|
|
|
-- WARNING: This query is known to require a higher than average wall time.
|
|
|
|
--
|
2022-10-20 18:56:16 +00:00
|
|
|
-- tags: transient state
|
2022-10-27 15:26:35 +00:00
|
|
|
-- interval: 600
|
2022-10-17 21:10:51 +00:00
|
|
|
-- platform: linux
|
2022-10-27 15:26:35 +00:00
|
|
|
SELECT key,
|
2022-09-24 15:12:23 +00:00
|
|
|
value,
|
|
|
|
p.pid,
|
|
|
|
p.path,
|
|
|
|
p.cmdline,
|
|
|
|
p.parent AS parent_pid,
|
2022-10-14 18:19:13 +00:00
|
|
|
pp.cmdline AS parent_cmd
|
2022-10-27 15:26:35 +00:00
|
|
|
-- Querying processes first and filtering by time gives a massive 20X speed improvement
|
|
|
|
-- over querying process_envs first and JOIN'ing against processes
|
|
|
|
FROM processes p
|
|
|
|
LEFT JOIN process_envs pe ON p.pid = pe.pid
|
2022-09-24 15:12:23 +00:00
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
2022-10-27 15:26:35 +00:00
|
|
|
WHERE -- This time should match the interval
|
|
|
|
p.start_time > (strftime('%s', 'now') - 600)
|
|
|
|
AND (
|
2022-09-24 15:12:23 +00:00
|
|
|
key = 'HISTFILE'
|
|
|
|
AND NOT VALUE LIKE '/home/%/.%_history'
|
|
|
|
)
|
|
|
|
OR (
|
|
|
|
key = 'LD_PRELOAD'
|
|
|
|
AND NOT p.path LIKE '%/firefox'
|
2022-10-13 18:59:32 +00:00
|
|
|
AND NOT pe.value = 'libfakeroot.so'
|
2022-09-24 15:12:23 +00:00
|
|
|
AND NOT pe.value LIKE ':/home/%/.local/share/Steam'
|
|
|
|
AND NOT pe.value LIKE ':/home/%/.var/app/com.valvesoftware.Steam/%'
|
|
|
|
AND NOT pe.value LIKE ':/snap/%'
|
|
|
|
AND NOT pe.value LIKE '/app/bin/%'
|
|
|
|
AND NOT pe.value LIKE 'libmozsandbox.so%'
|
2022-10-27 15:26:35 +00:00
|
|
|
)
|