Yara Recently Downloaded Go Crypt Exec
osquery
Recently downloaded cryptexec program
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
-- Recently downloaded cryptexec program
SELECT
file.path,
file.size,
file.btime,
file.ctime,
file.mtime,
data,
magic.hash.sha256,
*
yara.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 '/home/%/Downloads/%/%'
OR file.path LIKE '/Users/%/Downloads/%'
OR file.path LIKE '/Users/%/Downloads/%/%'
OR file.path LIKE '/Volumes/%'
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 yara.sigrule = '
rule cryptexec {
strings:
$cbc = "crypto/cipher.newCBC" ascii
$aes = "crypto/aes.newCipher"
$run = "os/exec.(*Cmd).Run" ascii
$exec = "os/exec.Command" ascii
condition:
3 of them
}'
AND yara.count > 0
AND file.path NOT LIKE '/Users/%/Downloads/chainctl%'
AND file.filename NOT IN ('grype', 'chainctl')
tags: SStagSS