fighting advanced malware using machine learning (japanese)

36
Fourteenforty Research Institute, Inc. FFRI, Inc. http://www.ffri.jp @PacSec 2013 Fighting advanced malware using machine learning 村上純一 新技術開発部長

Upload: ffri-inc

Post on 20-May-2015

675 views

Category:

Technology


3 download

DESCRIPTION

n this paper, behavioral-based detection powered by machine learning is introduced. As the result, detection ratio is dramatically improved by comparison with traditional detection. Needless to say that malware detection is getting harder today. Everybody knows signature-based detection reaches its limit, so that most anti-virus vendors use heuristic, behavioral and reputation-based detections altogether. About targeted attack, basically attackers use undetectable malware, so that reputation-based detection doesn't work well because it needs other victims beforehand. And it is a fact that detection ratio is not enough though we use heuristic and behavioral-based detections. In our research using the Metascan, average detection ratio of newest malware by most anti-virus scanner is about 30 %( the best is about 60 %). By the way, heuristic and behavioral-based detections are developed by knowledge and experience of malware analyst. For example, most analysts know that following features are indicator that those programs are malicious. - A file imports VirtualAlloc, VirtualProtect and LoadLibrary only and has a strange section name - An entry point that does not fall within declared text or code section - Creating remote threads into a legitimate process like explore.exe - After unpacking, calling OpenMutex and CreateMutex to avoid multiple infections - Register itself to auto start extension points like services and registry - Creating a .bat file and try to delete own itself through executing the file with cmd.exe - Setting global hook to capture keystroke using SetWindowsHookEx Heuristic and behavioral-based detections are developed based on those pre-determined features like above. Analysts are finding those features day by day. But, this kind of work is not appropriate for human. Therefore we classified programs as malware or benign by machine learning through dynamic analysis results. Thereby, detection ratio is dramatically improved and we could recognize that which features are strongly related to malware by numeric score. And then, we could find the features which we’ve never found by this method. Finally, the outlook and challenges of this method will be tackled.

TRANSCRIPT

Page 1: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

Fourteenforty Research Institute, Inc.

FFRI, Inc. http://www.ffri.jp

@PacSec 2013

Fighting advanced malware

using machine learning 村上純一

新技術開発部長

Page 2: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• セキュリティ研究者@FFRI

– マルウェア解析、脆弱性解析

– Windows, Linuxでのデバイスドライバ開発等

• 各種テクニカルカンファレンスにて講演

– BlackHat USA/JP, RSA, PacSec, AVAR, etc.

• 機械学習の専門家ではない

– 機械学習の*ユーザー*

自己紹介

2

Page 5: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 背景

• 検出アプローチ

• コンピュータ vs. 人間

• リアルタイム検知への応用

• まとめ

アジェンダ

5

Page 6: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

背景 – マルウェアおよびその検出技術

6

マルウェアの増加

標的型攻撃

(未知マルウェア)

生成ツール

難読化ツール

パターン

マッチングの限界

他の検出手法

レピュテーション

ヒューリスティック

機械学習

ビッグデータ ビヘイビア

Page 7: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• Metascanを利用して11社の製品の検出力を評価

• 最新のマルウェアを利用

• 異なるソース・期間から2つのデータセットを用意

– test-1: 1,000 検体

– test-2: 900 検体

パターンマッチングの限界

7

Pattern

Reputation

Huer.

ML

Bhvr.

Page 8: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

パターンマッチングの限界

8

0%

20%

40%

60%

80%

100%

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

test-

1te

st-

2

A B C D E F G H I J K

TPR FNR

平均

Page 9: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 基本的なコンセプトはパターンマッチングと同じ(blacklist)

• エンドポイントはパターンを持つ必要がない

• 新しいパターンの反映が容易(配信の必要がない)

レピュテーション検知の強み

9

1. query 2. check

3. response Pattern

Reputation

Huer.

ML

Bhvr.

Page 10: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

レピュテーションの弱み

10

1. query 2. check

3. response

• 「検知可能」 = 「既に誰かが攻撃されている」

• 自分達が初めての攻撃対象だった場合はどうか?

• 「真の標的型攻撃」に対してどの程度有効なのか?

Pattern

Reputation

Huer.

ML

Bhvr.

Page 11: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 事前に定義した特徴、挙動に基づいて検知

– OpenProcess → WriteProcessMemory → CreateRemoteThread

– Runキー等の自動スタートポイントに自身を登録

– Windows Firewallの無効化等

• 汎用的な検知機能を提供可能

• パターンが不要

(定常的なスキャン、アップデートが不要)

ヒューリスティック・ビヘイビア検知の強み

11

Pattern

Reputation

Huer.

ML

Bhvr.

Page 12: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 完全な誤検知の回避が困難

• ユーザーに検出アクションを許可するか判断を仰ぐ場合も

(ユーザーの判断依存)

• 継続的なマルウェア解析、ロジックの見直しが必要

ヒューリスティック・ビヘイビア検知の弱み

12

(人間よりもコンピュータに最適なタスク) Pattern

Reputation

Huer.

ML

Bhvr.

Page 13: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

Heuristic Behavioral Test - July 2012

13

http://chart.av-comparatives.org/chart1.php

• AV-comparativesが2012年よりテストを実施、結果を公開

• ビヘイビア検知は検知にほとんど寄与していない(平均:4.8%)

Page 14: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 機械学習を利用したビヘイビア検出

• 既存アイディアだが産業界においてより実践的取り組み

• オープンソースを利用することで実現、自動化が容易

– Cuckoo Sandbox

– Jubatus

検出アプローチ

14

Pattern

Reputation

Huer.

ML

Bhvr.

Page 15: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

機械学習による検知

15

特徴

静的情報

動的情報

ハイブリッド

アルゴリズム

SVM

ベイジアン

パーセプトロン等

評価

TPR/FRP

ROC曲線等

正確性、精度

• 多くの研究が学術界で行われている

• 基本的には、分類に関する問題

• 下記の組み合わせに関する研究が主流

Pattern

Reputation

Huer.

ML

Bhvr.

Page 16: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

概要

16

動的解析

学習

Cuckoo

Sandbox

Jubatus

学習セット

特徴

抽出

加工

変換

評価

Jubatus

テストセット

TPR: X%

FPR: Y%

データセット マルウェア

正常系

Page 17: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 信頼区間と呼ばれる概念

• どの程度誤差を許容するかに依存

• 下記はいずれも陽性率1%

– 1/100 (N=100)

– 10/1,000 (N=1,000)

– 100/10,000 (N=10,000)

• 1%と断定する確信が異なる

– それぞれ異なる誤差を持つ

必要なサンプル数

17

Page 18: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

用意したサンプル数に応じて推定誤差を計算可能

必要なサンプル数

18

(N)

誤差を含んだ陽性率

(

95%信頼区間

)

0.0%

1.0%

2.0%

3.0%

4.0%

5.0%

6.0%

100 1,000 10,000 100,000 1,000,000

Page 19: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 独自に収集している検体から無作為抽出

– マルウェア: 15,000(5,000 = 学習用, 10,000 = テスト用)

– 正常系: 15,000 (5,000 = 学習用, 10,000 = テスト用)

• ランダムであることが重要

– 異なる期間(毎日の収集データから少量ずつ抽出)

– 異なるソース

– 抽出時にファイルタイプ、マルウェア種別は考慮しない

マルウェア及び正常系データ

19

Page 20: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• オープンソースのマルウェア自動解析システム

– 検体を仮想マシンにコピー

– 検体を仮想マシン内で実行

– 実行時の挙動をモニタリングし、データを記録

• APIコール, ネットワーク通信, VirusTotalの結果等

Cuckoo Sandbox - http://www.cuckoosandbox.org/

20

Page 21: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

APIコール

21

Page 22: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 多くの検体が1秒以内にAPIコールを完了する

(または呼び出し続ける) -> 5秒以内に完了したものを対象に

APIコールの傾向

22

0

2000

4000

6000

8000

10000

1s 5s 10s 15s 30s 45s 60s 60s+

経過時間

malware goodware

APIコ

ールが完了した件数

Page 23: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• オンライン機械学習向け分散処理フレームワーク

– 分散処理: スケーラブル

– オンライン処理: 非バッチ処理、随時学習

• オープンソース, LGPL v2.1. 最新版0.4.5(22/07/2013)

• Preferred Infrastructure及びNTT Software Innovation Centerが開発

• 様々な機械学習をサポート

– 分類、回帰分析、推薦、異常検知等

• 利用が容易(様々な言語バインディング、特徴ベクトル変換器等)

Jubatus - http://jubat.us/en/

23

Page 24: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

特徴抽出及び加工

24

NtOpenFile

NtWriteFile

NtWriteFile

NtOpenFile

NtWriteFile

NtWriteFile APIコ

ールシーケンス

NtCreateProcess

NtOpenFileNtWriteFileNtWriteFile

NtWriteFileNtWriteFileNtOpenFile

NtWriteFileNtOpenFileNtWriteFile

.

.

.

.

.

Page 25: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

malware

benign

特徴抽出及び加工

25

malware

NtCreateProcess NtClose NtClose benign NtCreateProcess NtClose NtClose benign

NtCreateProcessNtCloseNtClose

label:benign

NtOpenFile NtWriteFile Nt

malware

NtOpenFileNtWriteFileNtWriteFile

label:malware train

Jubatus

Page 26: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

出現回数、ラベルに基づいて各特徴の重みを計算、更新

(イメージ) 学習の内部状態

26

malware benign

0.75 0.25

0.25

0.25

0.75

0.75

0.5 0.5

0.0

NtClose NtClose NtClose

NtWriteFile LdrLoadDll NtDelayExecution

NtCreateProcess NtClose NtClose

NtAllocateVirtualMemory ... ...

Page 27: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• N of N-gram

– 3~5-gram > 2-gram = 6-gram

• 最良値: 3-gram、log_tf-binによる重み付け

– TRP: 72.33% [71.58 ~ 73.07 % (95%信頼区間)]

– FPR: 0.77% [0.60 ~ 0.99% (95%信頼区間)]

• 上記はあくまで一つの結果

– 様々な特徴の組み合わせが存在する

(今回はAPI名とそのシーケンスのみ特徴化)

評価結果

27

Page 28: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

28

デモ

Page 30: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

API 3-gramにおけるマルウェアらしさ

30

[foo@nolife classifier]$ ./dump --input model --label “malware”

0.181128 api_call$VirtualProtectEx_VirtualProtectEx_VirtualProtectEx@space#log_tf/bin

0.142254 api_call$RegOpenKeyExA_NtOpenKey_NtOpenKey@space#log_tf/bin

0.137144 api_call$NtReadFile_NtReadFile_NtFreeVirtualMemory@space#log_tf/bin

0.134443 api_call$LdrLoadDll_LdrGetProcedureAddress_VirtualProtectEx@space#log_tf/bin

0.130287 api_call$LdrLoadDll_RegOpenKeyExA_NtOpenKey@space#log_tf/bin

0.130287 api_call$DeviceIoControl_LdrLoadDll_RegOpenKeyExA@space#log_tf/bin

0.122363 api_call$VirtualProtectEx_LdrLoadDll_LdrGetProcedureAddress@space#log_tf/bin

0.102545 api_call$NtFreeVirtualMemory_LdrGetDllHandle_NtCreateFile@space#log_tf/bin

0.102485 api_call$RegCloseKey_RegCloseKey_RegCloseKey@space#log_tf/bin

0.0983165 api_call$NtReadFile_NtFreeVirtualMemory_LdrLoadDll@space#log_tf/bin

0.0966545 api_call$NtSetInformationFile_NtReadFile_NtFreeVirtualMemory@space#log_tf/bin

0.094639 api_call$NtMapViewOfSection_NtFreeVirtualMemory_NtOpenKey@space#log_tf/bin

0.0933827 api_call$NtFreeVirtualMemory_LdrLoadDll_LdrGetProcedureAddress@space#log_tf/bin

0.0905402 api_call$DeviceIoControl_DeviceIoControl_NtWriteFile@space#log_tf/bin

0.0903766 api_call$DeviceIoControl_NtWriteFile_NtWriteFile@space#log_tf/bin

0.0884724 api_call$RegOpenKeyExW_RegOpenKeyExW_LdrGetDllHandle@space#log_tf/bin

0.0853282 api_call$LdrLoadDll_LdrLoadDll_LdrLoadDll@space#log_tf/bin

...

Page 31: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

API 3-gramにおける正常系らしさ

31

[foo@nolife classifier]$ ./dump --input model --label “goodware”

0.268353 api_call$LdrGetDllHandle_LdrGetDllHandle_ExitProcess@space#log_tf/bin

0.268353 api_call$LdrGetDllHandle_ExitProcess_NtTerminateProcess@space#log_tf/bin

0.259838 api_call$NtWriteFile_LdrGetDllHandle_LdrGetDllHandle@space#log_tf/bin

0.25887 api_call$NtWriteFile_NtWriteFile_LdrGetDllHandle@space#log_tf/bin

0.135514 api_call$NtOpenFile_NtOpenFile_NtCreateFile@space#log_tf/bin

0.122445 api_call$DeviceIoControl_LdrLoadDll_LdrGetProcedureAddress@space#log_tf/bin

0.12242 api_call$DeviceIoControl_DeviceIoControl_LdrGetDllHandle@space#log_tf/bin

0.119231 api_call$GetSystemMetrics_LdrLoadDll_NtCreateMutant@space#log_tf/bin

0.115319 api_call$DeviceIoControl_LdrGetDllHandle_LdrGetProcedureAddress@space#log_tf/bin

0.109306 api_call$LdrGetProcedureAddress_NtOpenKey_LdrLoadDll@space#log_tf/bin

0.105579 api_call$NtReadFile_NtReadFile_NtReadFile@space#log_tf/bin

0.104565 api_call$NtCreateFile_NtCreateFile_NtWriteFile@space#log_tf/bin

0.103304 api_call$RegOpenKeyExA_LdrGetDllHandle_LdrGetProcedureAddress@space#log_tf/bin

0.10306 api_call$VirtualProtectEx_RegOpenKeyExA_LdrGetDllHandle@space#log_tf/bin

0.100701 api_call$NtFreeVirtualMemory_NtFreeVirtualMemory_GetSystemMetrics@space#log_tf/bin

...

Page 32: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• “VirtualProtectEx_VirtualProtectEx_VirtualProtectEx” マルウェアらしさに関連しているように見える

• “RegOpenKeyExA_NtOpenKey_NtOpenKey”はどうか?

• コンピュータは人間が認識できないものを認識している

(非常に強力な左脳)

• コンピュータと協力してみてはどうか?

コンピュータ vs. 人間

32

Page 33: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 機械学習により学習モデルを生成する

• 人間がモデルをチェックし、新ロジックを開発

(人間の右脳を利用)

• 機械学習による検知は御し難い場合も

– 詳細な検出条件を指定できない

「コンピュータが悪と言ったから悪」(理由は不明)

• 機械学習とロジックベースの検出の掛け合わせ

コンピュータを利用する

33

Page 34: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 静的情報を特徴に利用した場合

– プログラム実行前に検査可能

– パフォーマンスは選定した特徴次第

• 動的情報を特徴に利用した場合

– マルウェアは既に実行されている

– 検知が手遅れになる場合も

– この観点でも機械学習とロジックの掛け合わせは有効

リアルタイム検知への応用

34

Page 35: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

• 従来のパターンマッチングは限界を迎えている

• 現行のビヘイビア検知は検出にほとんど寄与していない

• ビヘイビア検知に機械学習を適用

– TPRが改善

– 人間には分からない特徴を発見(コンピュータが)

– これらを人間が利用することが重要

まとめ

35

Page 36: Fighting advanced malware using machine learning (Japanese)

FFRI, Inc.

Thank you!

36

Contact: [email protected] Twitter: @FFRI_Research