2014年8月13日水曜日

Sysinternals の Sysmon


System Monitor (Sysmon)Windows Sysinternals の新しいツール。
サービスとして動作して、プロセスの生成、ネットワーク接続、ファイル作成時間の変更などの詳細情報を、イベントログに記録してくれる。

Vista 以前では、「イベントビューアー」の「システムイベントログ」に記録される。
Vista 以降では、「イベントビューアー」の「アプリケーションとサービスログ」>「Microsoft」>「Windows」>「Sysmon」>「Operational」に記録される。

ログは量が多いので、後で解析する方法が重要になりそう。
サービスだけ起動しておいて、攻撃されて問題発覚したら分析する感じかな。あるいは定期的に分析?ツールでほぼリアルタイムに?

「Operational」のイベントログは、デフォルトで最大ログサイズが 65536 (KB)、「必要に応じてイベントを上書きする(最も古いイベントから)」だから、そのままではすぐにログは上書きされそう。


インストール


「管理者として実行」でコマンドプロンプトを起動する。

C:\windows\system32> cd \hoge\Sysmon
C:\hoge\Sysmon>

ヘルプを表示

C:\hoge\Sysmon> Sysmon.exe

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Usage:
Install:    Sysmon.exe -i [-h [sha1|md5|sha256]] [-n]
Configure:  Sysmon.exe -c [[-h [sha1|md5|sha256]] [-n]|--]
Uninstall:  Sysmon.exe -u
  -c   Update configuration of an installed Sysmon driver or dump the
       current configuration if no other argument is provided.
  -h   Specify the hash algorithm used for image identification (default
       is SHA1).
  -i   Install service and driver.
  -m   Install the event manifest (done on service install as well).
  -n   Log network connections.
  -u   Uninstall service and driver.

The service logs events immediately and the driver installs as a boot-start
driver to capture activity from early in the boot that the service will
write to the event log when it starts.

On Vista and higher, events are stored in
 "Applications and Services Logs/Microsoft/Windows/Sysmon/Operational"
On older systems events write to the System event log.

Specify -accepteula to automatically accept the EULA on installation, otherwise
you will be interactively prompted to accept it.
Neither install nor uninstall require a reboot.

デフォルトの設定でインストール(サービスに登録)してみる。
デフォルトの設定は、プロセスイメージをSHA1でハッシュ、ネットワークをモニタリングをしない。

C:\hoge\Sysmon>Sysmon.exe -i

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Sysmon installed.
SysmonDrv installed.
Starting SysmonDrv.
SysmonDrv started.
Starting Sysmon.
Sysmon started.

サービスに Symon (System Monitor service) が登録され、サービスが開始される。
次回からはPC起動時に自動的に開始する。
カーネルモードのマルウェアのアクティビティをキャプチャするため、ブートプロセスの初期からイベントログは生成されるらしい。

ネットワーク接続もモニタリングするようにインストールするには、以下の様にする。

C:\hoge\Sysmon>Sysmon.exe -i -n

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Sysmon installed.
SysmonDrv installed.
Starting SysmonDrv.
SysmonDrv started.
Starting Sysmon.
Sysmon started.

インストール後に、ネットワーク接続もモニタリングするように設定を変更する。

C:\hoge\Sysmon>Sysmon.exe -c -n

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Configuration updated.

現在の設定を確認する

C:\hoge\Sysmon>Sysmon.exe -c

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Current configuration:
 - Service name:                  Sysmon
 - Driver name:                   SysmonDrv
 - HashingAlgorithm:              SHA1
 - Network connection:            enabled

デフォルトの設定に戻すには、以下の様にする

C:\hoge\Sysmon>Sysmon.exe -c --

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Updating configuration to use all defaults.
Configuration updated.

もう一度、設定を確認すると、デフォルトの設定に戻っている

C:\hoge\Sysmon>Sysmon.exe -c

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Current configuration:
 - Service name:                  Sysmon
 - Driver name:                   SysmonDrv
 - HashingAlgorithm:              SHA1
 - Network connection:            disabled

最後に、アンインストール(サービスから削除)する方法

C:\hoge\Sysmon>Sysmon.exe -u

Sysinternals Sysmon v1.0 - System activity monitor
Copyright (C) 2014 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Stopping Sysmon:
Sysmon stopped.
Sysmon removed.
Stopping SysmonDrv:
SysmonDrv stopped.
SysmonDrv removed.


イベントログの内容

イベントID「1」 (Process Create)


プロセスが生成されたとき。



イベントID「2」 (File creation time changed)


ファイル作成時間が変更されたとき



イベントID「3」 (Network connection detected)


ネットワーク接続されたとき





0 件のコメント:

コメントを投稿