osquery-defense-kit/detection/evasion/hidden-parent-pid.sql

32 lines
681 B
MySQL
Raw Normal View History

-- Find a process which has a parent that is not listed in the process table
--
2022-09-11 19:07:54 +00:00
-- Works well for revealing boopkit, so long as boopkit has a child process.
--
2022-10-14 18:19:13 +00:00
-- references:
-- * https://github.com/krisnova/boopkit
2022-10-19 20:56:32 +00:00
-- * https://attack.mitre.org/techniques/T1014/ (Rootkit)
2022-10-14 18:19:13 +00:00
--
-- false positives:
-- * None observed
--
-- tags: persistent daemon
SELECT
p.*,
hash.sha256,
GROUP_CONCAT(DISTINCT pof.path) AS open_files
FROM
processes p
LEFT JOIN hash ON p.path = hash.path
LEFT JOIN process_open_files pof ON p.pid = pof.pid
WHERE
p.parent NOT IN (
SELECT
pid
FROM
processes
)
AND p.parent != 0
AND p.parent IS NOT NULL
GROUP BY
p.pid