macOS provides a mix of standard Unix tools and Apple-specific utilities. This reference covers the most useful commands for security assessments and post-exploitation on macOS systems.
# Basic system infodateuptimew # Logged-in userswhoamiuname -asystem_profiler SPSoftwareDataType # OS info# Hardware and resourcessystem_profiler SPHardwareDataType # Hardware infosysctl -a # Kernel configurationdiskutil list # Connected drivesdf -h # Disk usage# Services and taskslaunchctl list # List all LaunchDaemon/LaunchAgent servicesatq # List "at" tasks for current usernettop # Network usage by process (top-style)
# Find files containing a specific word (Spotlight)mdfind password# Find files by name containing a wordmdfind -name password# Open app hidden (useful for stealth)open -a <Application Name> --hideopen some.doc -a TextEdit
# All running services for a specific user domainlaunchctl print gui/<users_UID># All running services under rootlaunchctl print system# Details for a specific agentlaunchctl print gui/<user_UID>/com.company.launchagent.label
brew list # List installed packagesbrew search <text> # Search for a packagebrew info <formula> # Info about a packagebrew install <formula>brew uninstall <formula>brew cleanup # Remove older versions
Some macOS malware and stealers use system_profiler to detect virtual machine environments and abort execution to evade sandboxes:
# Common VM detection snippet seen in macOS stealersif system_profiler SPHardwareDataType SPDisplaysDataType | grep -Eiq 'qemu|kvm|vmware|virtualbox'; then exit 100fi
Malware may exit with a specific exit code (e.g., 100) to signal sandbox detection to the operator, helping distinguish sandbox runs from real victim execution.
# Check SIP statuscsrutil status# Check Gatekeeper statusspctl --status# List loaded kernel extensionskextstat | grep -v com.apple# Check running processes with their full pathsps aux | grep -v "^root" | awk '{print $11}' | sort -u# List all Launch Daemons (system-wide persistence)ls /Library/LaunchDaemons/ls /System/Library/LaunchDaemons/# List Launch Agents (user-level persistence)ls ~/Library/LaunchAgents/ls /Library/LaunchAgents/ls /System/Library/LaunchAgents/# Check for login itemsosascript -e 'tell application "System Events" to get the name of every login item'# FileVault statusfdesetup status