2022-10-18 18:42:26 +00:00
|
|
|
-- Programs who were recently added to disk, based on btime/ctime
|
|
|
|
--
|
|
|
|
-- false-positives:
|
|
|
|
-- * many
|
|
|
|
--
|
|
|
|
-- tags: transient process state often
|
|
|
|
-- platform: linux
|
2022-10-19 20:19:53 +00:00
|
|
|
SELECT
|
|
|
|
p.pid,
|
2022-10-18 18:42:26 +00:00
|
|
|
p.path,
|
|
|
|
p.name,
|
|
|
|
p.cmdline,
|
|
|
|
p.cwd,
|
|
|
|
p.euid,
|
|
|
|
p.parent,
|
|
|
|
f.directory,
|
|
|
|
f.ctime,
|
|
|
|
f.btime,
|
|
|
|
f.mtime,
|
|
|
|
p.start_time,
|
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.name AS parent_name,
|
|
|
|
pp.cmdline AS parent_cmdline,
|
|
|
|
pp.cwd AS parent_cwd,
|
|
|
|
pp.euid AS parent_euid,
|
|
|
|
ch.sha256 AS child_sha256,
|
|
|
|
ph.sha256 AS parent_sha256
|
2022-10-19 20:19:53 +00:00
|
|
|
FROM
|
|
|
|
processes p
|
2022-10-18 18:42:26 +00:00
|
|
|
LEFT JOIN file f ON p.path = f.path
|
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN hash AS ch ON p.path = ch.path
|
|
|
|
LEFT JOIN hash AS ph ON pp.path = ph.path
|
2022-10-19 20:19:53 +00:00
|
|
|
WHERE
|
|
|
|
p.start_time > 0
|
2022-10-18 18:42:26 +00:00
|
|
|
AND f.ctime > 0 -- Only process programs that had an inode modification within the last 3 minutes
|
|
|
|
AND (p.start_time - MAX(f.ctime, f.btime)) < 180
|
|
|
|
AND p.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-10-18 18:42:26 +00:00
|
|
|
AND NOT p.path IN (
|
|
|
|
'',
|
|
|
|
'/opt/google/chrome/chrome',
|
2022-10-24 15:08:28 +00:00
|
|
|
'/opt/google/chrome/chrome_crashpad_handler',
|
|
|
|
'/opt/google/chrome/nacl_helper',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/bin/containerd',
|
|
|
|
'/usr/bin/dockerd',
|
2022-10-27 14:41:14 +00:00
|
|
|
'/usr/bin/bash',
|
2022-10-21 18:13:29 +00:00
|
|
|
'/usr/bin/gedit',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/bin/obs',
|
2022-10-27 14:23:15 +00:00
|
|
|
'/usr/bin/docker-proxy',
|
|
|
|
'/usr/lib/google-cloud-sdk/platform/bundledpythonunix/bin/python3',
|
|
|
|
'/usr/lib/snapd/snapd',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/bin/pipewire',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/bin/tailscaled',
|
|
|
|
'/usr/bin/udevadm',
|
2022-10-27 20:55:00 +00:00
|
|
|
'/usr/bin/cargo',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/at-spi2-registryd',
|
|
|
|
'/usr/lib/at-spi-bus-launcher',
|
2022-10-24 15:08:28 +00:00
|
|
|
'/usr/libexec/docker/docker-proxy',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/libexec/fwupd/fwupd',
|
|
|
|
'/usr/libexec/sssd/sssd_kcm',
|
|
|
|
'/usr/lib/fwupd/fwupd',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/lib/gdm',
|
|
|
|
'/usr/lib/gdm-session-worker',
|
|
|
|
'/usr/lib/gdm-x-session',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/slack/chrome_crashpad_handler',
|
|
|
|
'/usr/lib/slack/slack',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/lib/systemd/systemd',
|
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',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/lib/systemd/systemd-oomd',
|
|
|
|
'/usr/lib/systemd/systemd-resolved',
|
|
|
|
'/usr/lib/systemd/systemd-timesyncd',
|
|
|
|
'/usr/lib/x86_64-linux-gnu/obs-plugins/obs-browser-page',
|
|
|
|
'/usr/lib/xf86-video-intel-backlight-helper',
|
2022-10-27 14:23:15 +00:00
|
|
|
'/usr/bin/containerd-shim-runc-v2',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/usr/sbin/chronyd',
|
2022-10-18 18:42:26 +00:00
|
|
|
'/usr/sbin/cupsd',
|
|
|
|
'/usr/sbin/tailscaled'
|
|
|
|
)
|
|
|
|
AND NOT p.path LIKE '%-go-build%'
|
|
|
|
AND NOT p.path LIKE '/home/%/bin/%'
|
|
|
|
AND NOT p.path LIKE '/home/%/terraform-provider-%'
|
|
|
|
AND NOT p.path LIKE '/home/%/%.test'
|
|
|
|
AND NOT p.path LIKE '/home/%/Projects/%'
|
|
|
|
AND NOT p.path LIKE '/home/%/node_modules/.bin/exec-bin/%'
|
|
|
|
AND NOT p.path LIKE '/nix/store/%/bin/%'
|
|
|
|
AND NOT p.path LIKE '/usr/local/bin/%'
|
|
|
|
AND NOT p.path LIKE '/usr/local/Cellar/%'
|
|
|
|
AND NOT p.path LIKE '/usr/local/kolide-k2/bin/osqueryd-updates/%/osqueryd'
|
|
|
|
AND NOT p.path LIKE '%/.vscode/extensions/%'
|
|
|
|
AND NOT pp.path IN ('/usr/bin/gnome-shell') -- Filter out developers working on their own code
|
|
|
|
AND NOT (
|
|
|
|
p.path LIKE '/home/%'
|
|
|
|
AND p.uid > 499
|
|
|
|
AND f.ctime = f.mtime
|
|
|
|
AND f.uid = p.uid
|
|
|
|
AND p.cmdline LIKE './%'
|
|
|
|
)
|
2022-10-19 20:19:53 +00:00
|
|
|
GROUP BY
|
|
|
|
p.pid
|