Mac OSX TTPs
Enumeration
Gathering System Information Using IOPlatformExpertDevice
The ioreg command allows interaction with the I/O Kit registry, and the -c flag specifies the class of devices to list. The IOPlatformExpertDevice class provides information about the platform expert, which includes various system attributes. The -d flag specifies the depth of the search within the device tree.
ioreg -c IOPlatformExpertDevice -d 2Exploring Application Bundles
Applications on macOS are stored in the /Applications directory. Each application is bundled as a .app file, which is actually a directory with a specific layout. Key components of an application bundle include:
Info.plist: This file contains application-specific configuration, entitlements, tasks, and metadata.
MacOS: This directory contains the Mach-O executable.
Resources: This directory includes icons, fonts, and images used by the application.
# List Applications
ls /Applications
cd /Applications/Lens.app
ls -RBasic System Enumeration
Versions:
A basic script for gathering system information using osascript:
Environment Variables:
Home Folders:
Wireless Network:
Users
The three types of MacOS users are:
Local Users — Managed by the local OpenDirectory service, they aren’t connected in any way to the Active Directory
Network Users — Volatile Active Directory users who require a connection to the DC server to authenticate
Mobile Users — Active Directory users with a local backup for their credentials and files
Last Login
This command reads the contents of the login window preferences plist file. This can potentially expose information such as:
Automatic login settings
Display of usernames and other login screen options
Shutdown and restart privileges
Login hooks (scripts that run at login)
Passwords
The following one-liner which will dump credentials of all non-service accounts in Hashcat format -m 7100 (macOS PBKDF2-SHA512):
Safari History
Retrieve Safari history for user:
Safari Settings
To view all the settings for Safari, run:
Output example:
Keychains
[!TIP] The last command will prompt the user for their password each entry, even if root. This is extremely noisy
Network Services
SMB Shares
AFP Shares
SSH Scanning
Browse for all SSH services that are currently advertised on the local network
Network Service Scanning
dns-sd: Uses Bonjour to discover network services like AFP, SMB, and more.
System Profiler
It is an application created to gather detailed information about the Mac on which it is running.
Persistence
Extended Attributes
Extended attributes (EAs) on macOS can be used maliciously by attackers to hide data, evade detection, or persist malicious code, since EAs are not visible through typical file inspection methods
LaunchAgent Backdoors
LaunchAgent plists are a common target because they provide persistent access that survives reboots. Take this Grammarly helper, for example:
We could modify the ProgramArguments array to execute malicious commands instead of or alongside the legitimate Grammarly helper:
The RunAtLoad and KeepAlive keys make this particularly dangerous because the malicious payload would execute automatically at login and restart if it crashes. The MachServices configuration also provides inter-process communication capabilities that could be exploited.
Last updated