2023-01-03 13:50:19 +00:00
|
|
|
-- Unexpected process that spawns shell processes (event based)
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
|
|
|
-- false positives:
|
|
|
|
-- * IDE's
|
|
|
|
--
|
2022-10-19 20:56:32 +00:00
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1059/ (Command and Scripting Interpreter)
|
|
|
|
-- * https://attack.mitre.org/techniques/T1204/002/ (User Execution: Malicious File)
|
|
|
|
--
|
2023-01-03 13:50:19 +00:00
|
|
|
-- tags: process events
|
|
|
|
-- interval: 60
|
2022-10-14 18:19:13 +00:00
|
|
|
-- platform: posix
|
2022-09-24 15:12:23 +00:00
|
|
|
SELECT
|
2023-05-23 15:31:37 +00:00
|
|
|
-- Child
|
|
|
|
p0.pid AS p0_pid,
|
|
|
|
p0.path AS p0_path,
|
|
|
|
p0.name AS p0_name,
|
|
|
|
p0.start_time AS p0_start,
|
|
|
|
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.start_time AS p1_start,
|
|
|
|
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.start_time AS p2_start,
|
|
|
|
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-05-23 15:31:37 +00:00
|
|
|
processes p0
|
|
|
|
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
|
2023-05-23 15:31:37 +00:00
|
|
|
p0.name IN ('sh', 'fish', 'zsh', 'bash', 'dash')
|
2022-09-29 19:42:27 +00:00
|
|
|
-- Ignore partial table joins
|
2023-05-23 15:31:37 +00:00
|
|
|
AND p1_path != ''
|
2022-10-17 23:01:16 +00:00
|
|
|
-- Editors & terminals mostly.
|
|
|
|
-- I know it's tempting to list "electron" here but please find a more specific exclusion.
|
2023-05-23 15:31:37 +00:00
|
|
|
AND p1.name NOT IN (
|
2023-10-02 15:35:11 +00:00
|
|
|
'Alfred',
|
|
|
|
'Code - Insiders Helper (Renderer)',
|
|
|
|
'Code - Insiders Helper',
|
|
|
|
'Code Helper (Renderer)',
|
|
|
|
'Core Sync',
|
|
|
|
'Docker Desktop',
|
|
|
|
'FinderSyncExtension',
|
|
|
|
'GoogleSoftwareUpdateAgent',
|
|
|
|
'LogiTune',
|
|
|
|
'OpenLens',
|
|
|
|
'PK-Backend',
|
|
|
|
'Rancher Desktop',
|
|
|
|
'Runner.Listener',
|
|
|
|
'Runner.Worker',
|
2023-05-02 19:25:36 +00:00
|
|
|
'abrt-action-per',
|
2022-10-13 18:59:32 +00:00
|
|
|
'abrt-handle-eve',
|
|
|
|
'alacritty',
|
2023-05-02 19:25:36 +00:00
|
|
|
'anacron',
|
2023-10-02 15:35:11 +00:00
|
|
|
'auditd',
|
2022-10-13 18:59:32 +00:00
|
|
|
'bash',
|
|
|
|
'build-script-build',
|
2023-10-02 15:35:11 +00:00
|
|
|
'buildkit-runc',
|
2022-10-17 21:31:47 +00:00
|
|
|
'chezmoi',
|
2022-10-13 18:59:32 +00:00
|
|
|
'clang-11',
|
2022-12-19 23:06:06 +00:00
|
|
|
'code',
|
2022-10-13 18:59:32 +00:00
|
|
|
'collect2',
|
2023-01-09 15:46:30 +00:00
|
|
|
'configure',
|
2022-10-13 18:59:32 +00:00
|
|
|
'conmon',
|
|
|
|
'containerd-shim',
|
|
|
|
'dash',
|
|
|
|
'demoit',
|
|
|
|
'direnv',
|
2023-01-09 15:46:30 +00:00
|
|
|
'dnf',
|
2023-02-15 01:16:02 +00:00
|
|
|
'dnf-automatic',
|
2022-10-17 21:31:47 +00:00
|
|
|
'doas',
|
2023-02-15 01:16:02 +00:00
|
|
|
'dumb-init',
|
2022-12-16 22:37:32 +00:00
|
|
|
'erl_child_setup',
|
2022-10-13 18:59:32 +00:00
|
|
|
'find',
|
|
|
|
'fish',
|
2023-01-24 01:33:52 +00:00
|
|
|
'gephi',
|
2023-01-03 13:50:19 +00:00
|
|
|
'git',
|
2023-10-02 15:35:11 +00:00
|
|
|
'git-remote-http',
|
2023-01-24 01:33:52 +00:00
|
|
|
'git-remote-https',
|
2023-02-15 01:16:02 +00:00
|
|
|
'gnome-session-b',
|
2023-01-24 01:33:52 +00:00
|
|
|
'gnome-shell',
|
2022-10-13 18:59:32 +00:00
|
|
|
'go',
|
|
|
|
'goland',
|
2022-10-17 21:31:47 +00:00
|
|
|
'helm',
|
2022-11-28 21:06:07 +00:00
|
|
|
'i3bar',
|
2022-11-16 16:18:45 +00:00
|
|
|
'i3blocks',
|
2023-05-02 19:25:36 +00:00
|
|
|
'inittool2',
|
2022-10-13 18:59:32 +00:00
|
|
|
'java',
|
2023-01-24 01:33:52 +00:00
|
|
|
'jetbrains_client',
|
2022-12-15 15:20:16 +00:00
|
|
|
'kitty',
|
2022-10-13 18:59:32 +00:00
|
|
|
'ko',
|
2023-10-02 15:35:11 +00:00
|
|
|
'konsole',
|
2022-10-13 18:59:32 +00:00
|
|
|
'kubectl',
|
2023-01-24 01:33:52 +00:00
|
|
|
'kue',
|
2022-10-27 20:55:00 +00:00
|
|
|
'lightdm',
|
2023-10-02 15:35:11 +00:00
|
|
|
'logrotate',
|
2022-10-13 18:59:32 +00:00
|
|
|
'make',
|
|
|
|
'monorail',
|
2022-12-19 23:06:06 +00:00
|
|
|
'ninja',
|
2022-10-13 18:59:32 +00:00
|
|
|
'nix',
|
|
|
|
'nix-build',
|
2022-10-17 21:31:47 +00:00
|
|
|
'nix-daemon',
|
2022-10-13 18:59:32 +00:00
|
|
|
'node',
|
2023-10-02 15:35:11 +00:00
|
|
|
'nu',
|
2022-10-13 18:59:32 +00:00
|
|
|
'nvim',
|
2022-10-17 21:31:47 +00:00
|
|
|
'package_script_service',
|
2023-02-15 01:16:02 +00:00
|
|
|
'pacman',
|
2022-10-13 18:59:32 +00:00
|
|
|
'perl',
|
2023-01-24 01:33:52 +00:00
|
|
|
'pia-daemon',
|
2023-02-15 01:16:02 +00:00
|
|
|
'provisio',
|
2023-10-02 15:35:11 +00:00
|
|
|
'qcalc',
|
2022-10-13 18:59:32 +00:00
|
|
|
'roxterm',
|
2023-01-24 01:33:52 +00:00
|
|
|
'rpmbuild',
|
2022-11-28 21:06:07 +00:00
|
|
|
'sdk',
|
2022-10-13 18:59:32 +00:00
|
|
|
'sdzoomplugin',
|
|
|
|
'sh',
|
|
|
|
'skhd',
|
2023-02-15 01:16:02 +00:00
|
|
|
'ssh',
|
2022-10-17 21:31:47 +00:00
|
|
|
'sshd',
|
2023-02-15 01:16:02 +00:00
|
|
|
'steam_osx',
|
2022-10-13 18:59:32 +00:00
|
|
|
'swift',
|
|
|
|
'systemd',
|
|
|
|
'terminator',
|
|
|
|
'test2json',
|
2023-07-19 19:22:43 +00:00
|
|
|
'timeout',
|
2022-10-13 18:59:32 +00:00
|
|
|
'tmux',
|
2022-10-17 21:31:47 +00:00
|
|
|
'tmux:server',
|
2023-01-24 01:33:52 +00:00
|
|
|
'update-notifier',
|
2022-10-13 18:59:32 +00:00
|
|
|
'vi',
|
|
|
|
'vim',
|
|
|
|
'watch',
|
|
|
|
'wezterm-gui',
|
|
|
|
'xargs',
|
|
|
|
'xcrun',
|
2023-06-07 12:58:02 +00:00
|
|
|
'xfce4-session',
|
2023-10-02 15:35:11 +00:00
|
|
|
'xfce4-terminal',
|
2022-10-13 18:59:32 +00:00
|
|
|
'yum',
|
2022-10-29 18:11:33 +00:00
|
|
|
'zellij',
|
2022-10-13 18:59:32 +00:00
|
|
|
'zsh'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2023-05-23 15:31:37 +00:00
|
|
|
AND p1_path NOT IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'/Applications/Docker.app/Contents/MacOS/Docker',
|
2023-01-06 15:36:48 +00:00
|
|
|
'/Applications/Docker.app/Contents/MacOS/install',
|
2023-10-02 20:11:44 +00:00
|
|
|
'/Applications/Hyper.app/Contents/MacOS/Hyper',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/Applications/Docker.app/Contents/Resources/bin/com.docker.cli',
|
2022-12-19 23:06:06 +00:00
|
|
|
'/Applications/Docker.app/Contents/Resources/bin/docker-credential-desktop',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea',
|
2023-05-02 19:25:36 +00:00
|
|
|
'/Applications/Alfred 5.app/Contents/Preferences/Alfred Preferences.app/Contents/MacOS/Alfred Preferences',
|
2023-02-09 01:06:26 +00:00
|
|
|
'/Applications/Parallels Desktop.app/Contents/MacOS/Parallels Service',
|
2023-02-17 16:57:23 +00:00
|
|
|
'/Applications/Parallels Desktop.app/Contents/MacOS/prl_update_helper',
|
2023-03-21 18:07:06 +00:00
|
|
|
'/Applications/RStudio.app/Contents/Resources/app/bin/rsession-arm64',
|
2023-03-28 20:25:26 +00:00
|
|
|
'/Applications/Amazon Photos.app/Contents/MacOS/Amazon Photos',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/bin/dash',
|
2023-09-14 21:13:12 +00:00
|
|
|
'/usr/bin/networksetup',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/bin/sh',
|
2023-05-23 15:31:37 +00:00
|
|
|
'/usr/local/qualys/cloud-agent/bin/qualys-cloud-agent',
|
2023-03-21 18:07:06 +00:00
|
|
|
'/Library/Application Support/Logitech.localized/LogiOptionsPlus/logioptionsplus_agent.app/Contents/MacOS/logioptionsplus_agent',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/Library/Developer/CommandLineTools/usr/bin/git',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Helpers/GoogleSoftwareUpdateDaemon',
|
2023-03-21 18:07:06 +00:00
|
|
|
'/Library/Kandji/Kandji Agent.app/Contents/MacOS/kandji-library-manager',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/opt/X11/libexec/launchd_startx',
|
|
|
|
'/sbin/launchd',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/System/Library/Frameworks/Security.framework/authtrampoline',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/bin/alacritty',
|
2023-03-14 23:00:44 +00:00
|
|
|
'/usr/bin/apt',
|
2023-03-21 18:07:06 +00:00
|
|
|
'/usr/bin/apt-get',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/bin/bash',
|
|
|
|
'/usr/bin/bwrap',
|
|
|
|
'/usr/bin/crond',
|
2023-03-21 18:07:06 +00:00
|
|
|
'/usr/bin/dash',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/usr/bin/dirname',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/bin/login',
|
|
|
|
'/usr/bin/man',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/usr/bin/su',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/bin/sudo',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/usr/bin/sysdiagnose',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/bin/xargs',
|
|
|
|
'/usr/bin/zsh',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/usr/libexec/gdm-x-session',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/usr/libexec/gnome-terminal-server',
|
|
|
|
'/usr/libexec/periodic-wrapper',
|
2023-01-24 01:33:52 +00:00
|
|
|
'/usr/lib/xorg/Xorg'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2023-05-23 15:31:37 +00:00
|
|
|
AND NOT p0.cmdline IN (
|
2023-02-14 13:33:05 +00:00
|
|
|
-- npm run server
|
2022-10-13 18:59:32 +00:00
|
|
|
'sh -c -- exec-bin node_modules/.bin/hugo/hugo server',
|
2023-06-30 20:38:31 +00:00
|
|
|
'sh -c /usr/bin/defaults write us.zoom.xos NSQuitAlwaysKeepsWindows -bool false',
|
2023-03-03 12:24:42 +00:00
|
|
|
'/bin/sh -c ioreg -rd1 -c IOPlatformExpertDevice',
|
2023-09-20 13:30:46 +00:00
|
|
|
'/usr/bin/python3 /usr/bin/terminator',
|
2023-05-23 15:31:37 +00:00
|
|
|
'/bin/sh -c sysctl hw.model kern.osrelease',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/bin/sh /etc/security/audit_warn soft /var/audit',
|
2023-06-14 14:58:41 +00:00
|
|
|
'sh -c hugo-installer --version otherDependencies.hugo --extended --destination node_modules/.bin/hugo',
|
2023-05-02 19:25:36 +00:00
|
|
|
'/bin/bash -c ioreg -l -w 0 | grep SecureInput',
|
2023-02-15 01:16:02 +00:00
|
|
|
"sh -c acpi -b | grep -v 'unavailable'",
|
2023-02-14 13:33:05 +00:00
|
|
|
'sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null',
|
|
|
|
-- Brother printer
|
|
|
|
'sh -c ps -xcocommand,pid | grep "LOGINserver"'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
|
|
|
AND NOT (
|
2023-05-23 15:31:37 +00:00
|
|
|
p1.name = 'sshd'
|
|
|
|
AND p0.cmdline LIKE '%askpass%'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2023-01-13 19:10:43 +00:00
|
|
|
AND NOT (
|
2023-05-23 15:31:37 +00:00
|
|
|
p1.name = 'steam'
|
|
|
|
AND p0.cmdline LIKE 'sh -c %steamwebhelper.sh%'
|
2023-01-13 19:10:43 +00:00
|
|
|
)
|
2022-09-27 15:54:17 +00:00
|
|
|
AND NOT (
|
2023-05-23 15:31:37 +00:00
|
|
|
p1.name = 'bash'
|
|
|
|
AND p0.cmdline LIKE 'sh -s _hostname %'
|
2022-09-27 15:54:17 +00:00
|
|
|
)
|
2022-10-03 20:27:56 +00:00
|
|
|
AND NOT (
|
2023-05-23 15:31:37 +00:00
|
|
|
p1.cmdline LIKE 'perl%/help2man%'
|
|
|
|
AND p0.cmdline LIKE 'sh -c man/%'
|
2022-10-03 20:27:56 +00:00
|
|
|
)
|
2023-05-23 15:31:37 +00:00
|
|
|
AND NOT p0.cmdline LIKE '/bin/sh %/bin/docker-credential-gcloud get'
|
|
|
|
AND NOT p1_path LIKE '/private/var/folders/%/T/go-build%.test'
|
|
|
|
AND NOT p1_path LIKE '/private/tmp/PKInstallSandbox.%/tmp/Python/Python3.framework/Versions/%/Resources/Python.app/Contents/MacOS/Python'
|
|
|
|
AND NOT p0.cmdline LIKE '%/Library/Apple/System/Library/InstallerSandboxes%'
|
|
|
|
AND NOT p0.cmdline LIKE '%gcloud config config-helper%'
|
|
|
|
AND NOT p0.cmdline LIKE '%hugo/hugo server%'
|
|
|
|
AND NOT p1.cmdline LIKE '/Applications/Warp.app/%'
|
2023-06-14 14:58:41 +00:00
|
|
|
AND NOT p1.cmdline IN ('npm run start', 'npm install')
|
2023-05-23 15:31:37 +00:00
|
|
|
AND NOT p1.cmdline LIKE '%brew.rb%'
|
|
|
|
AND NOT p1.cmdline LIKE '%/Homebrew/build.rb%'
|
|
|
|
AND NOT p1.cmdline LIKE '%Code Helper%'
|
|
|
|
AND NOT p1.cmdline LIKE '%gcloud.py config config-helper%'
|
|
|
|
AND NOT p1.cmdline LIKE '/usr/lib/electron19/electron /usr/lib/code/out/bootstrap-fork --type=ptyHost --logsPath /home/%/.config/Code - OSS/logs/%'
|
|
|
|
AND NOT p1.name LIKE '%term%'
|
|
|
|
AND NOT p1.name LIKE '%Term%'
|
|
|
|
AND NOT p1.name LIKE 'Emacs%'
|
|
|
|
AND NOT p1.name LIKE 'terraform-provider-%'
|
|
|
|
AND NOT p1.path LIKE '/Users/%/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Helpers/GoogleSoftwareUpdateAgent.app/Contents/MacOS/GoogleSoftwareUpdateAgent'
|
2022-09-24 15:12:23 +00:00
|
|
|
-- Oh, NixOS.
|
2023-05-23 15:31:37 +00:00
|
|
|
AND NOT p1.name LIKE '%/bin/bash'
|
|
|
|
AND NOT p1.name LIKE '%/bin/direnv'
|
|
|
|
AND NOT p1_path LIKE '/nix/store/%sh'
|
|
|
|
AND NOT p1_path LIKE '/opt/homebrew/%'
|
|
|
|
AND NOT p0.cgroup_path LIKE '/system.slice/docker-%'
|
|
|
|
AND NOT p0.cgroup_path LIKE '/system.slice/system.slice:docker:%'
|