2022-10-14 18:19:13 +00:00
|
|
|
-- Unusually small programs (events-based)
|
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://cybersecurity.att.com/blogs/labs-research/shikitega-new-stealthy-malware-targeting-linux
|
|
|
|
--
|
2023-02-01 21:17:36 +00:00
|
|
|
-- interval: 300
|
2022-10-14 18:19:13 +00:00
|
|
|
-- tags: transient process events
|
2022-10-07 20:19:18 +00:00
|
|
|
SELECT
|
|
|
|
p.pid,
|
|
|
|
p.path,
|
|
|
|
p.cmdline,
|
|
|
|
file.size,
|
2022-11-09 14:14:10 +00:00
|
|
|
file.type,
|
2022-10-07 20:19:18 +00:00
|
|
|
p.mode,
|
|
|
|
p.cwd,
|
|
|
|
p.euid,
|
|
|
|
p.parent,
|
|
|
|
p.syscall,
|
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.name AS parent_name,
|
|
|
|
pp.cmdline AS parent_cmdline,
|
|
|
|
pp.euid AS parent_euid,
|
2022-11-09 14:14:10 +00:00
|
|
|
hash.sha256 AS child_sha256,
|
|
|
|
phash.sha256 AS parent_sha256,
|
|
|
|
magic.data AS magic
|
2022-10-07 20:19:18 +00:00
|
|
|
FROM
|
|
|
|
process_events p
|
|
|
|
LEFT JOIN file ON p.path = file.path
|
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
2022-11-09 14:14:10 +00:00
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
|
|
|
LEFT JOIN hash phash ON pp.path = phash.path
|
|
|
|
LEFT JOIN magic ON p.path = magic.path
|
2022-10-07 20:19:18 +00:00
|
|
|
WHERE
|
2023-02-01 21:17:36 +00:00
|
|
|
p.time > (strftime('%s', 'now') -300)
|
2022-10-07 20:19:18 +00:00
|
|
|
AND file.size > 0
|
|
|
|
AND file.size < 10000
|
2022-11-09 14:14:10 +00:00
|
|
|
AND file.type = 'regular'
|
2023-01-16 17:56:39 +00:00
|
|
|
AND p.cwd != ""
|
|
|
|
AND p.cwd IS NOT NULL
|
2022-10-18 00:37:44 +00:00
|
|
|
AND p.path NOT LIKE '%.sh'
|
|
|
|
AND p.path NOT LIKE '%.py'
|
|
|
|
AND p.path NOT LIKE '%.rb'
|
2022-11-17 12:20:19 +00:00
|
|
|
AND p.path != '/sbin/ldconfig'
|
2022-11-16 19:49:36 +00:00
|
|
|
AND NOT (
|
|
|
|
p.path LIKE '/Users/%'
|
|
|
|
AND magic.data LIKE 'POSIX shell script%'
|
|
|
|
)
|
2022-11-09 14:14:10 +00:00
|
|
|
AND p.path NOT LIKE '/private/var/folders/%/T/iTerm2-scrip%sh'
|
2023-04-28 18:09:57 +00:00
|
|
|
AND p.path NOT LIKE '/home/%/.local/share/Steam/%'
|
2022-10-17 21:31:47 +00:00
|
|
|
-- Removes a false-positive we've seen on Linux, generated through 'runc init'
|
2022-10-17 23:06:17 +00:00
|
|
|
AND NOT (
|
|
|
|
p.path = "/"
|
2022-10-18 15:32:18 +00:00
|
|
|
AND file.size < 8192
|
2022-10-17 23:06:17 +00:00
|
|
|
)
|