2023-06-09 11:29:00 +00:00
|
|
|
-- Long-running programs who were recently added to disk, based on btime/ctime
|
2022-10-18 18:42:26 +00:00
|
|
|
--
|
|
|
|
-- false-positives:
|
|
|
|
-- * many
|
|
|
|
--
|
2023-06-09 11:29:00 +00:00
|
|
|
-- tags: transient process state
|
2022-10-18 18:42:26 +00:00
|
|
|
-- platform: linux
|
2022-10-19 20:19:53 +00:00
|
|
|
SELECT
|
2023-05-23 15:31:37 +00:00
|
|
|
f.ctime AS p0_ctime,
|
|
|
|
f.mtime AS p0_mtime,
|
2023-04-17 20:20:35 +00:00
|
|
|
-- Child
|
|
|
|
p0.pid AS p0_pid,
|
|
|
|
p0.path AS p0_path,
|
2023-05-17 14:54:16 +00:00
|
|
|
p0.start_time AS p0_start,
|
2023-04-17 20:20:35 +00:00
|
|
|
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,
|
2023-05-17 14:54:16 +00:00
|
|
|
p1.start_time AS p1_start,
|
2023-04-17 20:20:35 +00:00
|
|
|
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,
|
2023-05-17 14:54:16 +00:00
|
|
|
p2.start_time AS p2_start,
|
2023-04-17 20:20:35 +00:00
|
|
|
p2.name AS p2_name,
|
|
|
|
p2.path AS p2_path,
|
|
|
|
p2.cmdline AS p2_cmd,
|
|
|
|
p2_hash.sha256 AS p2_sha256
|
2022-10-19 20:19:53 +00:00
|
|
|
FROM
|
2023-04-17 20:20:35 +00:00
|
|
|
processes p0
|
2023-05-08 17:20:47 +00:00
|
|
|
LEFT JOIN file f ON p0.path = f.path
|
2023-04-17 20:20:35 +00:00
|
|
|
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-10-19 20:19:53 +00:00
|
|
|
WHERE
|
2023-04-17 20:20:35 +00:00
|
|
|
p0.start_time > 0
|
2022-11-22 14:21:03 +00:00
|
|
|
AND f.ctime > 0
|
2023-06-09 11:42:30 +00:00
|
|
|
AND p0.start_time > (strftime('%s', 'now') - 43200)
|
2024-09-23 15:07:53 +00:00
|
|
|
AND (p0.start_time - MAX(f.ctime, f.btime)) < 1200
|
2023-04-17 20:20:35 +00:00
|
|
|
AND p0.start_time >= MAX(f.ctime, f.ctime)
|
2022-10-19 20:19:53 +00:00
|
|
|
AND NOT f.directory IN ('/usr/lib/firefox', '/usr/local/kolide-k2/bin') -- Typically daemons or long-running desktop apps
|
2022-10-27 14:41:14 +00:00
|
|
|
-- These are binaries that are known to get updated and subsequently executed
|
2022-11-03 15:51:54 +00:00
|
|
|
--
|
|
|
|
-- What I would give for osquery to support binary signature verification on Linux
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT p0.path IN (
|
2022-10-18 18:42:26 +00:00
|
|
|
'',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/bin/containerd',
|
|
|
|
'/bin/containerd-shim-runc-v2',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/opt/google/chrome/chrome',
|
2022-10-24 15:08:28 +00:00
|
|
|
'/opt/google/chrome/chrome_crashpad_handler',
|
|
|
|
'/opt/google/chrome/nacl_helper',
|
2022-11-17 12:20:19 +00:00
|
|
|
'/opt/Lens/chrome_crashpad_handler',
|
|
|
|
'/opt/Lens/lens',
|
|
|
|
'/opt/sublime_text/sublime_text',
|
2022-12-02 16:20:18 +00:00
|
|
|
'/usr/lib64/electron/electron',
|
2022-11-08 01:36:37 +00:00
|
|
|
'/usr/lib64/firefox/firefox',
|
|
|
|
'/usr/lib64/google-cloud-sdk/platform/bundledpythonunix/bin/python3',
|
2022-12-19 23:06:06 +00:00
|
|
|
'/usr/lib64/thunderbird/thunderbird',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/at-spi2-registryd',
|
|
|
|
'/usr/lib/at-spi-bus-launcher',
|
2024-08-27 22:40:43 +00:00
|
|
|
'/usr/lib/cups/notifier/dbus',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/docker/cli-plugins/docker-compose',
|
|
|
|
'/usr/lib/electron25/electron',
|
|
|
|
'/usr/libexec/accounts-daemon',
|
2022-12-02 16:20:18 +00:00
|
|
|
'/usr/libexec/bluetooth/bluetoothd',
|
2022-10-24 15:08:28 +00:00
|
|
|
'/usr/libexec/docker/docker-proxy',
|
2024-08-27 22:40:43 +00:00
|
|
|
'/usr/libexec/flatpak-portal',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/libexec/flatpak-system-helper',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/libexec/fwupd/fwupd',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/libexec/gnome-shell-calendar-server',
|
|
|
|
'/usr/libexec/gstreamer-1.0/gst-plugin-scanner',
|
2023-01-20 14:29:10 +00:00
|
|
|
'/usr/libexec/ibus-dconf',
|
|
|
|
'/usr/libexec/ibus-engine-simple',
|
|
|
|
'/usr/libexec/ibus-extension-gtk3',
|
|
|
|
'/usr/libexec/ibus-portal',
|
|
|
|
'/usr/libexec/ibus-x11',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/libexec/power-profiles-daemon',
|
2022-11-03 20:05:07 +00:00
|
|
|
'/usr/libexec/snapd/snapd',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/libexec/sssd/sssd_kcm',
|
2023-01-04 16:03:38 +00:00
|
|
|
'/usr/libexec/tracker-extract-3',
|
2022-12-19 23:06:06 +00:00
|
|
|
'/usr/libexec/tracker-miner-fs-3',
|
2022-12-02 16:20:18 +00:00
|
|
|
'/usr/lib/flatpak-session-helper',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/fwupd/fwupd',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/lib/gdm',
|
|
|
|
'/usr/lib/gdm-session-worker',
|
2024-08-27 22:40:43 +00:00
|
|
|
'/usr/lib64/discord/Discord',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/lib/gdm-x-session',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/gnome-shell-calendar-server',
|
2022-11-03 20:05:07 +00:00
|
|
|
'/usr/lib/google-cloud-sdk/platform/bundledpythonunix/bin/python3',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/ibus/ibus-dconf',
|
|
|
|
'/usr/lib/ibus/ibus-engine-simple',
|
|
|
|
'/usr/lib/ibus/ibus-portal',
|
2022-11-16 16:18:45 +00:00
|
|
|
'/usr/lib/libreoffice/program/oosplash',
|
2022-11-17 12:20:19 +00:00
|
|
|
'/usr/lib/libreoffice/program/soffice.bin',
|
2024-08-27 22:40:43 +00:00
|
|
|
'/usr/lib/opt/google/chrome/chrome',
|
2022-11-17 12:20:19 +00:00
|
|
|
'/usr/lib/polkit-1/polkitd',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/slack/chrome_crashpad_handler',
|
|
|
|
'/usr/lib/slack/slack',
|
2022-11-03 20:05:07 +00:00
|
|
|
'/usr/lib/snapd/snapd',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/lib/systemd/systemd',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/systemd/systemd-homed',
|
|
|
|
'/usr/lib/systemd/systemd-hostnamed',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/systemd/systemd-journald',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/lib/systemd/systemd-logind',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/systemd/systemd-machined',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/systemd/systemd-oomd',
|
|
|
|
'/usr/lib/systemd/systemd-resolved',
|
|
|
|
'/usr/lib/systemd/systemd-timesyncd',
|
2022-12-19 23:06:06 +00:00
|
|
|
'/usr/lib/systemd/systemd-userdbd',
|
2023-01-04 16:03:38 +00:00
|
|
|
'/usr/lib/systemd/systemd-userwork',
|
2023-01-20 14:29:10 +00:00
|
|
|
'/usr/lib/tracker-extract-3',
|
2023-07-19 19:22:43 +00:00
|
|
|
'/usr/lib/upowerd',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/x86_64-linux-gnu/obs-plugins/obs-browser-page',
|
2022-12-15 21:51:58 +00:00
|
|
|
'/usr/lib/xdg-desktop-portal-gtk',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/xf86-video-intel-backlight-helper',
|
2022-11-17 12:20:19 +00:00
|
|
|
'/usr/local/bin/kind',
|
2024-08-27 22:40:43 +00:00
|
|
|
'/usr/sbin/dnsmasq',
|
2022-11-17 12:20:19 +00:00
|
|
|
'/usr/share/code/chrome_crashpad_handler',
|
|
|
|
'/usr/share/code/code',
|
|
|
|
'/usr/share/spotify-client/spotify',
|
|
|
|
'/usr/share/teams/team'
|
2022-10-18 18:42:26 +00:00
|
|
|
)
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/bin/%'
|
2023-05-03 20:28:00 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/git/%'
|
2024-09-23 15:07:53 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/upstream/%'
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/.local/share/JetBrains/Toolbox/apps/%'
|
|
|
|
AND NOT p0.path LIKE '/home/%/.local/share/nvim/mason/packages/%'
|
2023-05-02 19:25:36 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/.cache/JetBrains/%/GoLand/___%'
|
2023-05-02 21:49:53 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/.local/share/Steam/ubuntu%'
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT p0.path LIKE '/home/%/.rustup/toolchains/%/libexec/%'
|
|
|
|
AND NOT p0.path LIKE '/home/%/jbr/lib/jcef_helper'
|
|
|
|
AND NOT p0.path LIKE '/home/%/jbr/bin/java'
|
|
|
|
AND NOT p0.path LIKE '/home/%/node_modules/.bin/%'
|
|
|
|
AND NOT p0.path LIKE '/home/%/Projects/%'
|
|
|
|
AND NOT p0.path LIKE '/home/%/terraform-provider-%'
|
|
|
|
AND NOT p0.path LIKE '/home/%/%.test'
|
|
|
|
AND NOT p0.path LIKE '/nix/store/%/bin/%'
|
|
|
|
AND NOT p0.path LIKE '/nix/store/%/libexec/%'
|
|
|
|
AND NOT p0.path LIKE '/opt/%'
|
|
|
|
AND NOT p0.path LIKE '/tmp/go-build%'
|
|
|
|
AND NOT p0.path LIKE '/tmp/terraform_%/terraform'
|
|
|
|
AND NOT p0.path LIKE '/tmp/tmp0.%/%/bin/%'
|
|
|
|
AND NOT p0.path LIKE '/usr/local/bin/%'
|
|
|
|
AND NOT p0.path LIKE '/usr/local/Cellar/%'
|
|
|
|
AND NOT p0.path LIKE '/usr/local/kolide-k2/bin/osqueryd-updates/%/osqueryd'
|
|
|
|
AND NOT p0.path LIKE '/usr/local/kolide-k2/bin/launcher-updates/%/launcher'
|
2024-04-26 20:14:02 +00:00
|
|
|
AND NOT p0.path LIKE '/var/kolide-k2/%/osqueryd'
|
|
|
|
AND NOT p0.path LIKE '/var/kolide-k2/%/launcher'
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT p0.path LIKE '%/.vscode/extensions/%'
|
2024-08-27 22:40:43 +00:00
|
|
|
AND NOT p0.path LIKE '/var/home/linuxbrew/.linuxbrew/Cellar/%'
|
2023-06-14 14:58:41 +00:00
|
|
|
AND NOT p0.path LIKE '%/.local/share/spotify-launcher/install/usr/%'
|
2024-09-23 15:07:53 +00:00
|
|
|
AND NOT p0.path LIKE '/var/opt/Elastic/Agent/data/elastic-agent-%/components/%'
|
2023-02-24 17:15:56 +00:00
|
|
|
AND NOT (
|
2023-04-17 20:20:35 +00:00
|
|
|
p0.name IN ('osqtool-x86_64', 'osqtool-arm64')
|
|
|
|
AND p0.cmdline LIKE './%'
|
2023-02-24 17:15:56 +00:00
|
|
|
)
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT p1.path IN ('/usr/bin/gnome-shell') -- Filter out developers working on their own code
|
2023-05-23 15:31:37 +00:00
|
|
|
AND NOT p1.name = 'makepkg'
|
|
|
|
AND NOT p2.path = '/usr/bin/yay'
|
|
|
|
AND NOT p2.cmdline LIKE '/usr/bin/yay %'
|
2024-02-26 22:26:56 +00:00
|
|
|
AND NOT (
|
|
|
|
f.directory IN ('/usr/bin', '/usr/sbin')
|
|
|
|
AND f.filename NOT LIKE '.%'
|
|
|
|
)
|
2022-10-18 18:42:26 +00:00
|
|
|
AND NOT (
|
2023-04-17 20:20:35 +00:00
|
|
|
p0.path LIKE '/home/%'
|
|
|
|
AND p0.uid > 499
|
2022-10-18 18:42:26 +00:00
|
|
|
AND f.ctime = f.mtime
|
2023-04-17 20:20:35 +00:00
|
|
|
AND f.uid = p0.uid
|
|
|
|
AND p0.cmdline LIKE './%'
|
2023-05-17 14:54:16 +00:00
|
|
|
AND p0.path NOT LIKE '%/.%'
|
|
|
|
AND p0.path NOT LIKE '%cache%'
|
2022-10-18 18:42:26 +00:00
|
|
|
)
|
2023-02-21 00:10:12 +00:00
|
|
|
AND NOT (
|
2023-04-17 20:20:35 +00:00
|
|
|
p0.path LIKE '/tmp/%/osqtool-%'
|
|
|
|
AND p0.uid > 499
|
2023-02-21 00:10:12 +00:00
|
|
|
AND f.ctime = f.mtime
|
2023-04-17 20:20:35 +00:00
|
|
|
AND f.uid = p0.uid
|
|
|
|
AND p0.cmdline LIKE './%'
|
2023-02-21 00:10:12 +00:00
|
|
|
)
|
2022-12-16 22:37:32 +00:00
|
|
|
AND NOT (
|
2023-04-17 20:20:35 +00:00
|
|
|
p0.path LIKE '/home/%/.magefile/%'
|
|
|
|
AND p0.uid > 499
|
2022-12-16 22:37:32 +00:00
|
|
|
AND f.ctime = f.mtime
|
2023-04-17 20:20:35 +00:00
|
|
|
AND f.uid = p0.uid
|
2022-12-16 22:37:32 +00:00
|
|
|
)
|
2022-10-19 20:19:53 +00:00
|
|
|
GROUP BY
|
2023-04-17 20:20:35 +00:00
|
|
|
p0.pid
|