osquery-defense-kit/process/high-disk-bytes-written.sql

64 lines
2.1 KiB
MySQL
Raw Normal View History

SELECT p.name,
p.path,
p.cmdline,
p.on_disk,
p.parent,
p.start_time,
hash.sha256,
p.disk_bytes_written,
p.cwd,
(strftime('%s', 'now') - start_time) AS age,
2022-09-02 14:56:04 +00:00
disk_bytes_written / (strftime('%s', 'now') - start_time) AS bytes_per_second
FROM processes p
LEFT JOIN hash ON p.path = hash.path
2022-09-02 16:56:31 +00:00
WHERE bytes_per_second > 2000000
2022-09-02 14:56:04 +00:00
AND age > 120
AND p.path NOT IN (
2022-09-02 16:56:31 +00:00
'/bin/bash',
2022-09-24 15:07:34 +00:00
'/usr/bin/aptd',
2022-09-02 16:56:31 +00:00
'/usr/bin/bash',
2022-09-24 15:07:34 +00:00
'/usr/bin/bwrap',
'/usr/bin/curl',
2022-09-02 16:56:31 +00:00
'/usr/bin/fish',
'/usr/bin/gnome-shell',
2022-09-24 15:07:34 +00:00
'/usr/bin/qemu-system-x86_64',
'/usr/bin/yay',
'/usr/bin/zsh',
'/usr/lib/flatpak-system-helper',
2022-09-02 14:56:04 +00:00
'/usr/lib/systemd/systemd-journald',
'/usr/lib/systemd/systemd',
2022-09-24 15:07:34 +00:00
'/usr/lib64/thunderbird/thunderbird',
2022-09-02 16:56:31 +00:00
'/usr/libexec/coreduetd',
'/usr/libexec/coreduetd',
'/usr/libexec/packagekitd',
'/usr/libexec/rosetta/oahd',
2022-09-07 02:08:17 +00:00
'/usr/libexec/secd',
2022-09-24 15:07:34 +00:00
'/usr/libexec/sharingd',
'/usr/sbin/screencapture'
2022-09-02 14:56:04 +00:00
)
AND NOT (name LIKE "jbd%/dm-%" AND on_disk = -1)
AND NOT (name = 'bindfs' AND cmdline LIKE 'bindfs -f -o fsname=%')
AND NOT (name = 'btrfs-transaction' AND on_disk = -1)
AND NOT (name = 'kernel_task' AND p.path = '' AND parent IN (0, 1) AND on_disk = -1)
AND NOT (name = 'launchd' AND p.path = '/sbin/launchd' AND parent = 0)
2022-09-02 16:56:31 +00:00
AND NOT (name = 'logd' AND cmdline = '/usr/libexec/logd' AND parent = 1)
AND NOT name IN (
2022-09-24 15:07:34 +00:00
'chrome',
'com.apple.MobileSoftwareUpdate.UpdateBrainService',
'containerd',
'esbuild',
'firefox',
2022-09-24 15:07:34 +00:00
'goland',
'gopls',
2022-09-24 15:07:34 +00:00
'jetbrains-toolb',
'slack',
'slack',
2022-09-24 15:07:34 +00:00
'wineserver'
)
AND p.path NOT LIKE '/Applications/%.app/Contents/%'
AND p.path NOT LIKE '/home/%/.local/share/Steam'
2022-09-22 17:18:16 +00:00
AND p.path NOT LIKE '/nix/store/%/bin/%sh'
2022-09-22 23:35:24 +00:00
AND p.path NOT LIKE '/nix/store/%/bin/nix'
2022-09-24 15:07:34 +00:00
AND p.path NOT LIKE '/System/Applications/%'
AND p.path NOT LIKE '/System/Library/%'
2022-09-22 17:18:16 +00:00
AND p.path NOT LIKE '/usr/local/kolide-k2/bin/osqueryd-updates/%/osqueryd'