2022-11-18 14:32:00 +00:00
|
|
|
-- Find programs which spawn root children without propagating environment variables
|
2022-10-27 15:26:35 +00:00
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://www.sandflysecurity.com/blog/bpfdoor-an-evasive-linux-backdoor-technical-analysis/
|
|
|
|
--
|
2023-05-17 14:54:16 +00:00
|
|
|
-- tags: persistent state daemon process seldom disabled
|
2022-10-27 15:26:35 +00:00
|
|
|
-- platform: darwin
|
|
|
|
-- interval: 600
|
2022-11-16 16:02:29 +00:00
|
|
|
SELECT
|
|
|
|
COUNT(key) AS count,
|
2022-10-27 15:26:35 +00:00
|
|
|
p.pid,
|
|
|
|
p.path,
|
2022-11-03 15:51:54 +00:00
|
|
|
p.name,
|
|
|
|
p.euid,
|
2022-10-27 15:26:35 +00:00
|
|
|
p.on_disk,
|
|
|
|
p.parent,
|
|
|
|
p.cmdline,
|
2023-02-01 18:55:55 +00:00
|
|
|
p.cwd,
|
2022-10-27 15:26:35 +00:00
|
|
|
pp.name AS parent_name,
|
|
|
|
pp.cmdline AS parent_cmd,
|
|
|
|
signature.identifier,
|
|
|
|
signature.authority,
|
|
|
|
hash.sha256,
|
2022-11-03 15:51:54 +00:00
|
|
|
CONCAT (
|
2022-10-27 15:26:35 +00:00
|
|
|
MIN(p.euid, 500),
|
|
|
|
',',
|
|
|
|
p.name,
|
|
|
|
',',
|
|
|
|
signature.identifier,
|
|
|
|
',',
|
|
|
|
signature.authority
|
2022-11-18 14:32:00 +00:00
|
|
|
) AS exception_key
|
2022-11-16 16:02:29 +00:00
|
|
|
FROM
|
|
|
|
processes p
|
2022-10-27 15:26:35 +00:00
|
|
|
LEFT JOIN process_envs pe ON p.pid = pe.pid
|
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
|
|
|
LEFT JOIN signature ON p.path = signature.path
|
2022-11-18 14:32:00 +00:00
|
|
|
WHERE
|
2023-02-24 21:30:17 +00:00
|
|
|
p.pid IN (
|
|
|
|
SELECT
|
|
|
|
pid
|
|
|
|
FROM
|
|
|
|
processes
|
|
|
|
WHERE
|
|
|
|
euid = 0
|
|
|
|
AND start_time > (strftime('%s', 'now') - 601)
|
|
|
|
AND start_time < (strftime('%s', 'now') - 1)
|
|
|
|
AND path NOT LIKE '/System/Library/%'
|
|
|
|
AND path NOT LIKE '/opt/homebrew/Cellar/%'
|
|
|
|
)
|
2022-11-01 11:20:57 +00:00
|
|
|
AND signature.authority NOT IN (
|
2022-11-16 15:56:36 +00:00
|
|
|
'Software Signing',
|
2022-11-03 15:51:54 +00:00
|
|
|
'Apple Mac OS Application Signing',
|
2022-10-31 21:40:37 +00:00
|
|
|
'Developer ID Application: Adobe Inc. (JQ525L2MZD)',
|
|
|
|
'Developer ID Application: Brave Software, Inc. (KL8N8XSYF4)',
|
|
|
|
'Developer ID Application: Docker Inc (9BNSXJN65R)',
|
|
|
|
'Developer ID Application: GitHub (VEKTX9H2N7)',
|
|
|
|
'Developer ID Application: Google LLC (EQHXZ8M8AV)',
|
|
|
|
'Developer ID Application: JetBrains s.r.o. (2ZEFAR8TH3)',
|
2022-11-16 19:49:36 +00:00
|
|
|
'Developer ID Application: Node.js Foundation (HX7739G8FX)',
|
2022-10-31 21:40:37 +00:00
|
|
|
'Developer ID Application: Keybase, Inc. (99229SGT5K)',
|
|
|
|
'Developer ID Application: Kolide Inc (YZ3EM74M78)',
|
|
|
|
'Developer ID Application: Logitech Inc. (QED4VVPZWA)',
|
|
|
|
'Developer ID Application: Microsoft Corporation (UBF8T346G9)',
|
|
|
|
'Developer ID Application: Mozilla Corporation (43AQ936H96)',
|
|
|
|
'Developer ID Application: Objective Development Software GmbH (MLZF7K7B5R)',
|
|
|
|
'Developer ID Application: Opal Camera Inc (97Z3HJWCRT)',
|
|
|
|
'Developer ID Application: Parallels International GmbH (4C6364ACXT)',
|
|
|
|
'Developer ID Application: Yubico Limited (LQA3CS5MM7)'
|
|
|
|
)
|
2022-11-16 16:02:29 +00:00
|
|
|
GROUP BY
|
|
|
|
p.pid
|
|
|
|
HAVING
|
|
|
|
count == 0;
|