Windows allows logon scripts to be run whenever a specific user or group of users log into a system.  The scripts can be used to perform administrative functions, which may often execute other programs or send information to an internal logging server.
If adversaries can access these scripts, they may insert additional code into the logon script to execute their tools when a user logs in. This code can allow them to maintain persistence on a single system, if it is a local script, or to move laterally within a network, if the script is stored on a central server and pushed to many systems. Depending on the access configuration of the logon scripts, either local credentials or an administrator account may be necessary.
Mac allows login and logoff hooks to be run as root whenever a specific user logs into or out of a system. A login hook tells Mac OS X to execute a certain script when a user logs in, but unlike startup items, a login hook executes as root . There can only be one login hook at a time though. If adversaries can access these scripts, they can insert additional code to the script to execute their tools when a user logs in.
An APT28 loader Trojan adds the Registry key
|Cobalt Group||Cobalt Group has added persistence by registering the file name for the next stage malware under UserInitMprLogonScript. |
|JHUHUGIT||JHUHUGIT has registered a Windows shell script under the Registry key HKCU\Environment\UserInitMprLogonScript to establish persistence.  |
|Zebrocy||Zebrocy performs persistence via adding a Registry key with a logon script. |
|Restrict File and Directory Permissions||Restrict write access to logon scripts to specific administrators.|
Monitor logon scripts for unusual access by abnormal users or at abnormal times. Look for files added or modified by unusual accounts outside of normal administration duties.
- Microsoft. (2005, January 21). Creating logon scripts. Retrieved April 27, 2016.
- Apple. (2011, June 1). Mac OS X: Creating a login hook. Retrieved July 17, 2017.
- ESET. (2016, October). En Route with Sednit - Part 1: Approaching the Target. Retrieved November 8, 2016.
- Mercer, W., et al. (2017, October 22). "Cyber Conflict" Decoy Document Used in Real Cyber Conflict. Retrieved November 2, 2018.