osquery-defense-kit/detection/initial_access/unexpected-diskimage-source...

273 lines
6.5 KiB
MySQL
Raw Normal View History

-- Surface ISO/DMG disk images that were downloaded from unexpected places
--
-- 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)
-- * https://unit42.paloaltonetworks.com/chromeloader-malware/
--
-- false positives:
-- * disk images downloaded from a location not in the exception list
--
-- platform: darwin
-- tags: persistent filesystem spotlight often
SELECT
file.path,
file.size,
datetime(file.btime, 'unixepoch') AS file_created,
magic.data,
hash.sha256,
signature.identifier,
signature.authority,
ea.value AS url,
REGEX_MATCH (ea.value, '/[\w_-]+\.([\w\._-]+)[:/]', 1) AS domain,
REGEX_MATCH (ea.value, '/([\w_-]+\.[\w\._-]+)[:/]', 1) AS host
FROM
mdfind
LEFT JOIN file ON mdfind.path = file.path
LEFT JOIN hash ON mdfind.path = hash.path
LEFT JOIN extended_attributes ea ON mdfind.path = ea.path
LEFT JOIN magic ON mdfind.path = magic.path
LEFT JOIN signature ON mdfind.path = signature.path
WHERE
(
mdfind.query = "kMDItemWhereFroms != '' && kMDItemFSName == '*.iso'"
OR mdfind.query = "kMDItemWhereFroms != '' && kMDItemFSName == '*.dmg'"
2023-01-13 18:47:02 +00:00
OR mdfind.query = "kMDItemWhereFroms != '' && kMDItemFSName == '*.pkg'"
)
AND ea.key = 'where_from'
AND file.btime > (strftime('%s', 'now') -86400)
AND domain NOT IN (
'adobe.com',
'akmedia.digidesign.com',
'alfredapp.com',
2023-09-01 21:09:47 +00:00
'amazon.com',
'android.com',
'ankiweb.net',
'apple.com',
'arc.net',
'asana.com',
'astutegraphics.com',
'backblazeb2.com',
'balena.io',
'balsamiq.com',
2024-08-27 22:40:43 +00:00
'bblmw.com',
2023-09-01 21:09:47 +00:00
'bluestacks.com',
'boxcdn.net',
2024-08-27 22:40:43 +00:00
'box.com',
'brave.com',
'byfly.by',
'canon.co.uk',
'cdn.mozilla.net',
'charlesproxy.com',
'chatgpt.com',
'cloudfront.net',
'cron.com',
'csclub.uwaterloo.ca',
'curseforge.com',
2024-08-27 22:40:43 +00:00
'c-wss.com',
2023-09-01 21:09:47 +00:00
'descript.com',
'desktop.evernote.com',
'digidesign.com',
2023-08-15 22:13:06 +00:00
'discordapp.net',
2024-08-27 22:40:43 +00:00
'discord.com',
'dl.meitu.com',
2023-09-01 21:09:47 +00:00
'dl.sourceforge.net',
'docker.com',
'dogado.de',
'download.prss.microsoft.com',
'duckduckgo.com',
'eclipse.org',
2024-08-27 22:40:43 +00:00
'emeet.com',
'epson.com',
'eventideaudio.com',
'fcix.net',
'figma.com',
'foundry.com',
'gaomon.net',
'getutm.app',
'gimp.org',
'github.io',
'githubusercontent.com',
'google.ca',
'google.com',
'grammarly.com',
'imazing.com',
'integodownload.com',
'irccloud.com',
'jetbrains.com',
'kagi.com',
'kolide.com',
'libreoffice.org',
'live.com',
'logitech.com',
'loom.com',
'macbartender.com',
'macroplant.com',
'maxon.net',
'microsoft.com',
'minecraft.net',
'mirrorservice.org',
'mm.cfix.net',
'mm.fcix.net',
'mojang.com',
'mozilla.org',
'mutedeck.com',
'mysql.com',
2023-08-15 22:13:06 +00:00
'notion.so',
2024-08-27 22:40:43 +00:00
'notion-static.com',
'ocf.berkeley.edu',
2024-09-23 15:10:05 +00:00
'odvdev.at',
'office.com',
'oobesaas.adobe.com',
2023-08-15 22:13:06 +00:00
'openra.net',
'oracle.com',
'osuosl.org',
'overwolf.com',
'pathofexile.com',
'perforce.com',
'poecdn.com',
'pqrs.org',
'proxmox.com',
'prusa3d.com',
'raspberrypi.com',
'redhat.com',
'remarkable.com',
'rewind.ai',
's3.amazonaws.com',
'securew2.com',
'signal.org',
'siliconmotion.com',
'skype.com',
'slack.com',
2024-08-27 22:40:43 +00:00
'slack-edge.com',
'stclairsoft.com',
'steampowered.com',
'synaptics.com',
'tableplus.com',
'teams.cdn.office.net',
'techsmith.com',
'tweaknews.eu',
'ubuntu.com',
'ultimaker.com',
'umd.edu',
'usa.canon.com',
'uubyte.com',
'vc.logitech.com',
'vimcal.com',
'virtualbox.org',
'viture.dev',
'vmware.com',
'warp.dev',
2023-01-13 20:24:18 +00:00
'webex.com',
'whatsapp.com',
'xtom.com',
'gitbutler.com',
'xx.fbcdn.net',
2024-03-29 12:07:01 +00:00
'yubico.com',
2024-08-27 22:40:43 +00:00
'zoo.dev',
2023-08-15 22:13:06 +00:00
'zoomgov.com',
2024-08-27 22:40:43 +00:00
'zoom.us',
'zsa.io'
)
2023-04-17 20:20:35 +00:00
-- NOTE: Do not put all of storage.googleapis.com or similarly generic hosts here
AND host NOT IN (
'adoptium.net',
'arc.net',
'asana.com',
'awscli.amazonaws.com',
'balsamiq.com',
'bearly.ai',
'blyt.net',
'brave.com',
'calibre-ebook.com',
'chatgpt.com',
'cron.com',
'discord.com',
'dl.discordapp.net',
'dl2.discordapp.net',
'dl.google.com',
'duckduckgo.com',
'dygma.com',
'emacsformacosx.com',
'epson.com',
'evernote.com',
'multipass.run',
'fbcdn.net',
'figma.com',
'flipperzero.one',
'fnord.com',
'getkap.co',
'github.com',
'gitbutler.com',
'go.dev',
'imazing.com',
'kittycad.io',
'krisp.ai',
'macroplant.com',
'mail.google.com',
'manual.canon',
'manytricks.com',
'maxon.net',
'mimestream.com',
'mnvoip.mm.fcix.net',
'mutedeck.com',
'obdev.at',
'obsidian.md',
'obsproject.com',
'opalcamera.com',
'openai.com',
'persistent.oaistatic.com',
'portswigger-cdn.net',
2023-02-24 21:30:17 +00:00
'posit.co',
'presenting.app',
'proton.me',
'rancherdesktop.io',
2023-02-24 21:30:17 +00:00
'rectangleapp.com',
's3.amazonaws.com',
'scribehow.com',
'shottr.cc',
'sipapp.fra1.digitaloceanspaces.com',
'sipapp.io',
'sourceforge.net',
'sourcegraph.com',
'stclairsoft.s3.amazonaws.com',
'store.steampowered.com',
'superkey.app',
'superhuman.com',
'tableplus.com',
'textexpander.com',
'tosmediaserver.schwab.com',
'transmissionbt.com',
'ubuntu.com',
'ultimaker.com',
'universal-blue.discourse.group',
'warp-releases.storage.googleapis.com',
'wavebox.io',
'www.google.com',
2023-02-24 21:30:17 +00:00
'www.messenger.com',
'zed.dev',
'zoo.dev',
2023-02-24 21:30:17 +00:00
'zoom.us'
)
-- Yes, these are meant to be fairly broad.
AND host NOT LIKE 'download%'
AND host NOT LIKE 'cdn%'
AND host NOT LIKE '%.cdn.%.com'
AND host NOT LIKE '%.edu'
AND host NOT LIKE 'github-production-release-asset-%.s3.amazonaws.com'
AND host NOT LIKE '%.org'
AND host NOT LIKE 'dl.%'
AND host NOT LIKE 'dl-%'
AND host NOT LIKE 'mirror%'
AND host NOT LIKE 'driver.%'
AND host NOT LIKE 'support%'
AND host NOT LIKE 's3.%.amazonaws.com'
2024-08-27 22:40:43 +00:00
AND host NOT LIKe '%.s3.%.amazonaws.com'
AND host NOT LIKE 'software%'
AND host NOT LIKE 'www.google.%'
AND host NOT LIKE '%release%.storage.googleapis.com'
2023-04-17 20:20:35 +00:00
AND ea.value NOT LIKE 'https://storage.googleapis.com/copilot-mac-releases/%'
AND ea.value NOT LIKE 'https://storage.googleapis.com/kolide-k2-production-downloads-f414/%'
GROUP BY
ea.value