Yara Exec Connect Process Linux
osquery
Currently running program with Linux red flags
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
-- Currently running program with Linux red flags
--
-- reference:
-- * bpfdoor (old)
--
-- tags: persistent
-- interval: 7200
-- platform: linux
SELECT
yara.strings,-- Child
AS p0_pid,
p0.pid AS p0_path,
p0.path AS p0_name,
p0.name AS p0_start,
p0.start_time AS p0_cmd,
p0.cmdline AS p0_cwd,
p0.cwd AS p0_cgroup,
p0.cgroup_path AS p0_euid,
p0.euid AS p0_sha256,
p0_hash.sha256 -- Parent
parent AS p1_pid,
p0.AS p1_path,
p1.path AS p1_name,
p1.name AS p1_start,
p1.start_time AS p1_euid,
p1.euid AS p1_cmd,
p1.cmdline AS p1_sha256,
p1_hash.sha256 -- Grandparent
parent AS p2_pid,
p1.AS p2_name,
p2.name AS p2_start,
p2.start_time AS p2_path,
p2.path AS p2_cmd,
p2.cmdline AS p2_sha256
p2_hash.sha256 FROM
processes p0JOIN yara ON p0.path = yara.path
LEFT JOIN hash p0_hash ON p0.path = p0_hash.path
LEFT JOIN processes p1 ON p0.parent = p1.pid
LEFT JOIN hash p1_hash ON p1.path = p1_hash.path
LEFT JOIN processes p2 ON p1.parent = p2.pid
LEFT JOIN hash p2_hash ON p2.path = p2_hash.path
WHERE
IN (
p0.pid SELECT
pidFROM
processesWHERE
> (strftime('%s', 'now') - 7200)
start_time AND path != ""
GROUP BY
path
)AND yara.sigrule = '
rule syscalls {
strings:
$inet_ntoa = "inet_ntoa"
$listen = "listen"
$connect = "connect"
$execve = "execve"
condition:
filesize < 10MB and $execve in (0..8192) and 2 of them
}'
AND yara.count > 0
AND yara.path NOT IN (
'/usr/bin/dbus-broker-launch',
'/usr/bin/sudo',
'/usr/lib/git-core/git-remote-https',
'/usr/sbin/auditd',
'/usr/sbin/mcelog'
)
tags: SStagSS