Re-opened Applications T1547.007
- Tactics
- Persistence, Privilege Escalation
- Platform
- macOS
- Version
- 1.2
- Created
- 24 January 2020
- Last modified
- 24 October 2025
Adversaries may modify plist files to automatically run an application when a user logs in. When a user logs out or restarts via the macOS Graphical User Interface (GUI), a prompt is provided to the user with a checkbox to "Reopen windows when logging back in".[1] When selected, all applications currently open are added to a property list file named com.apple.loginwindow.[UUID].plist within the ~/Library/Preferences/ByHost directory.[2][3] Applications listed in this file are automatically reopened upon the user’s next logon.
Offense vs defense T1547.007
Is defensive coverage keeping up with adversary use? Eight counts, each ranked against all 697 ATT&CK techniques. Attack sits left, defense right, so a shape leaning left means adversaries are better documented here than defenders are equipped. Hover any spoke for its percentile and the share of techniques that have more. The timeline below shows when each side arrived.
Re-opened Applications detection strategy DET0125
MITRE names one behaviour worth catching for this technique and breaks it into 1 analytic, one per platform. Each carries the log sources it needs and the fields you tune per environment.
Detect persistence via reopened application plist modification (macOS)
AN0349 · macOS
Unusual modification or creation of loginwindow-related plist files in '~/Library/Preferences/ByHost' correlated with unauthorized application paths and execution upon login.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | macos:unifiedlog | Execution of process launched via loginwindow session restore |
| File MetadataDC0059 | macos:endpointsecurity | es_event_file_rename_t or es_event_file_write_t |
| File ModificationDC0061 | fs:filesystem | Modification or creation of files matching 'com.apple.loginwindow.*.plist' in ~/Library/Preferences/ByHost |
| Logon Session MetadataDC0088 | macos:unifiedlog | LoginWindow context with associated PID linked to reopened plist paths |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| UserContext | Restrict to targeted users or unexpected users writing to plist |
| FilePathPattern | Allow tuning for alternative persistence paths or directory redirection |
| TimeWindow | Correlate plist write and process execution within logon window |
| BinaryAnomalyScore | Optional scoring of launched binary based on code signing, entropy, and known safe apps |
This feature can be disabled entirely with the following terminal command: defaults write -g ApplePersistence -bool no.
Holding the Shift key while logging in prevents apps from opening automatically.
| # | Test | Platform | Executor | Elevation | Prereqs | Cleanup | Ref | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01 | Copy in loginwindow.plist for Re-Opened Applications | macos | sh | — | — | Yes | ||||||||||||||
Copy in new loginwindow.plist to launch Calculator. Input arguments
Attack command cp #{calc_plist_path} ~/Library/Preferences/ByHost/com.apple.loginwindow.plist
Cleanup command rm -f ~/Library/Preferences/ByHost/com.apple.loginwindow.plist GUIDfb7b6c46-c9ee-4766-b170-ad81dfa77807 | ||||||||||||||||||||
| 02 | Re-Opened Applications using LoginHook | macos | sh | Required | — | Yes | ||||||||||||||
Mac Defaults Reference Input arguments
Attack command sudo defaults write com.apple.loginwindow LoginHook #{script}
Cleanup command sudo defaults delete com.apple.loginwindow LoginHook GUIDf35f3d47-a238-44b4-ab25-d1030fc9cabd | ||||||||||||||||||||
| 03 | Append to existing loginwindow for Re-Opened Applications | macos | sh | — | 1 | Yes | ||||||||||||||
Appends an entry to launch Calculator hidden loginwindow.*.plist for next login. Note that the change may not result in the added Calculator program launching on next user login. It may depend on which version of macOS you are running on. Input arguments
Attack command FILE=`find ~/Library/Preferences/ByHost/com.apple.loginwindow.*.plist -type f | head -1`
if [ -z "${FILE}" ] ; then echo "No loginwindow plist file found" && exit 1 ; fi
echo save backup copy to /tmp/
cp ${FILE} /tmp/t1547007_loginwindow-backup.plist
echo before
plutil -p ${FILE}
echo overwriting...
#{exe_path} ${FILE} && echo after && plutil -p ${FILE}
Cleanup command rm -f #{exe_path}
# revert to backup copy
FILE=`find ~/Library/Preferences/ByHost/com.apple.loginwindow.*.plist -type f | head -1`
if [ -z "${FILE}" ] ; then
exit 0
fi
mv /tmp/t1547007_loginwindow-backup.plist ${FILE}
Prerequisite compile C program Check if [ -f "#{exe_path}" ]; then exit 0 ; else exit 1; fi
Satisfy cc #{objc_source_path} -o #{exe_path} -framework Cocoa
GUIDd2a349da-1c65-45af-888d-508276d6b821 | ||||||||||||||||||||
Tests from Atomic Red Team (MIT licence) · technique definition