osquery-defense-kit/process/hidden-cwd.sql

27 lines
741 B
SQL

SELECT p.pid,
p.path,
p.name,
p.cmdline,
p.cwd,
p.euid,
p.parent,
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,
hash.sha256
FROM processes p
LEFT JOIN processes pp ON p.parent = pp.pid
LEFT JOIN hash ON p.path = hash.path
WHERE p.cwd LIKE "%/.%"
AND NOT (
p.cwd LIKE "%/.local/share%"
OR p.cwd LIKE "%/.vscode/extensions%"
OR p.cwd LIKE "/Users/%/.%"
OR p.cwd LIKE "/home/%/.%"
OR p.cwd LIKE "/Library/Apple/System/Library/InstallerSandboxes/.PKInstallSandboxManager-SystemSoftware/%"
OR p.cwd LIKE "/tmp/.wine-%/server-%"
OR p.name IN ('bindfs', 'wineserver')
OR p.path = "/usr/libexec/dirhelper"
)