LoginSignup
2
1

More than 3 years have passed since last update.

Winlogbeat 7.2.0の新機能: JavascriptプロセッサのSysmonモジュールを使ってイベントログを採取してみる

Last updated at Posted at 2019-07-07

はじめに

Winlogbeat 7.2.0がリリースされました!以下のような非常に興味深い機能追加や変更がされているようです。

7.2.0で追加されたJavascriptプロセッサ機能を利用すればWindowsイベントログがWinlogbeat内でElasticsearchへ転送される前に加工されるため、これまでLogstash側やElasticsearch/ingest node側で加工していた処理を置き換えまたは軽量にすることができそうです。

そこで以前ご紹介しました「標的型攻撃に対するJPCERT/CCのおすすめログ設定をElasticsearchで構築してみる - エンドポイントログ編(その2- Winlogbeat/Elasticsearch)」のログ基盤環境で新しいWinlogbeat 7.2.0をインストールし、Sysmonイベントログの採取の観点から新規機能や変更点をざっと眺めてみました。

評価環境

log_network_sysmon_winlogbeat.png

利用するソフトウェア

  • OS: Ubuntu 18.04
  • DNSサーバ: Dnsmasq (2.79)
  • Elasticsearch (6.6.0)
  • Kibana (6.6.0)
  • Winlogbeat (7.2.0)
  • Sysmon (v10.2)
  • VMware Workstation Player等のVMソフトウェア
  • Windows 10 (クライアントPC)

Winlogbeat 7.2.0を新規インストール

インストール方法は6.x系と同じです。

設定ファイル

7.2.0ではSecurityモジュールやSysmonモジュールはデフォルトで有効となっているため、6.x系で必要だったようなログ転送対象として設定する作業は必要ありません。

winlogbeat.yml
output.elasticsearch:
 #ログ転送先のElasticsearchのアドレスを指定
  hosts: ["log.example.com:9200"]

編集した設定ファイルをテスト

編集した設定内容をテストしておきます。

PS C:\Program Files\winlogbeat-7.2.0-windows-x86_64> .\winlogbeat.exe test config

Elasticsearchへのネットワーク接続テストも行っておきましょう。

PS C:\Program Files\winlogbeat-7.2.0-windows-x86_64> .\winlogbeat.exe test output -e -d "*"

Winlogbeatをインストールし起動

PowerShell.exeに-ExecutionPolicy UnRestrictedオプションを指定してインストールスクリプトを実行。

PS C:\Program Files\winlogbeat-7.2.0-windows-x86_64> PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-winlogbeat.ps1

この時点ではまだWinlogbeatサービスは起動していませんので起動します。

PS C:\Program Files\winlogbeat-7.2.0-windows-x86_64> Start-Service winlogbeat

Winlogbeat 7.2.0の新規機能と変更点

「[Winlogbeat] Sysmon and Security "modules" for Winlogbeat #11651」にまとめられている内容は以下の通りです。

この新しいパイプラインモジュールはWinlogbeatに新規に追加されたJavascriptプロセッサ(エンジンはgoja)で処理されます。そしてそれらのモジュールは(Elasticsearch/Ingestノード側ではなく)Winlogbeat内(Windows PC側)で実行されます。

よってモジュール自体はオブジェクトコード(バイナリ)ではなく、Javascriptで書かれた設定ファイルとして以下へ配置されています。

C:\Program Files\winlogbeat-7.2.0-windows-x86_64\module\sysmon\config\winlogbeat-sysmon.js

"C:\Program Files\winlogbeat-7.2.0-windows-x86_64\"はWinlogbeatのインストールフォルダです。

ただし、ライセンスはX-Packのようです。こちらにまだこれらSecurityモジュールとSysmonモジュールについて記載がないので、他のFilebeatモジュールなどと同様にBASICサブスクリプションで使えるのかは分かりません[2019/07/07現在]。掲載されたらアップデートしたいと思います。

さて、このSysmonモジュールにより加工されたイベントログやモジュールのソースコードを眺めて気付いた点を以下にまとめてみました。

(1) プロセスのコマンドライン引数がMicrosoft社から提供されているCommandLineToArgvW関数でパースおよび分割され、それぞれの引数が配列形式で格納されている。

これは例えばcmd.exe /cにてPowerShell.exeのスクリプトコードが記述されている場合や特定の引数に関する攻撃アラートの検知ルールを書く場合などに都合がいいでしょう。こんな感じです。

コマンド実行例
C:\>cmd.exe /c "powershell.exe Resolve-DnsName -Name hoge.example.com"
採取されたProcessCreateイベント
{
  "_index" : "winlogbeat-7.2.0-2019.07.06",
  "_type" : "doc",
  "_id" : "s4ZjxmsBgG2_Id_hJZ-L",
  "_score" : 0.0,
  "_source" : {
    "@timestamp" : "2019-07-06T08:25:12.674Z",
...
    "process" : {
      "pid" : 10148,
      "executable" : "C:\\Windows\\System32\\cmd.exe",
      "args" : [
        "cmd.exe",
        "/c",
        "powershell.exe Resolve-DnsName -Name hoge.example.com"
      ],
      "working_directory" : "C:\\Users\\xxxxx\\Desktop\\Sysmon v10.2\\",
      "parent" : {
        "executable" : "C:\\Windows\\System32\\cmd.exe",
        "args" : [
          "C:\\WINDOWS\\system32\\cmd.exe"
        ],
        "name" : "cmd.exe",
        "entity_id" : "{22052e76-3a7c-5d20-0000-0010591c7000}",
        "pid" : 7644
      },
      "name" : "cmd.exe",
      "entity_id" : "{22052e76-5ae8-5d20-0000-001080e05501}"
    },
...

このようにprocess.argsフィールドにて"powershell.exe Resolve-DnsName -Name hoge.example.com"のように"cmd.exe /c ..."の引数部分で指定されているPowerShellスクリプト部分が分離されています。

(2) イメージファイルのハッシュ値が複数のアルゴリズム(SHA1、SHA256やimphash)がある場合にそれぞれに分割されてマップ形式(キー: アルゴリズム名、値: ハッシュ値)で格納されている。

加工前
"Hashes" : "SHA256=BE3D2BA94E34BAC4EC82540FB9C849E7E1B320359F98A1C3AFAC5A9EBDA2E05A,IMPHASH=4A1F732482255DD2152873FD941D4344",
Sysmonモジュールによる加工後
"hash" : {
  "sha256" : "be3d2ba94e34bac4ec82540fb9c849e7e1b320359f98a1c3afac5a9ebda2e05a",
  "imphash" : "4a1f732482255dd2152873fd941d4344"
},

分析ツールなどでも扱いやすくなりました。

(3) Elasticsearchへ格納される際のイベントログのタイムスタンプ(@timestamp)がWinlogbeatがログを取り込んだ時刻ではなく、Sysmonイベントが発生した時刻へ修正されている(Sysmonイベントログ(XML形式)のUtcTimeフィールド値で上書き)。

(4) プロセスイメージファイルのベース名(フルパスからEXEファイル名だけ切り出し)がprocess.nameフィールドへ設定される。ベース名で検索をかけることも多いですから嬉しいですね。

(5) winlog.event_data.Userフィールドの元データは"ドメイン名\ユーザ名"の形式だった場合、ドメイン名とユーザ名に分割されて設定される。これもユーザ名で検索をかける際に便利です。

(6) パイプライン処理をWinlogbeat内(Windows PC側)で実行できるためElasticsearc/Ingest Node等の設定を置き換えたりまたは減らすことができる。Elasticsearchサーバ側の負荷軽減になりますね。

(7) Sysmonのイベントログ(XML)のフィールドがElastic Common Schema (ECS)で定義されているフィールド名前空間およびフィールド名へ変換されている(詳細は後述)。ただし、ECSに定義されていないフィールドは従来と同じevent_dataフィールド配下へ格納されています。

(8) Sysmon v10のDNSイベント(DNSクエリー)ログ(ID: 22)に対しては未対応[2019/07/07時点]のようですが、おそらくすぐに対応されるような気がします(笑)

ECSへの準拠は・・・Elastic SIEMでネットワーク機器など他の様々なログと横断的に運用したり、ML機能を利用することを考えると共通スキーマへの対応は妥当な方向だと思います(6.x系の運用で作成したツールへの修正が結構必要でツライですが・・・泣)。

Elastic Common Schema (ECS)への変換例

Sysmonイベントログの元データは以下のようなXML形式です。

ProcessCreateイベントログ
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Sysmon" Guid="{5770385f-c22a-43e0-bf4c-06f5698ffbd9}" /> 
    <EventID>1</EventID> 
    <Version>5</Version> 
    <Level>4</Level> 
    <Task>1</Task> 
    <Opcode>0</Opcode> 
    <Keywords>0x8000000000000000</Keywords> 
    <TimeCreated SystemTime="2019-07-06T16:43:56.545001500Z" /> 
    <EventRecordID>765175</EventRecordID> 
    <Correlation /> 
    <Execution ProcessID="2788" ThreadID="2600" /> 
    <Channel>Microsoft-Windows-Sysmon/Operational</Channel> 
    <Computer>xxxxxxxxxxxxxxx</Computer> 
    <Security UserID="S-1-5-18" /> 
  </System>
  <EventData>
    <Data Name="RuleName" /> 
    <Data Name="UtcTime">2019-07-06 16:43:56.540</Data> 
    <Data Name="ProcessGuid">{22052e76-cfcc-5d20-0000-0010b64b8a00}</Data> 
    <Data Name="ProcessId">6244</Data> 
    <Data Name="Image">C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</Data> 
    <Data Name="FileVersion">75.0.3770.100</Data> 
    <Data Name="Description">Google Chrome</Data> 
    <Data Name="Product">Google Chrome</Data> 
    <Data Name="Company">Google LLC</Data> 
    <Data Name="OriginalFileName">chrome.exe</Data> 
    <Data Name="CommandLine">"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=renderer --field-trial-handle=1812,14350702623308523604,1203234868984428877,131072 --lang=ja --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --device-scale-factor=1.25 --num-raster-threads=1 --service-request-channel-token=9155088137090119445 --renderer-client-id=77 --no-v8-untrusted-code-mitigations --mojo-platform-channel-handle=3652 /prefetch:1</Data> 
    <Data Name="CurrentDirectory">C:\Program Files (x86)\Google\Chrome\Application\75.0.3770.100\</Data> 
    <Data Name="User">xxxxxxxxxxxxxxx\xxxxx</Data> 
    <Data Name="LogonGuid">{22052e76-bcbd-5d20-0000-0020fbc42200}</Data> 
    <Data Name="LogonId">0x22c4fb</Data> 
    <Data Name="TerminalSessionId">1</Data> 
    <Data Name="IntegrityLevel">Low</Data> 
    <Data Name="Hashes">SHA256=BE3D2BA94E34BAC4EC82540FB9C849E7E1B320359F98A1C3AFAC5A9EBDA2E05A,IMPHASH=4A1F732482255DD2152873FD941D4344</Data> 
    <Data Name="ParentProcessGuid">{22052e76-cde1-5d20-0000-001038355e00}</Data> 
    <Data Name="ParentProcessId">7104</Data> 
    <Data Name="ParentImage">C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</Data> 
    <Data Name="ParentCommandLine">"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"</Data> 
  </EventData>
</Event>

WinlogbeatはこれをJSON形式へ変換します。さらに7.2.0で追加されたSysmonモジュールが最終的にECSのフィールド名前空間やフィールド名へ変換するわけです。以下はプロセス情報に関するECSへの変換例です。

元データXML
...
<Data Name="Image">C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</Data>
<Data Name="ProcessId">6244</Data> 
...
WinlogbeatがXMLからJSON形式へ変換
...
    "winlog" : {
       "event_data" : {
         "Image" : "C:\\Windows\\System32\\MusNotifyIcon.exe",
         "ProcessId" : "6244",
...
WinlogbeatのSysmonモジュールがECS形式へ変換
...
     "process" : {
       "executable" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
       "pid" : 6244,
...
      },
...

上記の例では「Image」は「winlog.event_data.Image」へまず変換され、最終的にSysmonモジュールによって「process.executable」という名前空間およびフィールド名へ変換されています(パイプライン処理)。

スキーマ変更点の概要

Winlogbeat 6.6.0と7.2.0のフィールド名の違いを比較表としてまとめてみました。

6.6.0 7.2.0 備考
source_name winlog.provider_name "Microsoft-Windows-Sysmon"
log_name winlog.channel "Microsoft-Windows-Sysmon/Operational"
event_id winlog.event_id SysmonイベントID
event_data.* winlog.event_data.* Sysmonイベントデータ
beat.* agent.* Winlogbeatの情報
N/A ecs.version "1.0.0"
event_data.User user.domainとuser.name ドメイン名とユーザ名へ分割
event_data.プロセス関連フィールド process.* ECSへ対応
event_data.ネットワーク通信関連フィールド network.*, destination.*, source.*へ分割 ECSへ対応

Winlogbeat 7.2.0でのSysmonイベントログ取得例

では実際に新しいWinlogbeat 7.2.0で採取したSysmonログをいくつか見てみましょう。

ProcessCreateログの取得
curl -XGET http://log.example.com:9200/winlogbeat-7.2.0-*/_search?pretty -H 'Content-Type: application/json' -d '
{
  "query": {
    "bool":{
      "filter": [
        {
          "term": {
            "winlog.channel" : "Microsoft-Windows-Sysmon/Operational"
          }
        },
        {
          "term": {
            "winlog.event_id" : 1
          }     
        }
      ]
    }
  },
  "size":10000
}
'

(長くなりますが)ここではクエリー結果を省略せずに掲載します。

Google_Chromeのプロセス起動ログ
{
  "_index" : "winlogbeat-7.2.0-2019.07.06",
  "_type" : "doc",
  "_id" : "noH7xWsBgG2_Id_hoL-x",
  "_score" : 0.0,
  "_source" : {
    "@timestamp" : "2019-07-06T06:31:39.628Z",
    "event" : {
      "kind" : "event",
      "code" : 1,
      "action" : "Process Create (rule: ProcessCreate)",
      "created" : "2019-07-06T06:32:10.224Z"
    },
    "log" : {
      "level" : "情報"
    },
    "process" : {
      "working_directory" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\75.0.3770.100\\",
      "parent" : {
        "entity_id" : "{22052e76-403f-5d20-0000-0010cc9a7c00}",
        "pid" : 8660,
        "executable" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
        "args" : [
          "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
        ],
        "name" : "chrome.exe"
      },
      "name" : "chrome.exe",
      "entity_id" : "{22052e76-404b-5d20-0000-0010cc447e00}",
      "pid" : 3780,
      "executable" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
      "args" : [
        "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
        "--type=renderer",
        "--field-trial-handle=1712,10598131892429460430,10188806900462235410,131072",
        "--lang=ja",
        "--enable-offline-auto-reload",
        "--enable-offline-auto-reload-visible-only",
        "--device-scale-factor=1.25",
        "--num-raster-threads=1",
        "--service-request-channel-token=8912458793989870459",
        "--renderer-client-id=16",
        "--no-v8-untrusted-code-mitigations",
        "--mojo-platform-channel-handle=5024",
        "/prefetch:1"
      ]
    },
    "user" : {
      "domain" : "xxxxxxxxxxxxxxx",
      "name" : "xxxx"
    },
    "host" : {
      "name" : "xxxxxxxxxxxxxxx",
      "os" : {
        "name" : "Windows 10 Pro",
        "kernel" : "10.0.17763.107 (WinBuild.160101.0800)",
        "build" : "17763.107",
        "platform" : "windows",
        "version" : "10.0",
        "family" : "windows"
      },
      "id" : "22052e76-721a-4007-86f6-6346e89d0c86",
      "hostname" : "xxxxxxxxxxxxxxx",
      "architecture" : "x86_64"
    },
    "agent" : {
      "id" : "13688524-bee4-4020-a8b5-4304667adbd0",
      "version" : "7.2.0",
      "type" : "winlogbeat",
      "ephemeral_id" : "b6156b7a-43aa-47b2-8957-dd113adf2008",
      "hostname" : "xxxxxxxxxxxxxxx"
    },
    "winlog" : {
      "task" : "Process Create (rule: ProcessCreate)",
      "computer_name" : "xxxxxxxxxxxxxxx",
      "event_data" : {
        "FileVersion" : "75.0.3770.100",
        "LogonGuid" : "{22052e76-cf0d-5d03-0000-00201a3c0300}",
        "IntegrityLevel" : "Low",
        "TerminalSessionId" : "1",
        "LogonId" : "0x33c1a",
        "Company" : "Google LLC",
        "Product" : "Google Chrome",
        "OriginalFileName" : "chrome.exe",
        "Description" : "Google Chrome"
      },
      "opcode" : "情報",
      "version" : 5,
      "process" : {
        "pid" : 236,
        "thread" : {
          "id" : 8028
        }
      },
      "provider_guid" : "{5770385f-c22a-43e0-bf4c-06f5698ffbd9}",
      "record_id" : 29304,
      "api" : "wineventlog",
      "event_id" : 1,
      "user" : {
        "identifier" : "S-1-5-18",
        "name" : "SYSTEM",
        "domain" : "NT AUTHORITY",
        "type" : "User"
      },
      "channel" : "Microsoft-Windows-Sysmon/Operational",
      "provider_name" : "Microsoft-Windows-Sysmon"
    },
    "message" : "Process Create:\nRuleName: \nUtcTime: 2019-07-06 06:31:39.628\nProcessGuid: {22052e76-404b-5d20-0000-0010cc447e00}\nProcessId: 3780\nImage: C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\nFileVersion: 75.0.3770.100\nDescription: Google Chrome\nProduct: Google Chrome\nCompany: Google LLC\nOriginalFileName: chrome.exe\nCommandLine: \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --type=renderer --field-trial-handle=1712,10598131892429460430,10188806900462235410,131072 --lang=ja --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --device-scale-factor=1.25 --num-raster-threads=1 --service-request-channel-token=8912458793989870459 --renderer-client-id=16 --no-v8-untrusted-code-mitigations --mojo-platform-channel-handle=5024 /prefetch:1\nCurrentDirectory: C:\\Program Files (x86)\\Google\\Chrome\\Application\\75.0.3770.100\\\nUser: xxxxxxxxxxxxxxx\\xxxxx\nLogonGuid: {22052e76-cf0d-5d03-0000-00201a3c0300}\nLogonId: 0x33C1A\nTerminalSessionId: 1\nIntegrityLevel: Low\nHashes: SHA256=BE3D2BA94E34BAC4EC82540FB9C849E7E1B320359F98A1C3AFAC5A9EBDA2E05A,IMPHASH=4A1F732482255DD2152873FD941D4344\nParentProcessGuid: {22052e76-403f-5d20-0000-0010cc9a7c00}\nParentProcessId: 8660\nParentImage: C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\nParentCommandLine: \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" ",
    "hash" : {
      "sha256" : "be3d2ba94e34bac4ec82540fb9c849e7e1b320359f98a1c3afac5a9ebda2e05a",
      "imphash" : "4a1f732482255dd2152873fd941d4344"
    },
    "ecs" : {
      "version" : "1.0.0"
    }
  }
},

以下はネットワーク通信ログの取得例です。

NetworkConnectionログの取得
curl -XGET http://log.example.com:9200/winlogbeat-7.2.0-*/_search?pretty -H 'Content-Type: application/json' -d '
{
  "query": {
    "bool":{
      "filter": [
        {
          "term": {
            "winlog.channel" : "Microsoft-Windows-Sysmon/Operational"
          }
        },
        {
          "term": {
            "winlog.event_id" : 3
          }
        }
      ]
    }
  },
  "size":10000
}
'
Google_ChromeのNetworkConnectionログ
{
  "_index" : "winlogbeat-7.2.0-2019.07.06",
  "_type" : "doc",
  "_id" : "yIH7xWsBgG2_Id_hoL_c",
  "_score" : 0.0,
  "_source" : {
    "@timestamp" : "2019-07-06T06:31:39.621Z",
    "network" : {
      "transport" : "tcp",
      "direction" : "outbound",
      "type" : "ipv4"
    },
    "destination" : {
      "ip" : "192.168.1.10",
      "domain" : "dmz.example.com",
      "port" : 3128
    },
    "host" : {
      "id" : "22052e76-721a-4007-86f6-6346e89d0c86",
      "hostname" : "xxxxxxxxxxxxxxx",
      "name" : "xxxxxxxxxxxxxxx",
      "architecture" : "x86_64",
      "os" : {
        "family" : "windows",
        "name" : "Windows 10 Pro",
        "kernel" : "10.0.17763.107 (WinBuild.160101.0800)",
        "build" : "17763.107",
        "platform" : "windows",
        "version" : "10.0"
      }
    },
    "message" : "Network connection detected:\nRuleName: \nUtcTime: 2019-07-06 06:31:39.621\nProcessGuid: {22052e76-4042-5d20-0000-0010c3c97c00}\nProcessId: 4012\nImage: C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\nUser: xxxxxxxxxxxxxxx\\xxxxx\nProtocol: tcp\nInitiated: true\nSourceIsIpv6: false\nSourceIp: 192.168.0.134\nSourceHostname: xxxxxxxxxxxxxxx.localdomain\nSourcePort: 50363\nSourcePortName: \nDestinationIsIpv6: false\nDestinationIp: 192.168.1.10\nDestinationHostname: dmz.example.com\nDestinationPort: 3128\nDestinationPortName: ",
    "event" : {
      "code" : 3,
      "action" : "Network connection detected (rule: NetworkConnect)",
      "created" : "2019-07-06T06:32:10.364Z",
      "kind" : "event"
    },
    "log" : {
      "level" : "情報"
    },
    "process" : {
      "executable" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
      "name" : "chrome.exe",
      "entity_id" : "{22052e76-4042-5d20-0000-0010c3c97c00}",
      "pid" : 4012
    },
    "source" : {
      "domain" : "xxxxxxxxxxxxxxx.localdomain",
      "port" : 50363,
      "ip" : "192.168.0.134"
    },
    "user" : {
      "domain" : "xxxxxxxxxxxxxxx",
      "name" : "xxxxx"
    },
    "ecs" : {
      "version" : "1.0.0"
    },
    "agent" : {
      "type" : "winlogbeat",
      "ephemeral_id" : "b6156b7a-43aa-47b2-8957-dd113adf2008",
      "hostname" : "xxxxxxxxxxxxxxx",
      "id" : "13688524-bee4-4020-a8b5-4304667adbd0",
      "version" : "7.2.0"
    },
    "winlog" : {
      "record_id" : 29346,
      "opcode" : "情報",
      "provider_guid" : "{5770385f-c22a-43e0-bf4c-06f5698ffbd9}",
      "process" : {
        "pid" : 236,
        "thread" : {
          "id" : 6456
        }
      },
      "user" : {
        "name" : "SYSTEM",
        "domain" : "NT AUTHORITY",
        "type" : "User",
        "identifier" : "S-1-5-18"
      },
      "provider_name" : "Microsoft-Windows-Sysmon",
      "channel" : "Microsoft-Windows-Sysmon/Operational",
      "task" : "Network connection detected (rule: NetworkConnect)",
      "computer_name" : "xxxxxxxxxxxxxxx",
      "version" : 5,
      "event_id" : 3,
      "api" : "wineventlog"
    }
  }
},

Sysmonモジュールを無効にしてみる

Winlogbeat設定ファイルのSysmonモジュール設定(processors)をコメントアウトします。

event_data.*がwinlog.event_data.*へ移動しているなど前述した通り名前空間の変更等はありますが、以下のようにSysmonイベントログの部分は6.x系と同形式および同フィールド名で採取できました。

winlogbeat.yml
winlogbeat.event_logs:
  - name: Application
    ignore_older: 72h
  - name: System
  - name: Security
    processors:
      - script:
          lang: javascript
          id: security
          file: ${path.home}/module/security/config/winlogbeat-security.js
  - name: Microsoft-Windows-Sysmon/Operational
#    processors:
#      - script:
#          lang: javascript
#          id: sysmon
#          file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js
...
クエリー結果
...
    "@timestamp" : "2019-07-06T16:42:23.767Z",
    "winlog" : {
      "task" : "Process Create (rule: ProcessCreate)",
      "event_data" : {
        "LogonId" : "0x22c4fb",
        "Product" : "Google Chrome",
        "OriginalFileName" : "chrome.exe",
        "Hashes" : "SHA256=BE3D2BA94E34BAC4EC82540FB9C849E7E1B320359F98A1C3AFAC5A9EBDA2E05A,IMPHASH=4A1F732482255DD2152873FD941D4344",
        "ProcessGuid" : "{22052e76-cf6f-5d20-0000-00103faf8700}",
        "CurrentDirectory" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\75.0.3770.100\\",
        "Image" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
        "ProcessId" : "6968",
        "LogonGuid" : "{22052e76-bcbd-5d20-0000-0020fbc42200}",
        "ParentCommandLine" : "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" ",
        "IntegrityLevel" : "Low",
        "Company" : "Google LLC",
        "CommandLine" : "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --type=utility --field-trial-handle=1812,14350702623308523604,1203234868984428877,131072 --lang=ja --service-sandbox-type=utility --service-request-channel-token=4120177429296784581 --mojo-platform-channel-handle=11696 --ignored=\" --type=renderer \" /prefetch:8",
        "User" : "xxxxxxxxxxxxxxxx\\xxxxx",
        "FileVersion" : "75.0.3770.100",
        "Description" : "Google Chrome",
        "ParentImage" : "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
        "UtcTime" : "2019-07-06 16:42:23.741",
        "ParentProcessId" : "7104",
        "TerminalSessionId" : "1",
        "ParentProcessGuid" : "{22052e76-cde1-5d20-0000-001038355e00}"
      },
...

まとめ

Winlogbeat 7.2.0の新規機能や変更点についてSysmonの観点を中心にざっと眺めてみました。

ログ基盤環境に組み込む観点からは(おそらく)Elastic SIEMを意識した対応やElasticsearch側の負荷低減ができるなど含め非常に興味深いリリースだと思います。

またJavascript書式による設定で容易かつ柔軟に様々なパイプライン処理を組み組める新機能は応用範囲が広がりそうで期待大です。

ただし、スキーマの互換性がなくなるのは・・・(独自に解析スクリプトを作成している場合など)正直ツライです・・・泣

また共通フォーマット(ECS)に準拠するかどうかもユーザ側の要件によって異なってくると思います。例えばインシデント発生時に、Windows被害端末から採取した元Sysmonイベントログと照合する際、フィールド名が共通スキーマに変換されているよりも元のSysmonログのフィールド名のままの方が都合がよい可能性もあります。

以上、ざっとWinlogbeat 7.2.0(+Sysmon 10.2)を評価してみました。

なおこの非常に興味深い新機能「Javascriptプロセッサ(パイプラインモジュール)」については別記事の「Winlogbeat 7.2.0 新機能: ScriptプロセッサのモジュールをJavascriptで作ってみる」にてご紹介しています。

(おまけ)SysmonモジュールにSysmon v10のDNSイベントログの加工処理を追加

Javascriptプロセッサ設定の練習としてSysmon v10の新機能「DNSイベント(DNSクエリー)」ログの加工処理などいくつか追加してみましたが問題なく動作しました。パイプライン設定をJavascriptの構文で簡単かつ柔軟にサクッと書けるので非常にお手軽で便利です。

Javascriptプロセッサで加工したDNSクエリーログ
{
  "_index" : "winlogbeat-7.2.0-2019.07.07",
  "_type" : "doc",
  "_id" : "5nxKzGsBcW1Zpfwo5Jbl",
  "_score" : 0.0,
  "_source" : {
    "@timestamp" : "2019-07-07T11:56:27.764Z",
    "message" : "Dns query:\nRuleName: \nUtcTime: 2019-07-07 11:56:27.764\nProcessGuid: {22052e76-cba4-5d21-0000-0010bb333f00}\nProcessId: 8516\nQueryName: www.youtube.com\nQueryStatus: 0\nQueryResults: type:  5 youtube-ui.l.google.com;2404:6800:4004:80d::200e;::ffff:172.217.31.142;::ffff:172.217.25.206;::ffff:172.217.25.238;::ffff:172.217.27.78;::ffff:172.217.161.78;::ffff:172.217.26.46;::ffff:172.217.31.174;::ffff:172.217.161.46;::ffff:216.58.197.206;::ffff:216.58.197.238;::ffff:216.58.197.142;::ffff:172.217.26.14;::ffff:172.217.25.110;\nImage: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "process" : {
      "entity_id" : "{22052e76-cba4-5d21-0000-0010bb333f00}",
      "pid" : 8516,
      "executable" : "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
      "name" : "powershell.exe"
    },
    "ecs" : {
      "version" : "1.0.0"
    },
    "host" : {
      "name" : "xxxxxxxxxxxxxxx",
      "os" : {
        "platform" : "windows",
        "version" : "10.0",
        "family" : "windows",
        "name" : "Windows 10 Pro",
        "kernel" : "10.0.17763.557 (WinBuild.160101.0800)",
        "build" : "17763.557"
      },
      "id" : "22052e76-721a-4007-86f6-6346e89d0c86",
      "hostname" : "xxxxxxxxxxxxxxx",
      "architecture" : "x86_64"
    },
    "agent" : {
      "ephemeral_id" : "212432b0-7ca8-48c3-9140-a0db41c5f90f",
      "hostname" : "xxxxxxxxxxxxxxx",
      "id" : "efd3716a-d03d-4687-aa16-644303a0165b",
      "version" : "7.2.0",
      "type" : "winlogbeat"
    },
    "winlog" : {
      "version" : 5,
      "event_id" : 22,
      "api" : "wineventlog",
      "process" : {
        "pid" : 2984,
        "thread" : {
          "id" : 1124
        }
      },
      "user" : {
        "identifier" : "S-1-5-18",
        "name" : "SYSTEM",
        "domain" : "NT AUTHORITY",
        "type" : "User"
      },
      "channel" : "Microsoft-Windows-Sysmon/Operational",
      "provider_name" : "Microsoft-Windows-Sysmon",
      "task" : "Dns query (rule: DnsQuery)",
      "computer_name" : "xxxxxxxxxxxxxxx",
      "provider_guid" : "{5770385f-c22a-43e0-bf4c-06f5698ffbd9}",
      "opcode" : "情報",
      "event_data" : {
        "QueryName" : "www.youtube.com",
        "QueryResults" : "type:  5 youtube-ui.l.google.com;2404:6800:4004:80d::200e;::ffff:172.217.31.142;::ffff:172.217.25.206;::ffff:172.217.25.238;::ffff:172.217.27.78;::ffff:172.217.161.78;::ffff:172.217.26.46;::ffff:172.217.31.174;::ffff:172.217.161.46;::ffff:216.58.197.206;::ffff:216.58.197.238;::ffff:216.58.197.142;::ffff:172.217.26.14;::ffff:172.217.25.110;",
        "QueryResults2" : [
          "type:5 youtube-ui.l.google.com",
          "2404:6800:4004:80d::200e",
          "172.217.31.142",
          "172.217.25.206",
          "172.217.25.238",
          "172.217.27.78",
          "172.217.161.78",
          "172.217.26.46",
          "172.217.31.174",
          "172.217.161.46",
          "216.58.197.206",
          "216.58.197.238",
          "216.58.197.142",
          "172.217.26.14",
          "172.217.25.110"
        ]
      },
      "record_id" : 1514962
    },
    "event" : {
      "kind" : "event",
      "code" : 22,
      "action" : "Dns query (rule: DnsQuery)",
      "created" : "2019-07-07T11:56:30.286Z"
    },
    "log" : {
      "level" : "情報"
    }
  }
},

ユーザ情報やプロセス情報が標準スキーマ(ECS)へ変換されています。またDNSクエリ結果であるQueryResults(元データ)がQueryResults2(加工後)へ扱いやすいように変換されています。これらの変換設定をJavascriptで記述できるのは楽ですね。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1