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

51 lines
1.2 KiB
MySQL
Raw Permalink Normal View History

-- tags: volume filesystem seldom
2023-09-20 21:03:21 +00:00
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
file.path IN (
2024-08-27 22:45:06 +00:00
SELECT
path
FROM
file
WHERE
(
file.path LIKE '/home/%/Downloads/%'
OR file.path LIKE '/home/%/Downloads/%/%'
OR file.path LIKE '/Users/%/Downloads/%'
OR file.path LIKE '/Users/%/Downloads/%/%'
OR file.path LIKE '/tmp/%'
OR file.path LIKE '/var/tmp/%'
)
AND file.type = "regular"
AND file.size > 2000
AND file.size < 400000
AND (
file.btime > (strftime('%s', 'now') -43200)
OR file.ctime > (strftime('%s', 'now') -43200)
OR file.mtime > (strftime('%s', 'now') -43200)
)
2023-09-20 21:03:21 +00:00
)
AND yara.sigrule = '
2023-09-20 21:03:21 +00:00
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
}'
2024-02-16 22:21:00 +00:00
AND yara.count > 0