2022-09-23 14:36:11 +00:00
|
|
|
-- Scan removable volumes for sketchy files
|
2022-10-12 01:53:36 +00:00
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- false positives:
|
|
|
|
-- * Installer packages with hidden files
|
2022-10-12 01:53:36 +00:00
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- references:
|
2022-10-19 20:56:32 +00:00
|
|
|
-- * https://attack.mitre.org/techniques/T1566/001/ (Phishing: Spearphishing Attachment)
|
|
|
|
-- * https://attack.mitre.org/techniques/T1204/002/ (User Execution: Malicious File)
|
2022-10-14 18:19:13 +00:00
|
|
|
-- * https://www.crowdstrike.com/blog/how-crowdstrike-uncovered-a-new-macos-browser-hijacking-campaign/
|
|
|
|
--
|
2022-10-20 18:56:16 +00:00
|
|
|
-- tags: transient volume filesystem seldom
|
2022-10-12 01:53:36 +00:00
|
|
|
-- platform: darwin
|
2022-09-24 15:12:23 +00:00
|
|
|
SELECT
|
2022-10-13 18:59:32 +00:00
|
|
|
RTRIM(file.path, '/') AS trimpath,
|
2022-09-24 15:12:23 +00:00
|
|
|
uid,
|
|
|
|
filename,
|
|
|
|
gid,
|
|
|
|
mode,
|
2022-10-13 18:59:32 +00:00
|
|
|
REGEX_MATCH (file.path, '(.*)/', 1) AS dirname,
|
|
|
|
REGEX_MATCH (RTRIM(file.path, '/'), '.*/(.*?)$', 1) AS basename,
|
|
|
|
REGEX_MATCH (RTRIM(file.path, '/'), '.*\.(.*?)$', 1) AS extension,
|
2022-09-24 15:12:23 +00:00
|
|
|
mtime,
|
|
|
|
ctime,
|
|
|
|
symlink,
|
|
|
|
type,
|
|
|
|
size,
|
|
|
|
hash.sha256,
|
|
|
|
magic.data,
|
|
|
|
signature.identifier,
|
|
|
|
signature.authority
|
|
|
|
FROM
|
|
|
|
file
|
|
|
|
LEFT JOIN hash on file.path = hash.path
|
|
|
|
LEFT JOIN magic ON file.path = magic.path
|
|
|
|
LEFT JOIN signature ON file.path = signature.path
|
|
|
|
WHERE
|
|
|
|
(
|
2022-10-13 18:59:32 +00:00
|
|
|
file.path LIKE '/Volumes/%/%'
|
|
|
|
OR file.path LIKE '/Volumes/%/.%'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2022-10-13 18:59:32 +00:00
|
|
|
AND file.path NOT LIKE '/Volumes/Macintosh HD%'
|
|
|
|
AND file.path NOT LIKE '/Volumes/%/.com.apple.timemachine%'
|
2022-09-24 15:12:23 +00:00
|
|
|
AND (
|
|
|
|
extension IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'command',
|
|
|
|
'lnk',
|
2023-02-15 01:16:02 +00:00
|
|
|
'gcode',
|
2022-10-13 18:59:32 +00:00
|
|
|
'mpkg',
|
2023-01-26 21:30:14 +00:00
|
|
|
'pkg',
|
2022-10-13 18:59:32 +00:00
|
|
|
'scpt',
|
|
|
|
'dmg',
|
|
|
|
'iso',
|
|
|
|
'gz',
|
|
|
|
'sh',
|
|
|
|
'sql'
|
2022-09-23 14:36:11 +00:00
|
|
|
)
|
2022-09-24 15:12:23 +00:00
|
|
|
OR file.symlink != 0
|
2022-10-13 18:59:32 +00:00
|
|
|
OR basename LIKE '.%'
|
|
|
|
OR basename LIKE '%.sql%'
|
|
|
|
OR basename LIKE '%Chrome%'
|
|
|
|
OR basename LIKE '%Extension%'
|
|
|
|
OR basename LIKE '%enforce%'
|
|
|
|
OR basename LIKE '%hidden%'
|
|
|
|
OR basename LIKE '%Installer%'
|
|
|
|
OR basename LIKE '%mono%'
|
|
|
|
OR basename LIKE '%secret%'
|
|
|
|
OR basename LIKE '%sql%'
|
|
|
|
OR basename LIKE '%guard%'
|
|
|
|
OR basename LIKE 'cg%'
|
2022-09-24 15:12:23 +00:00
|
|
|
) -- exceptions go here
|
|
|
|
AND basename NOT IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'.',
|
2023-01-26 21:30:14 +00:00
|
|
|
'..',
|
2023-09-01 21:34:36 +00:00
|
|
|
'.CFUserTextEncoding',
|
|
|
|
'.DS_Store',
|
|
|
|
'.TemporaryItems',
|
|
|
|
'.Trashes',
|
|
|
|
'.VolumeIcon.icns',
|
|
|
|
'._.TemporaryItems',
|
|
|
|
'._.Trashes',
|
2023-01-26 21:30:14 +00:00
|
|
|
'._.apdisk',
|
|
|
|
'._AUTORUN.INF',
|
2023-09-01 21:34:36 +00:00
|
|
|
'._Id.txt',
|
2023-09-01 21:09:47 +00:00
|
|
|
'.actrc',
|
|
|
|
'.angular-config.json',
|
2023-01-26 21:30:14 +00:00
|
|
|
'.apdisk',
|
2022-10-13 18:59:32 +00:00
|
|
|
'.background',
|
2023-03-21 18:07:06 +00:00
|
|
|
'.background.png',
|
2023-09-01 21:09:47 +00:00
|
|
|
'.background.tiff',
|
2023-03-14 23:00:44 +00:00
|
|
|
'.bash_history',
|
|
|
|
'.bashrc',
|
2023-09-01 21:09:47 +00:00
|
|
|
'.dbshell',
|
|
|
|
'.disk_label',
|
2023-01-26 21:30:14 +00:00
|
|
|
'.disk_label_2x',
|
2022-10-13 18:59:32 +00:00
|
|
|
'.file',
|
2023-01-26 21:30:14 +00:00
|
|
|
'.file-revisions-by-id',
|
2023-09-01 21:09:47 +00:00
|
|
|
'.flyrc',
|
|
|
|
'.gitconfig',
|
2023-01-26 21:30:14 +00:00
|
|
|
'.iotest',
|
2023-09-01 21:09:47 +00:00
|
|
|
'.keystone_install',
|
|
|
|
'.lesshst',
|
2022-10-13 18:59:32 +00:00
|
|
|
'.metadata_never_index_unless_rootfs',
|
2023-09-01 21:09:47 +00:00
|
|
|
'.mysql_history',
|
|
|
|
'.pdfbox.cache',
|
2022-10-13 18:59:32 +00:00
|
|
|
'.shortcut-targets-by-id',
|
|
|
|
'.vol',
|
2023-09-01 21:34:36 +00:00
|
|
|
'.zsh_history',
|
|
|
|
'KBFS_NOT_RUNNING',
|
|
|
|
'LogiPresentation Installer.app',
|
|
|
|
'Seagate Dashboard Installer.exe',
|
|
|
|
'UFRII_LT_LIPS_LX_Installer.pkg',
|
|
|
|
'pve-installer.squashfs'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
|
|
|
AND authority NOT IN (
|
2023-08-15 22:13:06 +00:00
|
|
|
'Developer ID Application: Adobe Inc. (JQ525L2MZD)',
|
|
|
|
'Developer ID Application: BlueStack Systems, Inc. (QX5T8D6EDU)',
|
2023-03-06 20:11:11 +00:00
|
|
|
'Developer ID Application: Canon Inc. (XE2XNRRXZ5)',
|
2023-06-01 15:52:20 +00:00
|
|
|
'Developer ID Application: Dropbox, Inc. (G7HH3F8CAK)',
|
2023-08-15 22:13:06 +00:00
|
|
|
'Developer ID Application: Google LLC (EQHXZ8M8AV)',
|
|
|
|
'Developer ID Application: Logitech Inc. (QED4VVPZWA)'
|
2022-09-24 15:12:23 +00:00
|
|
|
) -- Unsigned programs here
|
|
|
|
AND trimpath NOT IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'/Volumes/Google Chrome/.keystone_install',
|
|
|
|
'/Volumes/Google Chrome Canary/.keystone_install',
|
2023-06-07 13:55:17 +00:00
|
|
|
'/Volumes/macFUSE/Install macFUSE.pkg',
|
|
|
|
'/Volumes/macFUSE/.engine_install',
|
2023-03-21 18:07:06 +00:00
|
|
|
'/Volumes/Garmin Express/Install Garmin Express.pkg',
|
2023-03-14 23:00:44 +00:00
|
|
|
'/Volumes/PMHOME_3601DL/PMH_INST.pkg',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/Volumes/Jabra Direct Setup/JabraDirectSetup.pkg'
|
2023-02-09 01:06:26 +00:00
|
|
|
)
|
2023-02-09 22:01:29 +00:00
|
|
|
AND trimpath NOT LIKE '/Volumes/JDK %/JDK %.pkg'
|
2023-10-02 15:35:11 +00:00
|
|
|
AND trimpath NOT LIKE '/Volumes/Splunk %/Install Splunk'
|
2023-06-01 15:52:20 +00:00
|
|
|
AND trimpath NOT LIKE '/Volumes/Google Earth Pro%/Install Google Earth Pro%.pkg'
|
2023-02-15 01:16:02 +00:00
|
|
|
AND trimpath NOT LIKE '/Volumes/mysql-shell-%/mysql-shell-%.pkg'
|
2023-09-01 21:09:47 +00:00
|
|
|
AND trimpath NOT LIKE '/Volumes/Blackmagic DaVinci Resolve/Install Resolve %.pkg'
|
2023-03-30 22:44:01 +00:00
|
|
|
AND magic.data NOT LIKE 'ASCII text%'
|
2023-04-17 20:20:35 +00:00
|
|
|
AND NOT (
|
|
|
|
magic.data = 'AppleDouble encoded Macintosh file'
|
|
|
|
AND basename LIKE '._%'
|
2023-05-08 17:20:47 +00:00
|
|
|
)
|