2022-10-19 20:56:32 +00:00
|
|
|
-- Find processes that run with a lower effective UID than their parent (state-based)
|
2022-10-07 16:46:55 +00:00
|
|
|
--
|
2022-10-19 20:56:32 +00:00
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1548/001/ (Setuid and Setgid)
|
|
|
|
-- * https://cybersecurity.att.com/blogs/labs-research/shikitega-new-stealthy-malware-targeting-linux
|
|
|
|
--
|
|
|
|
-- related:
|
2022-10-07 16:46:55 +00:00
|
|
|
-- * unexpected-privilege-escalation-events.sql
|
2022-10-13 18:59:32 +00:00
|
|
|
--
|
2022-10-17 12:43:29 +00:00
|
|
|
-- tags: transient rapid state process escalation
|
2022-11-08 01:36:37 +00:00
|
|
|
-- platform: darwin
|
2022-09-24 15:12:23 +00:00
|
|
|
SELECT
|
|
|
|
p.pid AS child_pid,
|
|
|
|
p.path AS child_path,
|
|
|
|
p.name AS child_name,
|
|
|
|
p.cmdline AS child_cmdline,
|
|
|
|
p.euid AS child_euid,
|
|
|
|
p.state AS child_state,
|
|
|
|
file.mode AS child_mode,
|
|
|
|
hash.sha256 AS child_hash,
|
|
|
|
p.parent AS parent_pid,
|
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.name AS parent_name,
|
|
|
|
pp.cmdline AS parent_cmdline,
|
|
|
|
pp.euid AS parent_euid,
|
|
|
|
pfile.mode AS parent_mode,
|
2022-11-08 01:36:37 +00:00
|
|
|
phash.sha256 AS parent_hash
|
2022-09-24 15:12:23 +00:00
|
|
|
FROM
|
|
|
|
processes p
|
|
|
|
JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN file ON p.path = file.path
|
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
2022-10-21 21:38:29 +00:00
|
|
|
LEFT JOIN file AS pfile ON pp.path = pfile.path
|
|
|
|
LEFT JOIN hash AS phash ON pp.path = phash.path
|
2022-09-24 15:12:23 +00:00
|
|
|
WHERE
|
2022-11-08 01:36:37 +00:00
|
|
|
p.euid < p.uid
|
2022-09-24 15:12:23 +00:00
|
|
|
AND p.path NOT IN (
|
2022-11-16 21:52:39 +00:00
|
|
|
'/bin/ps',
|
|
|
|
'/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_session_monitor',
|
2022-11-08 01:36:37 +00:00
|
|
|
'/Library/DropboxHelperTools/Dropbox_u501/dbkextd',
|
2022-09-24 15:12:23 +00:00
|
|
|
'/usr/bin/login',
|
2022-11-03 15:51:54 +00:00
|
|
|
'/usr/bin/su',
|
2022-09-24 15:12:23 +00:00
|
|
|
'/usr/bin/sudo',
|
2022-11-16 21:52:39 +00:00
|
|
|
'/usr/bin/top',
|
|
|
|
'/usr/local/bin/doas'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|