2022-09-30 16:10:18 +00:00
|
|
|
-- Find processes running that are tied to binaries with unsual permissions. Namely, 0777.
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1222/
|
|
|
|
--
|
|
|
|
-- false positives:
|
|
|
|
-- * poorly written software
|
|
|
|
--
|
|
|
|
-- platform: posix
|
|
|
|
-- tags: persistent filesystem state
|
2022-09-24 15:12:23 +00:00
|
|
|
SELECT
|
2023-02-24 21:30:17 +00:00
|
|
|
f.mode,
|
|
|
|
f.uid,
|
|
|
|
f.gid,
|
|
|
|
f.ctime,
|
2023-02-09 01:06:26 +00:00
|
|
|
-- Child
|
|
|
|
p0.pid AS p0_pid,
|
|
|
|
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.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-09 01:06:26 +00:00
|
|
|
processes p0
|
|
|
|
LEFT JOIN file f ON p0.path = f.path
|
|
|
|
LEFT JOIN hash p0_hash ON p0.path = p0_hash.path
|
|
|
|
LEFT JOIN processes p1 ON p0.parent = p1.pid
|
|
|
|
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
|
|
|
|
f.mode NOT IN (
|
2022-09-14 14:51:56 +00:00
|
|
|
'0500',
|
2023-12-15 22:10:06 +00:00
|
|
|
'0551',
|
2022-09-14 14:51:56 +00:00
|
|
|
'0544',
|
2022-09-08 21:58:56 +00:00
|
|
|
'0555',
|
2022-09-14 14:51:56 +00:00
|
|
|
'0711',
|
2024-01-08 22:18:25 +00:00
|
|
|
'0750',
|
2022-09-14 14:51:56 +00:00
|
|
|
'0755',
|
2022-09-08 21:58:56 +00:00
|
|
|
'0775',
|
2023-01-09 14:04:38 +00:00
|
|
|
'0744',
|
2022-09-24 15:07:34 +00:00
|
|
|
'6755',
|
|
|
|
'0700',
|
2022-09-14 14:51:56 +00:00
|
|
|
'2755',
|
2022-09-08 21:58:56 +00:00
|
|
|
'4511',
|
2022-09-14 14:51:56 +00:00
|
|
|
'4555',
|
|
|
|
'4755'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2022-09-30 16:10:18 +00:00
|
|
|
-- Vendors who are very relaxed about permissions
|
2022-09-24 15:12:23 +00:00
|
|
|
AND NOT (
|
2022-09-30 16:10:18 +00:00
|
|
|
f.path IN (
|
2023-01-23 13:13:04 +00:00
|
|
|
'/Applications/Camera Settings.app/Contents/MacOS/LogitechCamera',
|
|
|
|
'/Applications/motionVFX/Plugins/mUtility.app/Contents/PlugIns/mUtility XPC Service.pluginkit/Contents/MacOS/mUtility XPC Service',
|
|
|
|
'/Library/Application Support/Logitech/com.logitech.vc.LogiVCCoreService/LogiVCCoreService.app/Contents/MacOS/LogiVCCoreService'
|
2022-09-30 16:10:18 +00:00
|
|
|
)
|
2022-09-24 15:12:23 +00:00
|
|
|
AND f.mode = '0777'
|
|
|
|
AND f.uid > 500
|
|
|
|
)
|
2023-07-19 19:22:43 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/Users/%/.local/bin/%'
|
|
|
|
AND f.mode = '0777'
|
|
|
|
AND f.uid > 500
|
|
|
|
)
|
2022-09-26 22:27:43 +00:00
|
|
|
AND NOT (
|
2022-10-13 18:59:32 +00:00
|
|
|
f.path LIKE '/Users/%/Library/Application Support/Code/User/globalStorage/grafana.vscode-jsonnet/bin/jsonnet-language-server'
|
2022-09-26 22:27:43 +00:00
|
|
|
AND f.mode = '0777'
|
|
|
|
AND f.uid > 500
|
|
|
|
)
|
2023-02-24 21:30:17 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/Users/%/.vscode/extensions/sumneko.lua-%-darwin-arm64/server/bin/lua-language-server'
|
|
|
|
AND f.mode = '0777'
|
|
|
|
AND f.uid > 500
|
|
|
|
)
|
2023-03-21 18:07:06 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/Users/%/Library/Application Support/Zwift/ZwiftAppMetal'
|
|
|
|
AND f.mode = '0777'
|
|
|
|
AND f.uid > 500
|
|
|
|
)
|
2022-09-26 22:27:43 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path = '/usr/bin/sudo'
|
2022-11-22 14:21:03 +00:00
|
|
|
AND f.mode = '4111'
|
2022-09-26 22:27:43 +00:00
|
|
|
AND f.uid = 0
|
|
|
|
)
|
2022-10-12 01:53:36 +00:00
|
|
|
AND NOT (
|
2022-10-13 18:59:32 +00:00
|
|
|
f.path LIKE '/home/%/.local/share/JetBrains/Toolbox/bin/jetbrains-toolbox'
|
2022-10-12 01:53:36 +00:00
|
|
|
AND f.mode = '0744'
|
|
|
|
)
|
2022-12-19 23:06:06 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/Users/%/Applications (Parallels)/%.app/Contents/MacOS/WinAppHelper'
|
|
|
|
AND f.mode = '0777'
|
|
|
|
)
|
2023-01-14 13:19:26 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/opt/homebrew/Cellar/socket_vmnet/%/bin/socket_vmnet'
|
|
|
|
AND f.mode = '1555'
|
|
|
|
)
|
2023-02-03 02:46:53 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/opt/homebrew/Cellar/dnsmasq/%/sbin/dnsmasq'
|
|
|
|
AND f.mode = '1555'
|
|
|
|
)
|
2023-02-09 01:06:26 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/Users/%/Library/Application Support/com.raycast.macos/NodeJS/runtime/%/bin/node'
|
|
|
|
AND f.mode = '0754'
|
2023-02-09 22:01:29 +00:00
|
|
|
)
|
2024-01-08 22:18:25 +00:00
|
|
|
AND NOT (
|
|
|
|
f.path LIKE '/opt/Elastic/Agent/data/elastic-agent%/elastic-agent'
|
|
|
|
AND f.mode = '0770'
|
2024-01-18 22:15:37 +00:00
|
|
|
)
|
|
|
|
AND NOT (
|
|
|
|
f.path = '/Library/Bitdefender/AVP/product/bin/EndpointSecurityforMac.app/Contents/MacOS/EndpointSecurityforMac'
|
|
|
|
AND f.mode = '0655'
|
2024-01-08 22:18:25 +00:00
|
|
|
)
|