2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windowsイベントログファイル(EVTX)をwinlogbeatコマンドラインから直接Elasticsearchへ投入してみる

Last updated at Posted at 2020-12-14

はじめに

Windowsイベントログファイル(.evtx)をElasticsearchへ直接投入するやり方について説明する機会があったので備忘録(小ネタ)。Winlogbeatをコマンドラインから実行するだけで簡単。

詳細はこちらをご参照ください。

利用するソフトウェア

  • OS: Ubuntu 18.04
  • Elasticsearch (7.8.1)
  • Kibana (7.8.1)
  • Winlogbeat(7.10.1)

利用するWindowsログファイル

Windows EVTX Samplesで配布されている攻撃実行時のWindowsイベントログファイル(SecurityログとSysmonログ)を利用してみます。
※利用時にはライセンスをご確認ください。

イベント投入用のwinlogbeat設定ファイル

「C:\Users\hoge\Desktop\upload_evtx\upload_evtx.yml」として以下を保存しておきます。

upload_evtx.yml
winlogbeat.event_logs:
  - name: ${EVTX_FILE} 
    no_more_events: stop

winlogbeat.shutdown_timeout: 1s
winlogbeat.registry_file: "${CWD}/winlogbeat/evtx-registry.yml"

output.elasticsearch:
  enabled: true
  hosts: ['http://<elastic_ip>:9200']

Windows EVTX Samplesで配布されているwinlogbeat_example.ymlとほぼ同じです。おまけを参照。

winlogbeat.exeコマンドでイベントを投入

PS C:\Users\hoge\Desktop> & "C:\Program Files\winlogbeat-7.10.1-windows-x86_64\winlogbeat.exe" -e -c 'C:\Users\hoge\Desktop\upload_evtx\upload_evtx.yml' -E EVTX_FILE="C:\Users\hoge\Desktop\EVTX-ATTACK-SAMPLES-master\Credential Access\sysmon_3_10_Invoke-Mimikatz_hosted_Github.evtx" -E CWD='C:\Users\hoge\Desktop\upload_evtx\

Elastic Common Schema (ECS)へ変換してから投入

SecurityログやSysmonログはwinlogbeatにECSへの変換を行ってくれるプロセッサ(スクリプト)が同梱されています。ECSへ変換して格納した方がいろいろ便利なので有効化したい場合には以下の設定例を参照ください。

upload_evtx.yml
winlogbeat.event_logs:
  - name: ${EVTX_FILE} 
    no_more_events: stop
    processors:
      # Sysmonログの変換
      - script:
          lang: javascript
          id: sysmon
          file: "C:\\Program Files\\winlogbeat-7.10.1-windows-x86_64\\module\\sysmon\\config\\winlogbeat-sysmon.js"
      # Securityログの変換
      - script:
          lang: javascript
          id: security
          file: "C:\\Program Files\\winlogbeat-7.10.1-windows-x86_64\\module\\security\\config\\winlogbeat-security.js"

winlogbeat.shutdown_timeout: 1s
winlogbeat.registry_file: "${CWD}/winlogbeat/evtx-registry.yml"

output.elasticsearch:
  enabled: true
  hosts: ['http://<elastic_ip>:9200']

Winlogbeatがデフォルトではサポートしていないイベントログの加工を行いたい場合でもjavascriptとしてスクリプトプロセッサを独自に書くことができます。少し古い記事ですが以下の記事もご参考まで。

Winlogbeat 7.2.0 新機能: ScriptプロセッサのモジュールをJavascriptで作ってみる

おまけ

今回利用したWindows EVTX Samplesには全イベントファイルをまとめて投入してくれるPowerShellスクリプトが同梱されています。

# Windows EVTX Samplesを展開したフォルダへ移動して・・・
PS C:\Users\hoge\Desktop\EVTX-ATTACK-SAMPLES-master> PowerShell.exe -ExecutionPolicy UnRestricted -File .\Winlogbeat-Bulk-Read.ps1 -Exe "C:\Program Files\winlogbeat-7.10.1-windows-x86_64\winlogbeat.exe" -Reset -Verbose -Config .\winlogbeat_example.yml
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?