2023-01-13 16:38:19 +00:00
|
|
|
-- Detect unusual calls to xattr, used to remove filesystem attributes
|
|
|
|
--
|
|
|
|
-- false positives:
|
|
|
|
-- * none observed, but they are expected
|
|
|
|
--
|
2023-01-18 14:49:56 +00:00
|
|
|
-- interval: 60
|
2023-01-13 16:38:19 +00:00
|
|
|
-- platform: darwin
|
|
|
|
-- tags: process events
|
2023-01-20 14:24:24 +00:00
|
|
|
SELECT
|
|
|
|
pe.path AS path,
|
2023-01-13 16:38:19 +00:00
|
|
|
REGEX_MATCH (pe.path, '.*/(.*)', 1) AS name,
|
|
|
|
TRIM(pe.cmdline) AS cmd,
|
|
|
|
pe.pid AS pid,
|
|
|
|
pe.euid AS euid,
|
|
|
|
pe.parent AS parent_pid,
|
|
|
|
TRIM(IIF(pp.cmdline != NULL, pp.cmdline, ppe.cmdline)) AS parent_cmd,
|
|
|
|
TRIM(IIF(pp.path != NULL, pp.path, ppe.path)) AS parent_path,
|
|
|
|
REGEX_MATCH (
|
|
|
|
IIF(pp.path != NULL, pp.path, ppe.path),
|
|
|
|
'.*/(.*)',
|
|
|
|
1
|
|
|
|
) AS parent_name,
|
|
|
|
TRIM(IIF(pp.path != NULL, hash.sha256, ehash.sha256)) AS parent_hash,
|
|
|
|
TRIM(IIF(gp.cmdline != NULL, gp.cmdline, gpe.cmdline)) AS gparent_cmd,
|
|
|
|
TRIM(IIF(gp.path != NULL, gp.path, gpe.path)) AS gparent_path,
|
|
|
|
REGEX_MATCH (
|
|
|
|
IIF(gp.path != NULL, gp.path, gpe.path),
|
|
|
|
'.*/(.*)',
|
|
|
|
1
|
|
|
|
) AS gparent_name,
|
|
|
|
IIF(pp.parent != NULL, pp.parent, ppe.parent) AS gparent_pid,
|
|
|
|
IIF(
|
|
|
|
signature.identifier != NULL,
|
|
|
|
signature.identifier,
|
|
|
|
esignature.identifier
|
|
|
|
) AS parent_identifier,
|
|
|
|
IIF(
|
|
|
|
signature.authority != NULL,
|
|
|
|
signature.authority,
|
|
|
|
esignature.authority
|
|
|
|
) AS parent_authority
|
2023-01-20 14:24:24 +00:00
|
|
|
FROM
|
|
|
|
process_events pe
|
2023-01-13 16:38:19 +00:00
|
|
|
LEFT JOIN processes p ON pe.pid = p.pid
|
|
|
|
LEFT JOIN processes pp ON pe.parent = pp.pid
|
|
|
|
LEFT JOIN process_events ppe ON pe.parent = ppe.pid
|
|
|
|
LEFT JOIN processes gp ON gp.pid = pp.parent
|
|
|
|
LEFT JOIN process_events gpe ON ppe.parent = gpe.pid
|
|
|
|
LEFT JOIN hash ON pp.path = hash.path
|
|
|
|
LEFT JOIN hash ehash ON ppe.path = ehash.path
|
|
|
|
LEFT JOIN signature ON pp.path = signature.path
|
|
|
|
LEFT JOIN signature esignature ON ppe.path = esignature.path
|
2023-01-20 14:24:24 +00:00
|
|
|
WHERE
|
|
|
|
pe.path = '/usr/bin/xattr'
|
2023-01-18 14:49:56 +00:00
|
|
|
AND pe.status = 0
|
|
|
|
AND pe.time > (strftime('%s', 'now') -60)
|
|
|
|
AND cmd NOT IN (
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app',
|
2023-01-20 14:04:00 +00:00
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/Library/LoginItems/1Password Launcher.app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/XPCServices/OP Updater Service.xpc',
|
|
|
|
'/usr/bin/xattr -r -d com.apple.quarantine /Applications/1Password.app',
|
|
|
|
'/usr/bin/xattr -d -r com.apple.quarantine /Applications/iTerm.app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/XPCServices/OP Updater Service.xpc/Contents/Helpers/1Password Updater.app',
|
2023-01-18 15:57:43 +00:00
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/Frameworks/1Password Helper.app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/Frameworks/1Password Helper (GPU).app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/Frameworks/1Password Helper (Plugin).app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/Frameworks/1Password Helper (Renderer).app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/Keybase.app',
|
|
|
|
'/usr/bin/xattr -d com.apple.quarantine /Applications/1Password.app/Contents/Library/LoginItems/1Password Browser Helper.app',
|
|
|
|
'xattr -d -r com.apple.quarantine /Applications/Google Chrome.app'
|
2023-01-18 14:49:56 +00:00
|
|
|
)
|
2023-01-13 16:38:19 +00:00
|
|
|
AND NOT (
|
2023-01-16 18:55:53 +00:00
|
|
|
pe.euid > 500
|
|
|
|
AND cmd LIKE '%xattr -l %'
|
2023-01-16 17:56:39 +00:00
|
|
|
)
|
2023-01-20 13:40:08 +00:00
|
|
|
AND NOT (
|
|
|
|
pe.euid > 500
|
|
|
|
AND cmd LIKE '%xattr -p com.apple.quarantine %'
|
|
|
|
)
|
2023-01-23 13:13:04 +00:00
|
|
|
AND NOT (
|
|
|
|
pe.euid > 500
|
|
|
|
AND cmd LIKE '/usr/bin/xattr -w com.apple.metadata:kMDItemAlternateNames %'
|
|
|
|
)
|
2023-01-16 17:56:39 +00:00
|
|
|
AND NOT (
|
2023-01-16 18:55:53 +00:00
|
|
|
pe.euid > 500
|
|
|
|
AND cmd = '/usr/bin/xattr -h'
|
2023-01-20 13:40:08 +00:00
|
|
|
AND parent_cmd LIKE '%homebrew%'
|
2023-01-16 17:56:39 +00:00
|
|
|
)
|
2023-01-16 18:55:53 +00:00
|
|
|
AND cmd NOT LIKE '/usr/bin/xattr -w com.apple.quarantine 0002;%'
|
|
|
|
AND cmd NOT LIKE '/usr/bin/xattr -w com.apple.quarantine 0181;%'
|
2023-01-20 14:24:24 +00:00
|
|
|
GROUP BY
|
|
|
|
pe.pid,
|
|
|
|
cmd
|