# T1547 - Boot or Logon Autostart Execution ## Description from ATT&CK > Adversaries may configure system settings to automatically execute a program during system boot or logon to maintain persistence or gain higher-level privileges on compromised systems. Operating systems may have mechanisms for automatically running a program on system boot or account logon.(Citation: Microsoft Run Key)(Citation: MSDN Authentication Packages)(Citation: Microsoft TimeProvider)(Citation: Cylance Reg Persistence Sept 2013)(Citation: Linux Kernel Programming) These mechanisms may include automatically executing programs that are placed in specially designated directories or are referenced by repositories that store configuration information, such as the Windows Registry. An adversary may achieve the same goal by modifying or extending features of the kernel. > > Since some boot or logon autostart programs run with higher privileges, an adversary may leverage these to elevate privileges. [Source](https://attack.mitre.org/techniques/T1547) ## Atomic Tests - [Atomic Test #1: Add a driver](#atomic-test-1-add-a-driver) - [Atomic Test #2: Driver Installation Using pnputil.exe](#atomic-test-2-driver-installation-using-pnputilexe) - [Atomic Test #3: Leverage Virtual Channels to execute custom DLL during successful RDP session](#atomic-test-3-leverage-virtual-channels-to-execute-custom-dll-during-successful-rdp-session) ### Atomic Test #1: Add a driver Install a driver via pnputil.exe lolbin **Supported Platforms:** Windows **auto_generated_guid:** `cb01b3da-b0e7-4e24-bf6d-de5223526785` #### Inputs | Name | Description | Type | Default Value | |------|-------------|------|---------------| | driver_inf | A built-in, already installed windows driver inf | path | C:\Windows\INF\usbstor.inf| #### Attack Commands: Run with `command_prompt`! ```cmd pnputil.exe /add-driver "#{driver_inf}" ``` ### Atomic Test #2: Driver Installation Using pnputil.exe pnputil.exe is a native command-line utility in Windows to install drivers, this can be abused by to install malicious drivers. Ref: https://lolbas-project.github.io/lolbas/Binaries/Pnputil/ **Supported Platforms:** Windows **auto_generated_guid:** `5cb0b071-8a5a-412f-839d-116beb2ed9f7` #### Inputs | Name | Description | Type | Default Value | |------|-------------|------|---------------| | driver_path | Enter the driver file path to install (Default is used built-in windows driver - acpipmi.inf) | path | C:\Windows\INF\acpipmi.inf| #### Attack Commands: Run with `powershell`! ```powershell pnputil.exe -i -a #{driver_path} ``` ### Atomic Test #3: Leverage Virtual Channels to execute custom DLL during successful RDP session Virtual Channels can be leveraged to alter RDP behavior using dedicated Addins.The mechanism is implemented using DLLs which can be executed during RDP session automatically. The DLLs are loaded in the host system only after successful connection is established with the remote system. Once the test is run, amsi.dll will be loaded on the host system during successful RDP session. Blog :https://learn.microsoft.com/en-us/windows/win32/termserv/terminal-services-virtual-channels?redirectedfrom=MSDN **Supported Platforms:** Windows **auto_generated_guid:** `fdd45306-74f6-4ade-9a97-0a4895961228` #### Inputs | Name | Description | Type | Default Value | |------|-------------|------|---------------| | Subkey_Added | New Sub key added in the registry path | String | Malware| | dll_inf | custom DLL to be executed | Path | C:\Windows\System32\amsi.dll| #### Attack Commands: Run with `command_prompt`! Elevation Required (e.g. root or admin) ```cmd reg add "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\Addins\#{Subkey_Added}" /v Name /t REG_SZ /d "#{dll_inf}" /f ``` #### Cleanup Commands ```cmd reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\Addins\#{Subkey_Added}" /f ```