マルウェア
初期侵入マルウェア「Batloader」による最新の回避手段:難読化ツール「Pyarmor Pro」を利用
2023年6月、トレンドマイクロでは、前回報告した初期侵入マルウェア「Batloader」の回避技術がアップグレードされていることを確認しました。
2023年6月、トレンドマイクロでは、前回報告した初期侵入マルウェア「Batloader」の回避技術がアップグレードされていることを確認しました。具体的に、Batloaderの背後にいる攻撃グループ(トレンドマイクロでは「Water Minyades」と呼ぶ)は、不正なPythonスクリプトの本体を難読化する手段として、コマンドラインによる難読化ツール「Pyarmor」の通常版ではなく、より高性能な「Pyarmor Pro」を利用するようになりました。Pyarmorの通常版で難読化されたスクリプトについては、オープンソースのツールによって手動で元に戻すことも可能です。Water Minyadesは、2022年12月頃からPyarmorを使用してきました。これは、Pyarmor(通常版も含める)の難読化を解除できるアンチウイルス製品が少なく、攻撃者にとっては不正なスクリプトの検知回避に役立つためと考えられます。
以上の他にも、Batloaderはさまざまな検知回避の技術を利用します。例として、マルウェアの配布媒体に巨大なMSIファイルを用いることが挙げられます。例として、図1に示すBatloaderのMSIファイルは、111MBもの容量を有しています。
こうしたMSIファイルの中には、多くの場合、Batloaderのキルチェーンを開始するカスタム動作スクリプトが埋め込まれています。今回調査した検体については、「Python2.bat」という名前のバッチファイルを起動します。この際にMSIファイルが実行するコマンドは、下記の通りです。
”C:\Windows\System32\cmd.exe" /c C:\Users\\AppData\Local\Reo\App\Python\Python2.bat
図2に、ファイル「Python2.bat」の内容を示します。本ファイルは、起動するとまず、被害端末上での管理者権限が自身に付与されているかをチェックします。付与されていない場合、「getadmin.vbs」という名前のファイルを介してユーザアカウント制御(UAC:User Account Control)のポップアップを表示し、管理者権限を付与するように求めます。管理者権限が付与されると、今度は画面上に見せない形でWinRARのインストールを行い(「r.exe」に改名されたインストーラを使用)、2つのアーカイブ「openssl.zip」と「frameworkb.rar」を展開します。展開された各ファイルは、Batloaderの実行チェーンにおける後続のステップで使用されます。
先述のアーカイブ「frameworkb.rar」を展開すると、図3の通り、2つのスクリプト「framework.py」、「frameworkb.py」、および、Pyarmor Proによるカスタマイズが施されたPython用ランタイムライブラリが得られます。このうち、2つのスクリプトはPyarmorの難読化がかけられた状態であり、マルウェア「Batloader」によって実行されます。
図4に、Pyarmorで難読化されたスクリプトの一例を示します。スクリプトの冒頭部には、本ファイルがPyarmor Pro 8.2.8によって作成されていること、そして、先述のPython用ライブラリがフォルダ「pyarmor_runtime_005214」から読み込まれる旨が記載されています。
図5に、frameworkb.pyの実行チェーンを「Trend Vision One™」で分析した結果を示します。その内容を踏まえると、cmd.exeによって起動された当該スクリプト「frameworkb.py」は、被害端末上でネットワーク構成情報を収集します。この際に使用するツールとして、IPアドレスをMACアドレスに変換する「arp.exe」や、ドメイン名などのシステム情報を取得する「WMIコマンドライン(WMIC)」などが挙げられます。収集した情報は、攻撃者が管理するコマンドコントロール(C&C:Command and Control)サーバ宛てに送信します。本事例では、C&Cサーバとして以下が利用されました。
countingstatistic[.]com
もう1つのPythonスクリプト「framework.py」は、第二段階用ペイロードがC&Cサーバからダウンロードされたタイミングで実行されます。第二段階用ペイロードの実体は各種マルウェアであり、前回のBatloaderによる攻撃事例では、「Usnif」、「Vidar」、「Redline Stealer」などが多く見られました。
上図、Vision Oneのコンソール画面に基づくと、framework.pyの起動に際しては下記のようなキルチェーンが実行されます。
(1):下記コマンドにより、Pythonがframework.pyを起動する。
cmd /c python.exe framework.py
(2):OpenSSLを用いてダウンロード済みファイル(a.exe.enc)を復号する。この際の復号アルゴリズムとして「CBCモード(Cipher-Block Chaining)のAES-256」、パスワードとして「tor92SS2jds」を使用する。
復号結果は「control.exe」のファイル名で保存され、後にcmd.exeによって起動される。
cmd /c "openssl enc -aes-256-cbc -d -in a.exe.enc -out control.exe -pbkdf2 -pass pass:tor92SS2jds"
(3)、(4)、(5):下記コマンドにより、被害者のネットワーク構成情報を収集する。
whoami /groups
C:\Windows\system32\cmd.exe /c "arp -a"
wmic computersystem get domain
まとめ
Batloaderは、さまざまなマルウェアの配布に利用されている初期アクセス用マルウェアです。その活動は現在なお活発であり、感染すると、「Royal」や「BlackSuit」をはじめとする危険なランサムウェアのインストールに繋がる恐れがあります。本マルウェアは高い回避性能を持ち、検知エンジンを逃れるためにさまざまな技術を搭載しています。具体例として、デジタル署名の不正使用、インストーラの容量を大幅に水増しすることで容量に制限のある検知エンジンを阻害する手口、さらには、本稿で述べたように、「PyArmor Pro」などのツールによってPythonスクリプトを難読化する手口が挙げられます。
トレンドマイクロによるソリューション
企業や組織がBatloaderをはじめとするマルウェアの脅威に対抗する上では、「Trend Vision One」のように包括的な検知・応答技術を備えたソリューションの導入が有効です。本ソリューションは、強固なXDR(Extended Detection and Response)機能を備え、メールからエンドポイント、サーバ、クラウド操作、ネットワークまでを含むさまざまなセキュリティレイヤーから情報を収集し、相互の関連を含めた分析を行います。これにより、潜在的なセキュリティ事象を見逃すことなく検知、阻止することが可能となります。
Vision Oneによる脅威検出
Trend Vision Oneをご利用のお客様は、今回のBatloaderによる脅威を検出する上で、下記の検索法をご使用いただけます。
メニュー上より「SearchApp > General > Search」を選択し、parentCmdとして以下を指定
”cmd /c python.exe framework*”
侵入の痕跡(Indicators of Compromise、IoC)
侵入の痕跡(IoC)についてはこちらで確認してください。
参考記事:
Latest Batloader Campaigns Use Pyarmor Pro for Evasion
By: Junestherry Dela Cruz
翻訳:清水 浩平(Core Technology Marketing, Trend Micro™ Research)