2023-02-14 13:33:05 +00:00
|
|
|
-- Alert on programs running that are unusually old
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
2022-10-19 20:56:32 +00:00
|
|
|
-- false positive:
|
|
|
|
-- * legimitely ancient programs. For instance, printer drivers.
|
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- references:
|
2022-10-19 20:56:32 +00:00
|
|
|
-- * https://attack.mitre.org/techniques/T1070/006/ (Indicator Removal on Host: Timestomp)
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
|
|
|
-- tags: transient process state
|
2023-01-20 14:24:24 +00:00
|
|
|
SELECT
|
|
|
|
p.path,
|
2022-09-24 15:12:23 +00:00
|
|
|
p.cmdline,
|
|
|
|
p.cwd,
|
2023-01-19 16:42:00 +00:00
|
|
|
p.pid,
|
|
|
|
p.name,
|
|
|
|
f.mtime,
|
|
|
|
f.ctime,
|
|
|
|
p.cgroup_path,
|
2022-09-24 15:12:23 +00:00
|
|
|
((strftime('%s', 'now') - f.ctime) / 86400) AS ctime_age_days,
|
2023-01-19 16:42:00 +00:00
|
|
|
((strftime('%s', 'now') - f.mtime) / 86400) AS mtime_age_days,
|
2022-09-24 15:12:23 +00:00
|
|
|
((strftime('%s', 'now') - f.btime) / 86400) AS btime_age_days,
|
|
|
|
h.sha256,
|
|
|
|
f.uid,
|
2023-02-21 00:10:12 +00:00
|
|
|
m.data,
|
2022-09-24 15:12:23 +00:00
|
|
|
f.gid
|
2023-01-20 14:24:24 +00:00
|
|
|
FROM
|
|
|
|
processes p
|
2023-01-19 16:42:00 +00:00
|
|
|
LEFT JOIN file f ON p.path = f.path
|
|
|
|
LEFT JOIN hash h ON p.path = h.path
|
|
|
|
LEFT JOIN magic m ON p.path = m.path
|
2023-01-20 14:24:24 +00:00
|
|
|
WHERE
|
|
|
|
(
|
2022-09-29 19:42:27 +00:00
|
|
|
ctime_age_days > 1050
|
|
|
|
OR mtime_age_days > 1050
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2023-01-20 13:40:08 +00:00
|
|
|
-- Jan 1st, 1980 (the source of many false positives)
|
|
|
|
AND f.mtime > 315561600
|
2023-01-19 16:42:00 +00:00
|
|
|
AND f.path NOT LIKE '/home/%/idea-IU-223.8214.52/%'
|
2023-03-04 17:20:53 +00:00
|
|
|
AND f.directory NOT LIKE '/Applications/%.app/Contents/MacOS'
|
|
|
|
AND f.directory NOT LIKE '/Applications/%.app/Contents/Frameworks/%/Resources'
|
|
|
|
AND f.directory NOT LIKE '/opt/homebrew/Cellar/%/bin'
|
2023-01-19 16:42:00 +00:00
|
|
|
AND f.path NOT IN (
|
2023-02-15 01:16:02 +00:00
|
|
|
'/Applications/Gitter.app/Contents/Library/LoginItems/GitterHelperApp.app/Contents/MacOS/GitterHelperApp',
|
|
|
|
'/Applications/Pandora.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/crashpad_handler',
|
|
|
|
'/Applications/Skitch.app/Contents/Library/LoginItems/J8RPQ294UB.com.skitch.SkitchHelper.app/Contents/MacOS/J8RPQ294UB.com.skitch.SkitchHelper',
|
|
|
|
'/Library/Application Support/Logitech/com.logitech.vc.LogiVCCoreService/LogiVCCoreService.app/Contents/MacOS/LogiVCCoreService',
|
2023-04-27 16:00:08 +00:00
|
|
|
'/Library/Printers/Brother/Utilities/BrStatusMonitor.app/Contents/MacOS/BrStatusMonitor',
|
2023-01-19 16:42:00 +00:00
|
|
|
'/Library/Printers/Brother/Utilities/Server/LOGINserver.app/Contents/MacOS/LOGINserver',
|
2023-02-15 01:16:02 +00:00
|
|
|
'/Library/Printers/Brother/Utilities/Server/NETserver.app/Contents/MacOS/NETserver',
|
|
|
|
'/Library/Printers/Brother/Utilities/Server/USBAppControl.app/Contents/MacOS/USBAppControl',
|
2023-01-19 16:42:00 +00:00
|
|
|
'/Library/Printers/Brother/Utilities/Server/USBserver.app/Contents/MacOS/USBserver',
|
|
|
|
'/Library/Printers/Brother/Utilities/Server/WorkflowAppControl.app/Contents/MacOS/WorkflowAppControl',
|
|
|
|
'/snap/brackets/138/opt/brackets/Brackets',
|
|
|
|
'/snap/brackets/138/opt/brackets/Brackets-node',
|
2023-02-15 01:16:02 +00:00
|
|
|
'/usr/bin/i3blocks',
|
2023-02-21 00:10:12 +00:00
|
|
|
'/usr/bin/sshfs',
|
2023-05-02 21:49:53 +00:00
|
|
|
'/usr/bin/xclip',
|
2023-04-27 16:00:08 +00:00
|
|
|
'/usr/bin/xss-lock',
|
|
|
|
'/usr/local/bin/dive'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2023-01-19 16:42:00 +00:00
|
|
|
AND p.name NOT IN (
|
|
|
|
'buildkitd',
|
2023-02-14 13:33:05 +00:00
|
|
|
'kail',
|
2023-02-15 01:16:02 +00:00
|
|
|
'kail',
|
2023-06-30 20:38:31 +00:00
|
|
|
'Android File Transfer Agent',
|
2023-01-19 16:42:00 +00:00
|
|
|
'BluejeansHelper',
|
|
|
|
'J8RPQ294UB.com.skitch.SkitchHelper',
|
|
|
|
'Pandora',
|
2023-01-20 13:40:08 +00:00
|
|
|
'Pandora Helper',
|
|
|
|
'dlv'
|
2023-01-19 16:42:00 +00:00
|
|
|
)
|
2023-03-20 21:05:02 +00:00
|
|
|
AND p.cgroup_path NOT LIKE '/system.slice/docker-%'
|
|
|
|
AND p.cgroup_path NOT LIKE '/user.slice/user-%.slice/user@%.service/user.slice/nerdctl-%'
|
2023-01-20 14:24:24 +00:00
|
|
|
GROUP BY
|
|
|
|
p.pid,
|
|
|
|
p.path
|