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.
Placing a program within a startup folder will 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:
* C:\Users[Username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
The startup folder path for all users is:
* C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
The following run keys are created by default on Windows systems:
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
The HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx 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 RunOnceEx APR 2018) For example, it is possible to load a DLL at logon using a "Depend" key with RunOnceEx: reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001\Depend /v 1 /d "C:\temp\evil[.]dll" (Citation: Oddvar Moe RunOnceEx Mar 2018)
The following Registry keys can be used to set startup folder items for persistence:
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
* HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
* HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
The following Registry keys can control automatic startup of services during boot:
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices
Using policy settings to specify startup programs creates corresponding values in either of two Registry keys:
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
* HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
The Winlogon key controls actions that occur when a user logs on to a computer running Windows 7. Most of these actions are under the control of the operating system, but you can also add custom actions here. The HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit and HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell subkeys can automatically launch programs.
Programs listed in the load value of the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows run when any user logs on.
By default, the multistring BootExecute value of the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager is set to autocheck autochk *. 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 to make the Registry entries look as if they are associated with legitimate programs.
T1060は、Windowsが起動またはユーザーがログインした際にプログラムを自動実行する「Runレジストリキー」や「スタートアップフォルダ」にマルウェアを登録し、「永続化(Persistence)」を達成します。
この手法で攻撃者は、「PCの起動やユーザーのログインという日常動作をトリガーにした、マルウェアの確実な自動再実行」を実現します。
永続化:
端末がシャットダウンや再起動されても、次回起動時に自動的に裏でマルウェアが動き出す環境を作ります。
一般ユーザー権限での潜伏:
管理者権限(特権)がなくても、現在ログインしているユーザー専用の自動実行領域を書き換えるだけでよいため、侵入初期の段階から極めて容易に実行できます。
攻撃者は、OSの標準的な自動起動の仕組みにマルウェアのパスを滑り込ませます。主に「レジストリ」と「フォルダ」の2つのルートがあります。
Windowsには、ログイン時に指定されたプログラムを動かすレジストリキーが存在します。
ユーザー権限で可能:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run (または RunOnce)
管理者権限が必要:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run (または RunOnce)
攻撃者はここに新しい値(例:UpdateCheck などの無害を装った名前)を作成し、データ部分にマルウェア(.exe や スクリプト)のパスを書き込みます。
ログイン時にフォルダ内のファイルを全実行する「スタートアップフォルダ」を狙います。
ユーザー権限:
C:\Users\<ユーザー名>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
管理者権限:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
攻撃者はこのフォルダ内に、マルウェア本体、またはマルウェアを呼び出すショートカットファイル(.lnk)を配置します。
ユーザーが次回システムにログインした瞬間、OSがこれらの場所を順番に読み込み、マルウェアが自動的に起動します。
「書き込みの監視」と「可視化」が最も効果的です。
レジストリ・フォルダの監視:
主要な Run キーやスタートアップフォルダに対する新しい値の追加・ファイルの作成を、EDRやSysmon(Event ID 11/12/13)等で常時監視し、アラート化します。
Sysinternals「Autoruns」の活用:
マイクロソフトが提供する公式ツール Autoruns を使用すると、これらの自動起動設定を網羅的に一覧表示できます。定期的にチェックし、身に覚えのないプログラムが登録されていないか確認します。
一般ユーザー権限の制限:
HKLM 側や全ユーザー共通のスタートアップフォルダへの書き込み権限を厳格に制限します(デフォルトで制限されていますが、設定ミスがないか監査します)。
攻撃者にとっての「一等地」:
シンプルで確実なため、高度なAPT攻撃グループから、一般的なランサムウェア、ネットバンキングを狙うバンキングトロジャンまで、あらゆるマルウェアが最初に狙う「超定番」の場所です。
カモフラージュ:
攻撃者は OneDrive Update や SecurityHealthSystray など、既存の正規プログラムに酷似した名前をつけて登録するため、目視での確認時は「名前」ではなく「実行ファイルのフルパス」が異常な場所(AppData\Local\Temp など)を指していないかを見る必要があります。
CWE-15: External Control of System or Configuration Setting:
システムの自動起動設定(レジストリやフォルダ)を外部から不正に操作されてしまう不備。
CWE-73: External Control of File Name or Path:
起動されるプログラムのパスが攻撃者の支配下に入ってしまう問題。
特定の脆弱性を突くものではなく、OSの標準仕様の悪用であるため、数え切れないほどのマルウェアが利用しています。
Emotet / TrickBot:
侵入した端末で活動を維持するため、ユーザー環境の Run レジストリキーにランダムな文字列、または正規を装った名前で自身を登録する手法を標準搭載していました。
多くのランサムウェア:
端末のファイルを暗号化した後、再起動されても身代金要求画面(ランサムノート)が自動でデスクトップにポップアップ表示されるよう、スタートアップフォルダにショートカットを仕込むケースが多々見られます。
セキュリティ運用の現場では、「不審なプロセスが Run レジストリを書き換えた」 という検知は高確率で黒(インシデント)と判断できます。特に、Office製品(Word, Excel)やPowerShellからこのレジストリへの書き込みが発生した場合は、マクロなどを起点とした攻撃が進行中である可能性が極めて高いです。
この攻撃手法を利用する脅威アクターは登録されていません。