WHEN 04 • DATE • TIME • DURATION WHERE 03 • THE LOCATION OF ARTIFACTS WE WANT TO HUNT IN THE DATA WHAT 02 • THE ITEM WE WANT TO HUNT WHO 01 • USERNAME/ACCOUNT • HOSTNAME • IP/PORT The Hypothesis
// Example gscript template // Title: Launch Agent Persistence // Author: ahhh // Purpose: Drop a sample binary and a launch agent plist and persist it using Launch Agent // Gscript version: 1.0.0 // ATT&CK: https://attack.mitre.org/wiki/Technique/T1159 Yes No Idea No Go Hunt ! Create one!
Manage scripts and processes • Launch Daemons ◦ Run without a logged in user. ◦ No GUI interaction. ◦ stored: /System/Library/LaunchDaemons/ & /Library/LaunchDaemons/ 47 Hypothesis: Do we have any outlier Launch (Daemon|Agent)s running in our environment? If yes, what are they and are they needed?
logged in. ◦ GUI interaction. ◦ stored: /System/Library/LaunchAgents : /Library/LaunchAgents. : ~/Library/LaunchAgents folder. • Equivalent to runkeys and services on Windows 48
mechanism as a means of allowing dynamic loading of code into the kernel, without the need to recompile or relink. Because KEXTs provide both modularity and dynamic loadability, they are a natural choice for any relatively self-contained service that requires access to internal kernel interfaces -- [BADNESS!] -- https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/Extend/Extend.html • KMs are typically loaded into /lib/modules as extension .ko • Adversaries will check KMs before loading maliciousness to ensure compilation • Monitor for execution of kextload commands ◦ Correlate with known goods. https://attack.mitre.org/techniques/T1215/ Hypothesis: Do we have non standard kext loads in our environment? Are security tools being kext unloaded?
◦ Each launchd job is described by a different (plist) file ◦ Additional Key called: StartCalendarInterval • What is normal in your environment? ◦ Rack and stack -- find the outliers! Hypothesis: What scheduled jobs are running? What is different across the endpoint corpus? 50
deviate from normal, expected, and benign extensions. ◦ Process and network monitoring can be used to detect browsers communicating with a C2 server. However, this may prove to be a difficult way of initially detecting a malicious extension depending on the nature and volume of the traffic it generates. • Monitor for any new items written to the Registry or PE files written to disk. ◦ May correlate with browser extension installation. 51 https://attack.mitre.org/techniques/T1176/ Hypothesis: Do we have malicious or unknown browser extensions running?
follow-on external connect?) • Local port forwards • Why are you touching /etc/pam.d/sudo? ◦ SPOILER: TOUCH TO SUDO! (or badness) • Stomping history files • What is that running from /tmp/? • etc 52
from the internet the com.apple.quarantine attribute flag is set. ◦ At program execution this flag will prompt the user to allow or deny execution as the system acknowledges that the file was downloaded from the internet. • Files from external media or network shares do not set this flag! ◦ The Gatekeeper check is now bypassed ◦ hunt for this attribute being removed with ▪ xattr -r -d com.apple.quarantine /path/to/MyApp.app https://attack.mitre.org/techniques/T1144/ Hypothesis: Are Q flags being removed? Is yes, why? courtesy of osxdaily.com
Large scale, open source, indexed packet capture and search tool (FPC). 83 Shout-outs to: Andy Wick & Elyse Rinne & the entire moloch community! Thank you for your continuous contributions to Moloch!
https://lockboxx.blogspot.com/ The folks and community behind Osquery and Fleet Andy Wick & Elyse Rinne & the entire moloch community! Thank you for your continuous contributions to Moloch! DC562, Reverse Shell Corp (RSC) & Shellcon Community The Awesome Paranoids Team You, thanks for watching! The Paranoids FIRE Team #IRLife