Files Downloads

osquery
Returns a list of file information from Downloads directories
Author

Chainguard

Published

January 29, 2025

Description

ODK (osquery-defense-kit) is unique in that the queries are designed to be used as part of a production detection & response pipeline. The detection queries are formulated to return zero rows during normal expected behavior, so that they may be configured to generate alerts when rows are returned.

Query

-- Returns a list of file information from Downloads directories
--
-- tags: postmortem
-- platform: posix
-- interval: 3600
SELECT
  file.*,
  magic.data,
  hash.sha256
FROM
  file
  LEFT JOIN magic ON file.path = magic.path
  LEFT JOIN hash ON file.path = hash.path
WHERE
  (
    file.path LIKE "/home/%/Downloads/%"
    OR file.path LIKE "/Users/%/Downloads/%"
  )
  AND (
    mtime > (strftime('%s', 'now') -3600)
    OR ctime > (strftime('%s', 'now') -3600)
    OR btime > (strftime('%s', 'now') -3600)
  )

tags: SStagSS

Reference

https://github.com/chainguard-dev/osquery-defense-kit