osquery-defense-kit/detection/initial_access/yara-recently-downloaded-mi...

40 lines
1000 B
SQL

-- Recently downloaded UPX file
SELECT
file.path,
file.size,
file.btime,
file.ctime,
file.mtime,
magic.data,
hash.sha256
FROM
file
JOIN yara ON file.path = yara.path
LEFT JOIN magic ON file.path = magic.path
LEFT JOIN hash ON file.path = hash.path
WHERE
-- Only scan recent downloads
(
file.path LIKE '/home/%/Downloads/%'
OR file.path LIKE '/Users/%/Downloads/%'
OR file.path LIKE '/tmp/%'
OR file.path LIKE '/var/tmp/%'
)
AND (
file.btime > (strftime('%s', 'now') -432000)
OR file.ctime > (strftime('%s', 'now') -432000)
OR file.mtime > (strftime('%s', 'now') -432000)
)
AND NOT file.path LIKE '%.csv'
AND yara.sigrule = '
rule miner {
strings:
$tcp = "stratum+tcp://" ascii
$tls = "stratum+tls://" ascii
$ssl = "stratum+ssl://" ascii
$stratum = "stratum://" ascii
$normalhash = "\"normalHashing\": true,"
condition:
filesize < 10MB and 1 of them
}'
AND yara.count > 0