osquery-defense-kit/detection/privesc/unexpected-setxid-process.sql

66 lines
2.1 KiB
MySQL
Raw Permalink Normal View History

-- Processes running that originate from setuid/setgid programs
2022-10-14 18:19:13 +00:00
--
2022-10-19 20:56:32 +00:00
-- false-positives:
-- * an unlisted setuid binary
--
-- references:
-- * https://attack.mitre.org/techniques/T1548/001/ (Setuid and Setgid)
--
-- tags: persistent state process escalation
2022-10-19 20:56:32 +00:00
-- platform: posix
SELECT
p.pid,
p.name,
p.path,
p.cmdline,
f.ctime,
p.cwd,
p.uid,
f.mode,
hash.sha256
FROM
processes p
JOIN file f ON p.path = f.path
JOIN hash ON p.path = hash.path
WHERE
f.mode NOT LIKE '0%'
AND f.path NOT IN (
'/Applications/Parallels Desktop.app/Contents/MacOS/Parallels Service',
'/Applications/VMware Fusion.app/Contents/Library/vmware-vmx',
'/bin/ps',
'/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_session_monitor',
'/Library/DropboxHelperTools/Dropbox_u501/dbkextd',
'/Library/Application Support/Google/GoogleUpdater/Current/GoogleUpdater.app/Contents/Helpers/launcher',
'/opt/1Password/1Password-BrowserSupport',
2024-08-27 22:40:43 +00:00
'/usr/lib/opt/1Password/1Password-BrowserSupport',
'/opt/1Password/1Password-KeyringHelper',
2023-05-12 20:41:17 +00:00
'/opt/google/chrome/chrome-sandbox',
'/opt/IRCCloud/chrome-sandbox',
'/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent',
'/usr/bin/doas',
'/usr/bin/crontab',
'/usr/bin/fusermount',
'/usr/bin/fusermount3',
'/usr/bin/schroot',
'/usr/bin/keybase-redirector',
'/usr/bin/login',
'/usr/bin/mount',
'/usr/bin/op',
'/opt/zoom/cef/chrome-sandbox',
'/usr/bin/ssh-agent',
'/usr/bin/su',
'/usr/bin/sudo',
'/usr/bin/top',
'/usr/lib/electron22/chrome-sandbox',
2023-05-12 20:41:17 +00:00
'/usr/lib/electron/chrome-sandbox',
'/usr/lib/polkit-1/polkit-agent-helper-1',
2023-05-12 20:41:17 +00:00
'/usr/lib/slack/chrome-sandbox',
'/usr/lib/xf86-video-intel-backlight-helper',
'/usr/lib/Xorg.wrap',
2024-10-29 13:34:42 +00:00
'/usr/sbin/traceroute',
'/usr/bin/bwrap'
2023-01-13 19:10:43 +00:00
)
AND f.path NOT LIKE '/Users/%/homebrew/Cellar/socket_vmnet/%/bin/socket_vmnet'
AND f.path NOT LIKE '/opt/homebrew/Cellar/dnsmasq/%/sbin/dnsmasq'
2023-01-14 13:19:26 +00:00
AND f.path NOT LIKE '/opt/homebrew/Cellar/socket_vmnet/%/bin/socket_vmnet'