Boot or Logon Initialization Scripts: RC Scripts

Adversaries may establish persistence by modifying RC scripts which are executed during a Unix-like system’s startup. These files allow system administrators to map and start custom services at startup for different run levels. RC scripts require root privileges to modify.

Adversaries can establish persistence by adding a malicious binary path or shell commands to rc.local, rc.common, and other RC scripts specific to the Unix-like distribution.[1][2] Upon reboot, the system executes the script's contents as root, resulting in persistence.

Adversary abuse of RC scripts is especially effective for lightweight Unix-like distributions using the root user as default, such as IoT or embedded systems.[3]

Several Unix-like systems have moved to Systemd and deprecated the use of RC scripts. This is now a deprecated mechanism in macOS in favor of Launchd. [4][5] This technique can be used on Mac OS X Panther v10.3 and earlier versions which still execute the RC scripts.[6] To maintain backwards compatibility some systems, such as Ubuntu, will execute the RC scripts if they exist with the correct file permissions.[7]

ID: T1037.004
Sub-technique of:  T1037
Platforms: Linux, Network, macOS
Permissions Required: root
Version: 2.1
Created: 15 January 2020
Last Modified: 16 April 2024

Procedure Examples

ID Name Description
G0016 APT29

APT29 has installed a run command on a compromised system to enable malware execution on system startup.[8]

S0687 Cyclops Blink

Cyclops Blink has the ability to execute on device startup, using a modified RC script named S51armled.[9]

S0690 Green Lambert

Green Lambert can add init.d and rc.d files in the /etc folder to establish persistence.[10][11]

S0394 HiddenWasp

HiddenWasp installs reboot persistence by adding itself to /etc/rc.local.[2]

S0278 iKitten

iKitten adds an entry to the rc.common file for persistence.[12]

Mitigations

ID Mitigation Description
M1022 Restrict File and Directory Permissions

Limit privileges of user accounts so only authorized users can edit the rc.common file.

Detection

ID Data Source Data Component Detects
DS0017 Command Command Execution

Monitor executed commands and arguments resulting from RC scripts for unusual or unknown applications or behavior

DS0022 File File Creation

Monitor for newly constructed /etc/rc.local file

File Modification

Monitor for changes made to files for unexpected modifications to RC scripts in the /etc/ directory

DS0009 Process Process Creation

Monitor for newly constructed processes and/or command-lines that execute /etc/rc.local if present.

References