2022-10-12 01:53:36 +00:00
|
|
|
-- Find root-run processes which link against libpf
|
|
|
|
--
|
2022-09-22 23:35:24 +00:00
|
|
|
-- WARNING: This check consumes an unusual amount of system memory (up to 225MB)
|
2022-10-12 01:53:36 +00:00
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1205/001/ (Traffic Signaling: Port Knocking)
|
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- platform: posix
|
2022-10-17 21:11:15 +00:00
|
|
|
-- tags: persistent state process sniffer
|
2022-09-24 15:12:23 +00:00
|
|
|
SELECT
|
|
|
|
pmm.pid,
|
|
|
|
pmm.path AS lib_path,
|
|
|
|
p.path,
|
|
|
|
p.name,
|
|
|
|
p.cmdline,
|
|
|
|
p.cwd,
|
|
|
|
p.euid,
|
|
|
|
p.parent,
|
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.name AS parent_name,
|
|
|
|
pp.cmdline AS parent_cmdline,
|
|
|
|
pp.cwd AS parent_cwd,
|
|
|
|
pp.euid AS parent_euid,
|
|
|
|
hash.sha256 AS child_sha256,
|
|
|
|
phash.sha256 AS parent_sha256
|
2023-01-09 20:18:00 +00:00
|
|
|
-- Using processes is much faster than process_memory_map
|
2022-09-24 15:12:23 +00:00
|
|
|
FROM
|
2023-01-09 20:18:00 +00:00
|
|
|
processes p
|
|
|
|
LEFT JOIN process_memory_map pmm ON p.pid = pmm.pid
|
2022-09-24 15:12:23 +00:00
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
|
|
|
LEFT JOIN hash AS phash ON pp.path = phash.path
|
|
|
|
WHERE
|
2023-01-09 20:18:00 +00:00
|
|
|
p.euid = 0
|
|
|
|
AND (
|
2022-10-13 18:59:32 +00:00
|
|
|
lib_path LIKE '%:bpf%'
|
|
|
|
OR lib_path LIKE '%libbpf%'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
|
|
|
AND p.path NOT IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/bin/qemu-system-x86_64',
|
|
|
|
'/usr/lib/systemd/systemd'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2022-12-15 21:51:58 +00:00
|
|
|
AND p.cmdline != '/usr/bin/python3 /usr/sbin/execsnoop-bpfcc'
|
2022-10-13 18:59:32 +00:00
|
|
|
AND p.path NOT LIKE '/nix/store/%/lib/systemd/systemd'
|
2022-09-24 15:12:23 +00:00
|
|
|
GROUP BY
|
|
|
|
pmm.pid
|