2022-10-04 13:37:40 +00:00
|
|
|
-- Programs which appear to have been touched on macOS
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
2022-10-07 16:46:55 +00:00
|
|
|
-- This check is probably not very useful as there are plenty of legit reasons why
|
2022-10-13 18:59:32 +00:00
|
|
|
-- the dates (in particular, 'btime'), gets doctored.
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
|
|
|
-- false positives:
|
|
|
|
-- * Programs which are packaged weirdly and don't follow the typical Apple app layout
|
|
|
|
--
|
2022-10-19 20:56:32 +00:00
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1070/006/ (Timestomping)
|
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- tags: transient seldom filesystem state
|
|
|
|
-- platform: darwin
|
2022-10-12 01:53:36 +00:00
|
|
|
SELECT
|
|
|
|
p.path,
|
2022-10-04 13:37:40 +00:00
|
|
|
p.name,
|
|
|
|
p.cmdline,
|
|
|
|
p.euid,
|
2022-10-13 18:59:32 +00:00
|
|
|
DATETIME(p.start_time, 'unixepoch') AS started,
|
|
|
|
DATETIME(f.ctime, 'unixepoch') AS changed,
|
|
|
|
DATETIME(f.btime, 'unixepoch') AS birthed,
|
|
|
|
DATETIME(f.mtime, 'unixepoch') AS modified,
|
|
|
|
DATETIME(f.atime, 'unixepoch') AS accessed,
|
2022-10-04 13:37:40 +00:00
|
|
|
(f.btime - f.ctime) / 86400 AS btime_ctime_days_diff,
|
2022-10-05 20:15:40 +00:00
|
|
|
(p.start_time - f.atime) / 86400 AS start_atime_days_diff,
|
2022-10-04 13:37:40 +00:00
|
|
|
pp.path AS parent_path,
|
|
|
|
pp.cmdline AS parent_cmd,
|
|
|
|
pp.cwd AS parent_cwd,
|
|
|
|
hash.sha256 AS sha256,
|
|
|
|
signature.identifier,
|
|
|
|
signature.authority
|
2022-10-12 01:53:36 +00:00
|
|
|
FROM
|
|
|
|
processes p
|
2022-10-04 13:37:40 +00:00
|
|
|
LEFT JOIN file f ON p.path = f.path
|
|
|
|
LEFT JOIN processes pp ON p.parent = pp.pid
|
|
|
|
LEFT JOIN hash ON p.path = hash.path
|
|
|
|
LEFT JOIN signature ON p.path = signature.path
|
2022-10-12 01:53:36 +00:00
|
|
|
WHERE
|
2023-05-17 14:54:16 +00:00
|
|
|
p.pid IN (
|
|
|
|
SELECT pid
|
|
|
|
FROM processes
|
|
|
|
WHERE path NOT LIKE '/System/%'
|
|
|
|
AND path NOT LIKE '/Library/Apple/%'
|
|
|
|
AND path NOT LIKE '/usr/libexec/%'
|
|
|
|
AND path NOT LIKE '/usr/sbin/%'
|
|
|
|
AND path NOT LIKE '/sbin/%'
|
|
|
|
AND path NOT LIKE '/private/var/db/com.apple.xpc.roleaccountd.staging/%'
|
|
|
|
AND path NOT LIKE '/usr/bin/%'
|
|
|
|
AND path NOT LIKE '/usr/local/kolide-k2/bin/osqueryd-updates/%/osqueryd'
|
|
|
|
AND path NOT LIKE '/usr/local/kolide-k2/bin/launcher-updates/%/Kolide.app/Contents/MacOS/launcher'
|
|
|
|
)
|
|
|
|
|
|
|
|
AND f.btime == f.mtime
|
2022-10-04 13:37:40 +00:00
|
|
|
AND (
|
2022-10-07 20:19:18 +00:00
|
|
|
-- change time is older than birth time
|
|
|
|
btime_ctime_days_diff > 0 -- change time is older than birth time, but not 1970
|
|
|
|
OR (
|
|
|
|
(btime_ctime_days_diff < -365)
|
|
|
|
AND (btime_ctime_days_diff < -1000)
|
2022-11-16 15:56:58 +00:00
|
|
|
)
|
|
|
|
-- access time is older than start time
|
|
|
|
OR start_atime_days_diff > 90
|
2022-10-07 20:19:18 +00:00
|
|
|
) -- Vendors that create software packages that look like a touched file.
|
2022-10-04 13:37:40 +00:00
|
|
|
AND NOT signature.authority IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'Apple Mac OS Application Signing',
|
2022-11-03 15:51:54 +00:00
|
|
|
'Developer ID Application: Fumihiko Takayama (G43BCU2T37)', -- Karibiner
|
2022-10-13 18:59:32 +00:00
|
|
|
'Developer ID Application: Adobe Inc. (JQ525L2MZD)',
|
|
|
|
'Developer ID Application: Brave Software, Inc. (KL8N8XSYF4)',
|
|
|
|
'Developer ID Application: Brother Industries, LTD. (5HCL85FLGW)',
|
|
|
|
'Developer ID Application: Bryan Jones (49EYHPJ4Q3)',
|
2023-02-24 21:30:17 +00:00
|
|
|
'Developer ID Application: Reflect App, LLC (789ULN5MZB)',
|
2022-10-13 18:59:32 +00:00
|
|
|
'Developer ID Application: CodeWeavers Inc. (9C6B7X7Z8E)',
|
|
|
|
'Developer ID Application: Corsair Memory, Inc. (Y93VXCB8Q5)',
|
2022-11-16 15:56:58 +00:00
|
|
|
'Developer ID Application: Sublime HQ Pty Ltd (Z6D26JE4Y4)',
|
2022-10-13 18:59:32 +00:00
|
|
|
'Developer ID Application: Docker Inc (9BNSXJN65R)',
|
|
|
|
'Developer ID Application: Emmanouil Konstantinidis (3YP8SXP3BF)',
|
2022-11-16 15:56:58 +00:00
|
|
|
'Developer ID Application: Microsoft Corporation (UBF8T346G9)',
|
2022-10-13 18:59:32 +00:00
|
|
|
'Developer ID Application: Galvanix (5BRAQAFB8B)',
|
|
|
|
'Developer ID Application: General Arcade (Pte. Ltd.) (S8JLSG5ES7)',
|
|
|
|
'Developer ID Application: GEORGE NACHMAN (H7V7XYVQ7D)',
|
|
|
|
'Developer ID Application: JetBrains s.r.o. (2ZEFAR8TH3)',
|
|
|
|
'Developer ID Application: GitHub (VEKTX9H2N7)',
|
|
|
|
'Developer ID Application: Google LLC (EQHXZ8M8AV)',
|
|
|
|
'Developer ID Application: Logitech Inc. (QED4VVPZWA)',
|
|
|
|
'Developer ID Application: Michael Jones (YD6LEYT6WZ)',
|
|
|
|
'Developer ID Application: OSQUERY A Series of LF Projects, LLC (3522FA9PXF)',
|
|
|
|
'Developer ID Application: RescueTime, Inc (FSY4RB8H39)',
|
|
|
|
'Developer ID Application: Seiko Epson Corporation (TXAEAV5RN4)',
|
|
|
|
'Developer ID Application: Yubico Limited (LQA3CS5MM7)',
|
|
|
|
'Software Signing'
|
2022-10-04 13:37:40 +00:00
|
|
|
)
|
|
|
|
AND NOT (
|
2022-10-07 20:19:18 +00:00
|
|
|
p.euid > 500
|
2022-10-04 13:37:40 +00:00
|
|
|
AND (
|
|
|
|
p.path IN (
|
2023-04-28 18:09:57 +00:00
|
|
|
'/Applications/Canon Utilities/IJ Scan Utility/Canon IJ Scan Utility Lite.app/Contents/Library/LoginItems/CIJSULAgent.app/Contents/MacOS/CIJSULAgent',
|
|
|
|
'/Applications/Canon Utilities/Inkjet Extended Survey Program/Inkjet Extended Survey Program.app/Contents/MacOS/ESPController.app/Contents/Library/LoginItems/CanonIJExtendedSurveyLaunchAgent.app/Contents/MacOS/CanonIJExtendedSurveyLaunchAgent',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/Applications/Divvy.app/Contents/MacOS/Divvy',
|
|
|
|
'/Applications/Sourcetree.app/Contents/MacOS/Sourcetree',
|
|
|
|
'/Library/CoreMediaIO/Plug-Ins/DAL/LogiCapture.plugin/Contents/MacOS/Assistant',
|
2023-04-28 18:09:57 +00:00
|
|
|
'/Library/Printers/Brother/Utilities/BrStatusMonitor.app/Contents/MacOS/BrStatusMonitor'
|
2022-10-04 13:37:40 +00:00
|
|
|
)
|
2022-10-13 18:59:32 +00:00
|
|
|
OR p.path LIKE '/Users/%/Library/Application Support/com.elgato.StreamDeck/Plugins/%'
|
2023-03-06 20:11:11 +00:00
|
|
|
OR p.path LIKE '/private/var/folders/%/T/AppTranslocation/%/Contents/MacOS/%'
|
2022-10-13 18:59:32 +00:00
|
|
|
OR p.path LIKE '/Applications/%.app/Contents/MacOS/%'
|
2022-12-02 16:20:18 +00:00
|
|
|
OR p.path LIKE '/Applications/%.app/Contents/Frameworks/%/Versions/A/Resources/%'
|
2022-10-13 18:59:32 +00:00
|
|
|
OR p.path LIKE '/opt/homebrew/Cellar/%/bin/%'
|
2022-10-21 15:40:47 +00:00
|
|
|
OR p.path LIKE '/opt/homebrew/Caskroom/%/bin/%'
|
2022-11-18 15:27:43 +00:00
|
|
|
OR p.path LIKE '/Users/%/google-cloud-sdk/bin/%'
|
2022-10-04 13:37:40 +00:00
|
|
|
)
|
|
|
|
)
|
2022-10-21 15:40:47 +00:00
|
|
|
AND NOT (
|
|
|
|
p.euid > 300
|
|
|
|
AND p.path LIKE '/nix/store/%'
|
|
|
|
)
|
2022-11-16 21:52:39 +00:00
|
|
|
AND NOT (
|
|
|
|
p.euid > 300
|
|
|
|
-- Electron
|
|
|
|
AND p.path LIKE '% Helper'
|
|
|
|
)
|
2022-10-12 01:53:36 +00:00
|
|
|
AND NOT (
|
|
|
|
p.euid = 0
|
|
|
|
AND (
|
2022-10-13 18:59:32 +00:00
|
|
|
p.path LIKE '/nix/store/%/bin/nix'
|
|
|
|
OR p.path LIKE '/nix/store/%/bin/nix-daemon'
|
2022-10-12 01:53:36 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
GROUP by
|
|
|
|
p.pid
|