diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md
index 4038661de..d4544b13d 100644
--- a/CHANGELOG-Japanese.md
+++ b/CHANGELOG-Japanese.md
@@ -9,6 +9,7 @@
**改善:**
- 実行時のメモリ利用率を表示する機能を追加した。`--debug`オプションで利用可能。 (#788) (@fukusuket)
+- Clap Crateパッケージの更新。更新の関係で`--visualize-timeline` のショートオプションの`-V`を`-T`に変更した。 (#725) (@YamatoSecurity)
**バグ修正:**
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5836e49ac..dd3a813b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,8 @@
**Enhancements:**
-- Added the ability to display memory utilization at runtime. Available with the `--debug` option. (#788) (@fukusuket)
+- Added `--debug` option to display memory utilization at runtime. (#788) (@fukusuket)
+- Updated clap crate package to version 4 and changed the `--visualize-timeline` short option `-V` to `-T`. (#725) (@YamatoSecurity)
**Bug Fixes:**
diff --git a/Cargo.lock b/Cargo.lock
index c88e50417..705c2cd3b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -216,20 +216,33 @@ checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
dependencies = [
"atty",
"bitflags",
- "clap_derive",
- "clap_lex",
+ "clap_lex 0.2.4",
"indexmap",
- "once_cell",
"strsim",
"termcolor",
"textwrap",
]
+[[package]]
+name = "clap"
+version = "4.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e"
+dependencies = [
+ "atty",
+ "bitflags",
+ "clap_derive",
+ "clap_lex 0.3.0",
+ "once_cell",
+ "strsim",
+ "termcolor",
+]
+
[[package]]
name = "clap_derive"
-version = "3.2.18"
+version = "4.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
+checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
dependencies = [
"heck",
"proc-macro-error",
@@ -247,6 +260,15 @@ dependencies = [
"os_str_bytes",
]
+[[package]]
+name = "clap_lex"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
+dependencies = [
+ "os_str_bytes",
+]
+
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@@ -638,7 +660,7 @@ dependencies = [
"bitflags",
"byteorder",
"chrono",
- "clap",
+ "clap 3.2.23",
"crc32fast",
"dialoguer",
"encoding",
@@ -846,7 +868,7 @@ dependencies = [
"base64",
"bytesize",
"chrono",
- "clap",
+ "clap 4.0.26",
"comfy-table",
"compact_str",
"crossbeam-utils",
@@ -1154,7 +1176,7 @@ dependencies = [
"anyhow",
"atty",
"chrono",
- "clap",
+ "clap 3.2.23",
"file-chunker",
"memmap2",
"num_cpus",
diff --git a/Cargo.toml b/Cargo.toml
index e98591d7a..fa4ad1cee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,7 +8,7 @@ rust-version = "1.65.0"
[dependencies]
itertools = "*"
dashmap = "*"
-clap = { version = "3.*", features = ["derive", "cargo"]}
+clap = { version = "4.*", features = ["derive", "cargo", "color"]}
evtx = { git = "https://github.com/Yamato-Security/hayabusa-evtx.git" , features = ["fast-alloc"] , rev = "f07e263" } # 0.8.3 2022/11/20 update
quick-xml = {version = "0.25.*", features = ["serialize"] }
serde = { version = "1.*", features = ["derive"] }
diff --git a/README-Japanese.md b/README-Japanese.md
index dc8536954..bee84bb37 100644
--- a/README-Japanese.md
+++ b/README-Japanese.md
@@ -42,7 +42,7 @@ Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/)
- [スクリーンショット](#スクリーンショット)
- [起動画面](#起動画面)
- [ターミナル出力画面](#ターミナル出力画面)
- - [イベント頻度タイムライン出力画面 (`-V`オプション)](#イベント頻度タイムライン出力画面--vオプション)
+ - [イベント頻度タイムライン出力画面 (`-T`オプション)](#イベント頻度タイムライン出力画面--tオプション)
- [結果サマリ画面](#結果サマリ画面)
- [HTMLの結果サマリ (`-H`オプション)](#htmlの結果サマリ--hオプション)
- [Excelでの解析](#excelでの解析)
@@ -85,7 +85,7 @@ Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/)
- [プロファイルの比較](#プロファイルの比較)
- [Profile Field Aliases](#profile-field-aliases)
- [Levelの省略](#levelの省略)
- - [MITRE ATT&CK戦術の省略](#mitre-attck戦術の省略)
+ - [MITRE ATT\&CK戦術の省略](#mitre-attck戦術の省略)
- [Channel情報の省略](#channel情報の省略)
- [その他の省略](#その他の省略)
- [プログレスバー](#プログレスバー)
@@ -134,7 +134,7 @@ Hayabusaは従来のWindowsイベントログ分析解析と比較して、分
![Hayabusa ターミナル出力画面](screenshots/Hayabusa-Results.png)
-## イベント頻度タイムライン出力画面 (`-V`オプション)
+## イベント頻度タイムライン出力画面 (`-T`オプション)
![Hayabusa イベント頻度タイムライン出力画面](screenshots/HayabusaEventFrequencyTimeline.png)
@@ -394,63 +394,67 @@ macOSの環境設定から「セキュリティとプライバシー」を開き
## コマンドラインオプション
```
-USAGE:
- hayabusa.exe [OTHER-ACTIONS] [OPTIONS]
-
-INPUT:
- -d, --directory .evtxファイルを持つディレクトリのパス
- -f, --file 1つの.evtxファイルに対して解析を行う
- -l, --live-analysis ローカル端末のC:\Windows\System32\winevt\Logsフォルダを解析する
-
-ADVANCED:
- -c, --rules-config ルールフォルダのコンフィグディレクトリ (デフォルト: ./rules/config)
- -Q, --quiet-errors Quiet errorsモード: エラーログを保存しない
- -r, --rules ルールファイルまたはルールファイルを持つディレクトリ (デフォルト: ./rules)
- -t, --thread-number スレッド数 (デフォルト: パフォーマンスに最適な数値)
- --target-file-ext ... evtx以外の拡張子を解析対象に追加する。 (例1: evtx_data 例2:evtx1 evtx2)
-
-OUTPUT:
- -H, --html-report HTML形式で詳細な結果を出力する (例: results.html)
- -j, --json タイムラインの出力をJSON形式で保存する(例: -j -o results.json)
- -J, --jsonl タイムラインの出力をJSONL形式で保存する (例: -J -o results.jsonl)
- -o, --output タイムラインをCSV形式で保存する (例: results.csv)
- -P, --profile 利用する出力プロファイル名を指定する
-
-DISPLAY-SETTINGS:
- --debug デバッグ情報を出力する (メモリ使用量など)
- --no-color カラー出力を無効にする
- --no-summary 結果概要を出力しない
- -q, --quiet Quietモード: 起動バナーを表示しない
- -v, --verbose 詳細な情報を出力する
- -V, --visualize-timeline イベント頻度タイムラインを出力する
-
-FILTERING:
- -e, --eid-filter イベントIDによるフィルタリングを行う(コンフィグファイル: ./rules/config/target_event_IDs.txt`)
- --enable-deprecated-rules Deprecatedルールを有効にする
- --exclude-status ... 読み込み対象外とするルール内でのステータス (ex: experimental) (ex: stable test)
- -m, --min-level 結果出力をするルールの最低レベル (デフォルト: informational)
- -n, --enable-noisy-rules Noisyルールを有効にする
- --timeline-end 解析対象とするイベントログの終了時刻 (例: "2022-02-22 23:59:59 +09:00")
- --timeline-start 解析対象とするイベントログの開始時刻 (例: "2020-02-22 00:00:00 +09:00")
-
-OTHER-ACTIONS:
- --contributors コントリビュータの一覧表示
- -L, --logon-summary 成功と失敗したログオン情報の要約を出力する
- --level-tuning [] ルールlevelのチューニング (デフォルト: ./rules/config/level_tuning.txt)
- --list-profiles 利用可能な出力プロファイル名を出力する
- -M, --metrics イベントIDの統計情報を表示する
- -p, --pivot-keywords-list ピボットキーワードの一覧作成
- --set-default-profile デフォルトの出力コンフィグを設定する
- -u, --update-rules rulesフォルダをhayabusa-rulesのgithubリポジトリの最新版に更新する
-
-TIME-FORMAT:
- --European-time ヨーロッパ形式で日付と時刻を出力する (例: 22-02-2022 22:00:00.123 +02:00)
- --ISO-8601 ISO-8601形式で日付と時刻を出力する (ex: 2022-02-22T10:10:10.1234567Z) (Always UTC)
- --RFC-2822 RFC 2822形式で日付と時刻を出力する (例: Fri, 22 Feb 2022 22:00:00 -0600)
- --RFC-3339 RFC 3339形式で日付と時刻を出力する (例: 2022-02-22 22:00:00.123456-06:00)
- --US-military-time 24時間制(ミリタリータイム)のアメリカ形式で日付と時刻を出力する (例: 02-22-2022 22:00:00.123 -06:00)
- --US-time アメリカ形式で日付と時刻を出力する (例: 02-22-2022 10:00:00.123 PM -06:00)
- -U, --UTC UTC形式で日付と時刻を出力する (デフォルト: 現地時間)
+Usage:
+ hayabusa.exe [OTHER-ACTIONS] [OUTPUT] [OPTIONS]
+
+Options:
+ -h, --help ヘルプ画面の表示
+ -V, --version バージョンの表示
+
+Input:
+ -d, --directory .evtxファイルを持つディレクトリのパス
+ -f, --file 1つの.evtxファイルに対して解析を行う
+ -l, --live-analysis ローカル端末のC:\Windows\System32\winevt\Logsフォルダを解析する
+
+Advanced:
+ -c, --rules-config ルールフォルダのコンフィグディレクトリ (デフォルト: ./rules/config)
+ -Q, --quiet-errors Quiet errorsモード: エラーログを保存しない
+ -r, --rules ルールファイルまたはルールファイルを持つディレクトリ (デフォルト: ./rules)
+ -t, --thread-number スレッド数 (デフォルト: パフォーマンスに最適な数値)
+ --target-file-ext evtx以外の拡張子を解析対象に追加する。 (例1: evtx_data 例2:evtx1,evtx2)
+
+Output:
+ -H, --html-report HTML形式で詳細な結果を出力する (例: results.html)
+ -j, --json タイムラインの出力をJSON形式で保存する(例: -j -o results.json)
+ -J, --jsonl タイムラインの出力をJSONL形式で保存する (例: -J -o results.jsonl)
+ -o, --output タイムラインをCSV形式で保存する (例: results.csv)
+ -P, --profile 利用する出力プロファイル名を指定する
+
+Display Settings:
+ --no-color カラー出力を無効にする
+ --no-summary 結果概要を出力しない
+ -q, --quiet Quietモード: 起動バナーを表示しない
+ -v, --verbose 詳細な情報を出力する
+ -T, --visualize-timeline イベント頻度タイムラインを出力する
+ --debug デバッグ情報を出力する (メモリ使用量など)
+
+Filtering:
+ -e, --eid-filter イベントIDによるフィルタリングを行う(コンフィグファイル: ./rules/config/target_event_IDs.txt)
+ --enable-deprecated-rules Deprecatedルールを有効にする
+ --exclude-status 読み込み対象外とするルール内でのステータス (ex: experimental) (ex: stable,test)
+ -m, --min-level 結果出力をするルールの最低レベル (デフォルト: informational)
+ -n, --enable-noisy-rules Noisyルールを有効にする
+ --timeline-end 解析対象とするイベントログの終了時刻 (例: "2022-02-22 23:59:59 +09:00")
+ --timeline-start 解析対象とするイベントログの開始時刻 (例: "2020-02-22 00:00:00 +09:00")
+
+Other Actions:
+ --contributors コントリビュータの一覧表示
+ -L, --logon-summary 成功と失敗したログオン情報の要約を出力する
+ --level-tuning [] ルールlevelのチューニング (デフォルト: ./rules/config/level_tuning.txt)
+ --list-profiles 利用可能な出力プロファイル名を出力する
+ -M, --metrics イベントIDの統計情報を表示する
+ -p, --pivot-keywords-list ピボットキーワードの一覧作成
+ --set-default-profile デフォルトの出力コンフィグを設定する
+ -u, --update-rules rulesフォルダをhayabusa-rulesのgithubリポジトリの最新版に更新する
+
+Time Format:
+ --European-time ヨーロッパ形式で日付と時刻を出力する (例: 22-02-2022 22:00:00.123 +02:00)
+ --ISO-8601 ISO-8601形式で日付と時刻を出力する (ex: 2022-02-22T10:10:10.1234567Z) (いつもUTC)
+ --RFC-2822 RFC 2822形式で日付と時刻を出力する (例: Fri, 22 Feb 2022 22:00:00 -0600)
+ --RFC-3339 RFC 3339形式で日付と時刻を出力する (例: 2022-02-22 22:00:00.123456-06:00)
+ --US-military-time 24時間制(ミリタリータイム)のアメリカ形式で日付と時刻を出力する (例: 02-22-2022 22:00:00.123 -06:00)
+ --US-time アメリカ形式で日付と時刻を出力する (例: 02-22-2022 10:00:00.123 PM -06:00)
+ -U, --UTC UTC形式で日付と時刻を出力する (デフォルト: 現地時間)
```
## 使用例
@@ -845,7 +849,7 @@ Hayabusaの結果は`level`毎に文字色が変わります。
### イベント頻度タイムライン
-`-V`または`--visualize-timeline`オプションを使うことで、検知したイベントの数が5以上の時、頻度のタイムライン(スパークライン)を画面に出力します。
+`-T`または`--visualize-timeline`オプションを使うことで、検知したイベントの数が5以上の時、頻度のタイムライン(スパークライン)を画面に出力します。
マーカーの数は最大10個です。デフォルトのCommand PromptとPowerShell Promptでは文字化けがでるので、Windows TerminalやiTerm2等のターミナルをご利用ください。
# Hayabusaルール
diff --git a/README.md b/README.md
index 04bf105ea..aa3c0555b 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ Hayabusa is a **Windows event log fast forensics timeline generator** and **thre
- [Screenshots](#screenshots)
- [Startup](#startup)
- [Terminal Output](#terminal-output)
- - [Event Fequency Timeline (`-V` option)](#event-fequency-timeline--v-option)
+ - [Event Fequency Timeline (`-T` option)](#event-fequency-timeline--t-option)
- [Results Summary](#results-summary)
- [HTML Results Summary (`-H` option)](#html-results-summary--h-option)
- [Analysis in Excel](#analysis-in-excel)
@@ -85,7 +85,7 @@ Hayabusa is a **Windows event log fast forensics timeline generator** and **thre
- [Profile Comparison](#profile-comparison)
- [Profile Field Aliases](#profile-field-aliases)
- [Level Abbrevations](#level-abbrevations)
- - [MITRE ATT&CK Tactics Abbreviations](#mitre-attck-tactics-abbreviations)
+ - [MITRE ATT\&CK Tactics Abbreviations](#mitre-attck-tactics-abbreviations)
- [Channel Abbreviations](#channel-abbreviations)
- [Other Abbreviations](#other-abbreviations)
- [Progress Bar](#progress-bar)
@@ -129,7 +129,7 @@ Hayabusa hopes to let analysts get 80% of their work done in 20% of the time whe
![Hayabusa terminal output](screenshots/Hayabusa-Results.png)
-## Event Fequency Timeline (`-V` option)
+## Event Fequency Timeline (`-T` option)
![Hayabusa Event Frequency Timeline](screenshots/HayabusaEventFrequencyTimeline.png)
@@ -389,63 +389,67 @@ You should now be able to run hayabusa.
## Command Line Options
```
-USAGE:
- hayabusa.exe [OTHER-ACTIONS] [OPTIONS]
-
-INPUT:
- -d, --directory Directory of multiple .evtx files
- -f, --file File path to one .evtx file
- -l, --live-analysis Analyze the local C:\Windows\System32\winevt\Logs folder
-
-ADVANCED:
- -c, --rules-config Specify custom rule config directory (default: ./rules/config)
- -Q, --quiet-errors Quiet errors mode: do not save error logs
- -r, --rules Specify a custom rule directory or file (default: ./rules)
- -t, --thread-number Thread number (default: optimal number for performance)
- --target-file-ext ... Specify additional target file extensions (ex: evtx_data) (ex: evtx1 evtx2)
-
-OUTPUT:
- -H, --html-report Save detail Results Summary in html (ex: results.html)
- -j, --json Save the timeline in JSON format (ex: -j -o results.json)
- -J, --jsonl Save the timeline in JSONL format (ex: -J -o results.jsonl)
- -o, --output Save the timeline in CSV format (ex: results.csv)
- -P, --profile Specify output profile
-
-DISPLAY-SETTINGS:
- --debug Print debug information (memory usage, etc...)
- --no-color Disable color output
- --no-summary Do not display result summary
- -q, --quiet Quiet mode: do not display the launch banner
- -v, --verbose Output verbose information
- -V, --visualize-timeline Output event frequency timeline
-
-FILTERING:
- -e, --eid-filter Filter by Event IDs (config file: ./rules/config/target_event_IDs.txt)
- --enable-deprecated-rules Enable rules marked as deprecated
- --exclude-status ... Ignore rules according to status (ex: experimental) (ex: stable test)
- -m, --min-level Minimum level for rules (default: informational)
- -n, --enable-noisy-rules Enable rules marked as noisy
- --timeline-end End time of the event logs to load (ex: "2022-02-22 23:59:59 +09:00")
- --timeline-start Start time of the event logs to load (ex: "2020-02-22 00:00:00 +09:00")
-
-OTHER-ACTIONS:
- --contributors Print the list of contributors
- -L, --logon-summary Print a summary of successful and failed logons
- --level-tuning [] Tune alert levels (default: ./rules/config/level_tuning.txt)
- --list-profiles List the output profiles
- -M, --metrics Print event ID metrics
- -p, --pivot-keywords-list Create a list of pivot keywords
- --set-default-profile Set default output profile
- -u, --update-rules Update to the latest rules in the hayabusa-rules github repository
-
-TIME-FORMAT:
- --European-time Output timestamp in European time format (ex: 22-02-2022 22:00:00.123 +02:00)
- --ISO-8601 Output timestamp in ISO-8601 format (ex: 2022-02-22T10:10:10.1234567Z) (Always UTC)
- --RFC-2822 Output timestamp in RFC 2822 format (ex: Fri, 22 Feb 2022 22:00:00 -0600)
- --RFC-3339 Output timestamp in RFC 3339 format (ex: 2022-02-22 22:00:00.123456-06:00)
- --US-military-time Output timestamp in US military time format (ex: 02-22-2022 22:00:00.123 -06:00)
- --US-time Output timestamp in US time format (ex: 02-22-2022 10:00:00.123 PM -06:00)
- -U, --UTC Output time in UTC format (default: local time)
+Usage:
+ hayabusa.exe [OTHER-ACTIONS] [OUTPUT] [OPTIONS]
+
+Options:
+ -h, --help Print help information
+ -V, --version Print version information
+
+Input:
+ -d, --directory Directory of multiple .evtx files
+ -f, --file File path to one .evtx file
+ -l, --live-analysis Analyze the local C:\Windows\System32\winevt\Logs folder
+
+Advanced:
+ -c, --rules-config Specify custom rule config directory (default: ./rules/config)
+ -Q, --quiet-errors Quiet errors mode: do not save error logs
+ -r, --rules Specify a custom rule directory or file (default: ./rules)
+ -t, --thread-number Thread number (default: optimal number for performance)
+ --target-file-ext Specify additional target file extensions (ex: evtx_data) (ex: evtx1,evtx2)
+
+Output:
+ -H, --html-report Save detail Results Summary in html (ex: results.html)
+ -j, --json Save the timeline in JSON format (ex: -j -o results.json)
+ -J, --jsonl Save the timeline in JSONL format (ex: -J -o results.jsonl)
+ -o, --output Save the timeline in CSV format (ex: results.csv)
+ -P, --profile Specify output profile
+
+Display Settings:
+ --no-color Disable color output
+ --no-summary Do not display result summary
+ -q, --quiet Quiet mode: do not display the launch banner
+ -v, --verbose Output verbose information
+ -T, --visualize-timeline Output event frequency timeline
+ --debug Print debug information (memory usage, etc...)
+
+Filtering:
+ -e, --eid-filter Filter by Event IDs (config file: ./rules/config/target_event_IDs.txt)
+ --enable-deprecated-rules Enable rules marked as deprecated
+ --exclude-status Ignore rules according to status (ex: experimental) (ex: stable,test)
+ -m, --min-level Minimum level for rules (default: informational)
+ -n, --enable-noisy-rules Enable rules marked as noisy
+ --timeline-end End time of the event logs to load (ex: "2022-02-22 23:59:59 +09:00")
+ --timeline-start Start time of the event logs to load (ex: "2020-02-22 00:00:00 +09:00")
+
+Other Actions:
+ --contributors Print the list of contributors
+ -L, --logon-summary Print a summary of successful and failed logons
+ --level-tuning [] Tune alert levels (default: ./rules/config/level_tuning.txt)
+ --list-profiles List the output profiles
+ -M, --metrics Print event ID metrics
+ -p, --pivot-keywords-list Create a list of pivot keywords
+ --set-default-profile Set default output profile
+ -u, --update-rules Update to the latest rules in the hayabusa-rules github repository
+
+Time Format:
+ --European-time Output timestamp in European time format (ex: 22-02-2022 22:00:00.123 +02:00)
+ --ISO-8601 Output timestamp in ISO-8601 format (ex: 2022-02-22T10:10:10.1234567Z) (Always UTC)
+ --RFC-2822 Output timestamp in RFC 2822 format (ex: Fri, 22 Feb 2022 22:00:00 -0600)
+ --RFC-3339 Output timestamp in RFC 3339 format (ex: 2022-02-22 22:00:00.123456-06:00)
+ --US-military-time Output timestamp in US military time format (ex: 02-22-2022 22:00:00.123 -06:00)
+ --US-time Output timestamp in US time format (ex: 02-22-2022 10:00:00.123 PM -06:00)
+ -U, --UTC Output time in UTC format (default: local time)
```
## Usage Examples
@@ -839,7 +843,7 @@ Total events, the number of events with hits, data reduction metrics, total and
### Event Fequency Timeline
-If you add `-V` or `--visualize-timeline` option, the Event Frequency Timeline feature displays a sparkline frequency timeline of detected events.
+If you add `-T` or `--visualize-timeline` option, the Event Frequency Timeline feature displays a sparkline frequency timeline of detected events.
Note: There needs to be more than 5 events. Also, the characters will not render correctly on the default Command Prompt or PowerShell Prompt, so please use a terminal like Windows Terminal, iTerm2, etc...
# Hayabusa Rules
diff --git a/art/logo.txt b/art/logo.txt
index 1c52500b7..b308079b5 100644
--- a/art/logo.txt
+++ b/art/logo.txt
@@ -5,4 +5,4 @@
║╔═╗║╚═╝║╚╗╔╝║╚═╝║╔═╗║║ ║╠══╗║╚═╝║
║║ ║║╔═╗║ ║║ ║╔═╗║╚═╝║╚═╝║╚═╝║╔═╗║
╚╝ ╚╩╝ ╚╝ ╚╝ ╚╝ ╚╩═══╩═══╩═══╩╝ ╚╝
- by Yamato Security
\ No newline at end of file
+ by Yamato Security
diff --git a/src/afterfact.rs b/src/afterfact.rs
index a5f41a79a..404355923 100644
--- a/src/afterfact.rs
+++ b/src/afterfact.rs
@@ -49,7 +49,7 @@ pub fn set_output_color() -> HashMap {
.unwrap(),
);
let mut color_map: HashMap = HashMap::new();
- if configs::CONFIG.read().unwrap().args.no_color {
+ if configs::CONFIG.read().unwrap().no_color {
return color_map;
}
if read_result.is_err() {
@@ -170,7 +170,7 @@ pub fn after_fact(all_record_cnt: usize) {
let mut displayflag = false;
let mut target: Box =
- if let Some(csv_path) = &configs::CONFIG.read().unwrap().args.output {
+ if let Some(csv_path) = &configs::CONFIG.read().unwrap().output {
// output to file
match File::create(csv_path) {
Ok(file) => Box::new(BufWriter::new(file)),
@@ -207,9 +207,9 @@ fn emit_csv(
let html_output_flag = *HTML_REPORT_FLAG;
let disp_wtr = BufferWriter::stdout(ColorChoice::Always);
let mut disp_wtr_buf = disp_wtr.buffer();
- let json_output_flag = configs::CONFIG.read().unwrap().args.json_timeline;
- let jsonl_output_flag = configs::CONFIG.read().unwrap().args.jsonl_timeline;
- let is_no_summary = configs::CONFIG.read().unwrap().args.no_summary;
+ let json_output_flag = configs::CONFIG.read().unwrap().json_timeline;
+ let jsonl_output_flag = configs::CONFIG.read().unwrap().jsonl_timeline;
+ let is_no_summary = configs::CONFIG.read().unwrap().no_summary;
let mut wtr = if json_output_flag || jsonl_output_flag {
WriterBuilder::new()
@@ -427,7 +427,7 @@ fn emit_csv(
};
println!();
- if configs::CONFIG.read().unwrap().args.visualize_timeline {
+ if configs::CONFIG.read().unwrap().visualize_timeline {
_print_timeline_hist(timestamps, terminal_width, 3);
println!();
}
@@ -674,7 +674,7 @@ fn _print_unique_results(
} else {
(unique_counts_by_level[i] as f64) / (unique_total_count as f64) * 100.0
};
- if configs::CONFIG.read().unwrap().args.html_report.is_some() {
+ if configs::CONFIG.read().unwrap().html_report.is_some() {
total_detect_md.push(format!(
" - {}: {} ({:.2}%)",
level_name[0],
@@ -706,7 +706,7 @@ fn _print_unique_results(
)
.ok();
}
- if configs::CONFIG.read().unwrap().args.html_report.is_some() {
+ if configs::CONFIG.read().unwrap().html_report.is_some() {
html_output_stock.extend(total_detect_md.iter());
html_output_stock.extend(unique_detect_md.iter());
}
@@ -949,7 +949,7 @@ fn _print_detection_summary_tables(
/// get timestamp to input datetime.
fn _get_timestamp(time: &DateTime) -> i64 {
- if configs::CONFIG.read().unwrap().args.utc || configs::CONFIG.read().unwrap().args.iso_8601 {
+ if configs::CONFIG.read().unwrap().utc || configs::CONFIG.read().unwrap().iso_8601 {
time.timestamp()
} else {
let offset_sec = Local
diff --git a/src/detections/configs.rs b/src/detections/configs.rs
index 4ccfffa70..fc531b631 100644
--- a/src/detections/configs.rs
+++ b/src/detections/configs.rs
@@ -2,7 +2,7 @@ use crate::detections::message::AlertMessage;
use crate::detections::pivot::{PivotKeyword, PIVOT_KEYWORD};
use crate::detections::utils;
use chrono::{DateTime, Utc};
-use clap::{App, CommandFactory, Parser};
+use clap::{ColorChoice, Command, CommandFactory, Parser};
use hashbrown::{HashMap, HashSet};
use lazy_static::lazy_static;
use nested::Nested;
@@ -13,76 +13,64 @@ use std::sync::RwLock;
use terminal_size::{terminal_size, Width};
lazy_static! {
- pub static ref CONFIG: RwLock> = RwLock::new(ConfigReader::new());
+ pub static ref CONFIG: RwLock = RwLock::new(Config::parse());
+ pub static ref CURRENT_EXE_PATH: PathBuf =
+ current_exe().unwrap().parent().unwrap().to_path_buf();
pub static ref EVENTKEY_ALIAS: EventKeyAliasConfig = load_eventkey_alias(
- utils::check_setting_path(
- &CONFIG.read().unwrap().args.config,
- "eventkey_alias.txt",
- false
- )
- .unwrap_or_else(|| {
- utils::check_setting_path(
- &CURRENT_EXE_PATH.to_path_buf(),
- "rules/config/eventkey_alias.txt",
- true,
- )
+ utils::check_setting_path(&CONFIG.read().unwrap().config, "eventkey_alias.txt", false)
+ .unwrap_or_else(|| {
+ utils::check_setting_path(
+ &CURRENT_EXE_PATH.to_path_buf(),
+ "rules/config/eventkey_alias.txt",
+ true,
+ )
+ .unwrap()
+ })
+ .to_str()
.unwrap()
- })
- .to_str()
- .unwrap()
);
pub static ref IDS_REGEX: Regex =
Regex::new(r"^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$").unwrap();
- pub static ref CURRENT_EXE_PATH: PathBuf =
- current_exe().unwrap().parent().unwrap().to_path_buf();
}
-pub struct ConfigReader<'a> {
- pub app: App<'a>,
- pub args: Config,
+pub struct ConfigReader {
+ pub app: Command,
pub headless_help: String,
pub event_timeline_config: EventInfoConfig,
pub target_eventids: TargetEventIds,
}
-impl Default for ConfigReader<'_> {
+impl Default for ConfigReader {
fn default() -> Self {
Self::new()
}
}
#[derive(Parser, Clone)]
-#[clap(
+#[command(
name = "Hayabusa",
- usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]",
+ override_usage = "hayabusa.exe [OTHER-ACTIONS] [OUTPUT] [OPTIONS]",
author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)",
- help_template = "\n{name} {version}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n",
+ help_template = "\n{name} {version}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}",
version,
term_width = 400
)]
pub struct Config {
/// Directory of multiple .evtx files
- #[clap(help_heading = Some("INPUT"), short = 'd', long, value_name = "DIRECTORY")]
+ #[arg(help_heading = Some("Input"), short = 'd', long, value_name = "DIRECTORY")]
pub directory: Option,
/// File path to one .evtx file
- #[clap(help_heading = Some("INPUT"), short = 'f', long = "file", value_name = "FILE")]
+ #[arg(help_heading = Some("Input"), short = 'f', long = "file", value_name = "FILE")]
pub filepath: Option,
- /// Specify a custom rule directory or file (default: ./rules)
- #[clap(
- help_heading = Some("ADVANCED"),
- short = 'r',
- long,
- default_value = "./rules",
- hide_default_value = true,
- value_name = "DIRECTORY/FILE"
- )]
- pub rules: PathBuf,
+ /// Analyze the local C:\Windows\System32\winevt\Logs folder
+ #[arg(help_heading = Some("Input"), short = 'l', long = "live-analysis")]
+ pub live_analysis: bool,
/// Specify custom rule config directory (default: ./rules/config)
- #[clap(
- help_heading = Some("ADVANCED"),
+ #[arg(
+ help_heading = Some("Advanced"),
short = 'c',
long = "rules-config",
default_value = "./rules/config",
@@ -91,37 +79,88 @@ pub struct Config {
)]
pub config: PathBuf,
+ /// Quiet errors mode: do not save error logs
+ #[arg(help_heading = Some("Advanced"), short = 'Q', long = "quiet-errors")]
+ pub quiet_errors: bool,
+
+ /// Specify a custom rule directory or file (default: ./rules)
+ #[arg(
+ help_heading = Some("Advanced"),
+ short = 'r',
+ long,
+ default_value = "./rules",
+ hide_default_value = true,
+ value_name = "DIRECTORY/FILE"
+ )]
+ pub rules: PathBuf,
+
+ /// Thread number (default: optimal number for performance)
+ #[arg(help_heading = Some("Advanced"), short, long = "thread-number", value_name = "NUMBER")]
+ pub thread_number: Option,
+
+ /// Specify additional target file extensions (ex: evtx_data) (ex: evtx1,evtx2)
+ #[arg(help_heading = Some("Advanced"), long = "target-file-ext", use_value_delimiter = true, value_delimiter = ',')]
+ pub evtx_file_ext: Option>,
+
+ /// Save detail Results Summary in html (ex: results.html)
+ #[arg(help_heading = Some("Output"), short = 'H', long="html-report", value_name = "FILE")]
+ pub html_report: Option,
+
+ /// Save the timeline in JSON format (ex: -j -o results.json)
+ #[arg(help_heading = Some("Output"), short = 'j', long = "json", requires = "output")]
+ pub json_timeline: bool,
+
+ /// Save the timeline in JSONL format (ex: -J -o results.jsonl)
+ #[arg(help_heading = Some("Output"), short = 'J', long = "jsonl", requires = "output")]
+ pub jsonl_timeline: bool,
+
/// Save the timeline in CSV format (ex: results.csv)
- #[clap(help_heading = Some("OUTPUT"), short = 'o', long, value_name = "FILE")]
+ #[arg(help_heading = Some("Output"), short = 'o', long, value_name = "FILE")]
pub output: Option,
+ /// Specify output profile
+ #[arg(help_heading = Some("Output"), short = 'P', long = "profile")]
+ pub profile: Option,
+
+ /// Disable color output
+ #[arg(help_heading = Some("Display Settings"), long = "no-color")]
+ pub no_color: bool,
+
+ /// Do not display result summary
+ #[arg(help_heading = Some("Display Settings"), long = "no-summary")]
+ pub no_summary: bool,
+
+ /// Quiet mode: do not display the launch banner
+ #[arg(help_heading = Some("Display Settings"), short, long)]
+ pub quiet: bool,
+
/// Output verbose information
- #[clap(help_heading = Some("DISPLAY-SETTINGS"), short = 'v', long)]
+ #[arg(help_heading = Some("Display Settings"), short = 'v', long)]
pub verbose: bool,
/// Output event frequency timeline
- #[clap(help_heading = Some("DISPLAY-SETTINGS"), short = 'V', long = "visualize-timeline")]
+ #[arg(help_heading = Some("Display Settings"), short = 'T', long = "visualize-timeline")]
pub visualize_timeline: bool,
- /// Enable rules marked as deprecated
- #[clap(help_heading = Some("FILTERING"), long = "enable-deprecated-rules")]
- pub enable_deprecated_rules: bool,
+ /// Print debug information (memory usage, etc...)
+ #[clap(help_heading = Some("Display Settings"), long = "debug")]
+ pub debug: bool,
/// Filter by Event IDs (config file: ./rules/config/target_event_IDs.txt)
- #[clap(help_heading = Some("FILTERING"), short = 'e', long = "eid-filter")]
+ #[arg(help_heading = Some("Filtering"), short = 'e', long = "eid-filter")]
pub eid_filter: bool,
- /// Enable rules marked as noisy
- #[clap(help_heading = Some("FILTERING"), short = 'n', long = "enable-noisy-rules")]
- pub enable_noisy_rules: bool,
+ /// Enable rules marked as deprecated
+ #[arg(help_heading = Some("Filtering"), long = "enable-deprecated-rules")]
+ pub enable_deprecated_rules: bool,
- /// Update to the latest rules in the hayabusa-rules github repository
- #[clap(help_heading = Some("OTHER-ACTIONS"), short = 'u', long = "update-rules")]
- pub update_rules: bool,
+ /// Ignore rules according to status (ex: experimental) (ex: stable,test)
+ #[arg(help_heading = Some("Filtering"), long = "exclude-status", value_name = "STATUS", use_value_delimiter = true, value_delimiter = ',')]
+ pub exclude_status: Option>,
/// Minimum level for rules (default: informational)
- #[clap(
- help_heading = Some("FILTERING"),
+ #[arg(
+ help_heading = Some("Filtering"),
short = 'm',
long = "min-level",
default_value = "informational",
@@ -130,129 +169,85 @@ pub struct Config {
)]
pub min_level: String,
- /// Analyze the local C:\Windows\System32\winevt\Logs folder
- #[clap(help_heading = Some("INPUT"), short = 'l', long = "live-analysis")]
- pub live_analysis: bool,
-
- /// Start time of the event logs to load (ex: "2020-02-22 00:00:00 +09:00")
- #[clap(help_heading = Some("FILTERING"), long = "timeline-start", value_name = "DATE")]
- pub start_timeline: Option,
+ /// Enable rules marked as noisy
+ #[arg(help_heading = Some("Filtering"), short = 'n', long = "enable-noisy-rules")]
+ pub enable_noisy_rules: bool,
/// End time of the event logs to load (ex: "2022-02-22 23:59:59 +09:00")
- #[clap(help_heading = Some("FILTERING"), long = "timeline-end", value_name = "DATE")]
+ #[arg(help_heading = Some("Filtering"), long = "timeline-end", value_name = "DATE")]
pub end_timeline: Option,
- /// Output timestamp in RFC 2822 format (ex: Fri, 22 Feb 2022 22:00:00 -0600)
- #[clap(help_heading = Some("TIME-FORMAT"), long = "RFC-2822")]
- pub rfc_2822: bool,
-
- /// Output timestamp in RFC 3339 format (ex: 2022-02-22 22:00:00.123456-06:00)
- #[clap(help_heading = Some("TIME-FORMAT"), long = "RFC-3339")]
- pub rfc_3339: bool,
-
- /// Output timestamp in US time format (ex: 02-22-2022 10:00:00.123 PM -06:00)
- #[clap(help_heading = Some("TIME-FORMAT"), long = "US-time")]
- pub us_time: bool,
-
- /// Output timestamp in ISO-8601 format (ex: 2022-02-22T10:10:10.1234567Z) (Always UTC)
- #[clap(help_heading = Some("TIME-FORMAT"), long = "ISO-8601")]
- pub iso_8601: bool,
-
- /// Output timestamp in US military time format (ex: 02-22-2022 22:00:00.123 -06:00)
- #[clap(help_heading = Some("TIME-FORMAT"), long = "US-military-time")]
- pub us_military_time: bool,
-
- /// Output timestamp in European time format (ex: 22-02-2022 22:00:00.123 +02:00)
- #[clap(help_heading = Some("TIME-FORMAT"), long = "European-time")]
- pub european_time: bool,
-
- /// Output time in UTC format (default: local time)
- #[clap(help_heading = Some("TIME-FORMAT"), short = 'U', long = "UTC")]
- pub utc: bool,
-
- /// Disable color output
- #[clap(help_heading = Some("DISPLAY-SETTINGS"), long = "no-color")]
- pub no_color: bool,
-
- /// Thread number (default: optimal number for performance)
- #[clap(help_heading = Some("ADVANCED"), short, long = "thread-number", value_name = "NUMBER")]
- pub thread_number: Option,
+ /// Start time of the event logs to load (ex: "2020-02-22 00:00:00 +09:00")
+ #[arg(help_heading = Some("Filtering"), long = "timeline-start", value_name = "DATE")]
+ pub start_timeline: Option,
- /// Print event ID metrics
- #[clap(help_heading = Some("OTHER-ACTIONS"), short='M', long)]
- pub metrics: bool,
+ /// Print the list of contributors
+ #[arg(help_heading = Some("Other Actions"), long)]
+ pub contributors: bool,
/// Print a summary of successful and failed logons
- #[clap(help_heading = Some("OTHER-ACTIONS"), short = 'L', long = "logon-summary")]
+ #[arg(help_heading = Some("Other Actions"), short = 'L', long = "logon-summary")]
pub logon_summary: bool,
/// Tune alert levels (default: ./rules/config/level_tuning.txt)
- #[clap(
- help_heading = Some("OTHER-ACTIONS"),
+ #[arg(
+ help_heading = Some("Other Actions"),
long = "level-tuning",
hide_default_value = true,
value_name = "FILE"
)]
pub level_tuning: Option