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
|
2023-02-01 18:55:55 +00:00
|
|
|
s.authority AS p0_auth,
|
|
|
|
s.identifier AS p0_id,
|
|
|
|
-- Child
|
|
|
|
p0.path AS p0_path,
|
|
|
|
p0.name AS p0_name,
|
|
|
|
p0.cmdline AS p0_cmd,
|
|
|
|
p0.cwd AS p0_cwd,
|
|
|
|
p0.cgroup_path AS p0_cgroup,
|
|
|
|
p0.euid AS p0_euid,
|
|
|
|
p0_hash.sha256 AS p0_sha256,
|
|
|
|
-- Parent
|
|
|
|
p0.parent AS p1_pid,
|
|
|
|
p1.path AS p1_path,
|
|
|
|
p1.name AS p1_name,
|
|
|
|
p1_f.mode AS p1_mode,
|
|
|
|
p1.euid AS p1_euid,
|
|
|
|
p1.cmdline AS p1_cmd,
|
|
|
|
p1_hash.sha256 AS p1_sha256,
|
|
|
|
-- Grandparent
|
|
|
|
p1.parent AS p2_pid,
|
|
|
|
p2.name AS p2_name,
|
|
|
|
p2.path AS p2_path,
|
|
|
|
p2.cmdline AS p2_cmd,
|
|
|
|
p2_hash.sha256 AS p2_sha256
|
2022-09-24 15:12:23 +00:00
|
|
|
FROM
|
2023-02-01 18:55:55 +00:00
|
|
|
processes p0
|
|
|
|
LEFT JOIN signature s ON p0.path = s.path
|
|
|
|
LEFT JOIN hash p0_hash ON p0.path = p0_hash.path
|
|
|
|
LEFT JOIN processes p1 ON p0.parent = p1.pid
|
|
|
|
LEFT JOIN file p1_f ON p1.path = p1_f.path
|
|
|
|
LEFT JOIN hash p1_hash ON p1.path = p1_hash.path
|
|
|
|
LEFT JOIN processes p2 ON p1.parent = p2.pid
|
|
|
|
LEFT JOIN hash p2_hash ON p2.path = p2_hash.path
|
2022-09-24 15:12:23 +00:00
|
|
|
WHERE
|
2023-02-01 18:55:55 +00:00
|
|
|
p0.euid < p0.uid
|
|
|
|
AND p0.path NOT IN (
|
2022-11-22 14:21:03 +00:00
|
|
|
'',
|
2022-11-16 21:52:39 +00:00
|
|
|
'/bin/ps',
|
2023-01-27 01:40:47 +00:00
|
|
|
'/Applications/Parallels Desktop.app/Contents/MacOS/Parallels Service',
|
2022-11-16 21:52:39 +00:00
|
|
|
'/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
|
|
|
)
|