# T1547.001 - Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder

## Description from ATT&CK

> Adversaries may achieve persistence by adding a program to a startup folder or referencing it with a Registry run key. Adding an entry to the "run keys" in the Registry or startup folder will cause the program referenced to be executed when a user logs in.(Citation: Microsoft Run Key) These programs will be executed under the context of the user and will have the account's associated permissions level.
> 
> The following run keys are created by default on Windows systems:
> 
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run</code>
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce</code>
> * <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run</code>
> * <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce</code>
> 
> Run keys may exist under multiple hives.(Citation: Microsoft Wow6432Node 2018)(Citation: Malwarebytes Wow6432Node 2016) The <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx</code> is also available but is not created by default on Windows Vista and newer. Registry run key entries can reference programs directly or list them as a dependency.(Citation: Microsoft Run Key) For example, it is possible to load a DLL at logon using a "Depend" key with RunOnceEx: <code>reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001\Depend /v 1 /d "C:\temp\evil[.]dll"</code> (Citation: Oddvar Moe RunOnceEx Mar 2018)
> 
> Placing a program within a startup folder will also cause that program to execute when a user logs in. There is a startup folder location for individual user accounts as well as a system-wide startup folder that will be checked regardless of which user account logs in. The startup folder path for the current user is <code>C:\Users\\[Username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup</code>. The startup folder path for all users is <code>C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp</code>.
> 
> The following Registry keys can be used to set startup folder items for persistence:
> 
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</code>
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</code>
> * <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</code>
> * <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</code>
> 
> The following Registry keys can control automatic startup of services during boot:
> 
> * <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce</code>
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce</code>
> * <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices</code>
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices</code>
> 
> Using policy settings to specify startup programs creates corresponding values in either of two Registry keys:
> 
> * <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run</code>
> * <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run</code>
> 
> Programs listed in the load value of the registry key <code>HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows</code> run automatically for the currently logged-on user.
> 
> By default, the multistring <code>BootExecute</code> value of the registry key <code>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager</code> is set to <code>autocheck autochk *</code>. This value causes Windows, at startup, to check the file-system integrity of the hard disks if the system has been shut down abnormally. Adversaries can add other programs or processes to this registry value which will automatically launch at boot.
> 
> Adversaries can use these configuration locations to execute malware, such as remote access tools, to maintain persistence through system reboots. Adversaries may also use [Masquerading](https://attack.mitre.org/techniques/T1036) to make the Registry entries look as if they are associated with legitimate programs.

[Source](https://attack.mitre.org/techniques/T1547/001)

## Atomic Tests

- [Atomic Test #1: Reg Key Run](#atomic-test-1-reg-key-run)
- [Atomic Test #2: Reg Key RunOnce](#atomic-test-2-reg-key-runonce)
- [Atomic Test #3: PowerShell Registry RunOnce](#atomic-test-3-powershell-registry-runonce)
- [Atomic Test #4: Suspicious vbs file run from startup Folder](#atomic-test-4-suspicious-vbs-file-run-from-startup-folder)
- [Atomic Test #5: Suspicious jse file run from startup Folder](#atomic-test-5-suspicious-jse-file-run-from-startup-folder)
- [Atomic Test #6: Suspicious bat file run from startup Folder](#atomic-test-6-suspicious-bat-file-run-from-startup-folder)
- [Atomic Test #7: Add Executable Shortcut Link to User Startup Folder](#atomic-test-7-add-executable-shortcut-link-to-user-startup-folder)
- [Atomic Test #8: Add persistance via Recycle bin](#atomic-test-8-add-persistance-via-recycle-bin)
- [Atomic Test #9: SystemBC Malware-as-a-Service Registry](#atomic-test-9-systembc-malware-as-a-service-registry)
- [Atomic Test #10: Change Startup Folder - HKLM Modify User Shell Folders Common Startup Value](#atomic-test-10-change-startup-folder---hklm-modify-user-shell-folders-common-startup-value)
- [Atomic Test #11: Change Startup Folder - HKCU Modify User Shell Folders Startup Value](#atomic-test-11-change-startup-folder---hkcu-modify-user-shell-folders-startup-value)
- [Atomic Test #12: HKCU - Policy Settings Explorer Run Key](#atomic-test-12-hkcu---policy-settings-explorer-run-key)
- [Atomic Test #13: HKLM - Policy Settings Explorer Run Key](#atomic-test-13-hklm---policy-settings-explorer-run-key)
- [Atomic Test #14: HKLM - Append Command to Winlogon Userinit KEY Value](#atomic-test-14-hklm---append-command-to-winlogon-userinit-key-value)
- [Atomic Test #15: HKLM - Modify default System Shell - Winlogon Shell KEY Value ](#atomic-test-15-hklm---modify-default-system-shell---winlogon-shell-key-value-)
- [Atomic Test #16: secedit used to create a Run key in the HKLM Hive](#atomic-test-16-secedit-used-to-create-a-run-key-in-the-hklm-hive)
- [Atomic Test #17: Modify BootExecute Value](#atomic-test-17-modify-bootexecute-value)
- [Atomic Test #18: Allowing custom application to execute during new RDP logon session](#atomic-test-18-allowing-custom-application-to-execute-during-new-rdp-logon-session)
- [Atomic Test #19: Creating Boot Verification Program Key for application execution during successful boot](#atomic-test-19-creating-boot-verification-program-key-for-application-execution-during-successful-boot)
- [Atomic Test #20: Add persistence via Windows Context Menu](#atomic-test-20-add-