From 4f9b4559dba1c25f92e49f33df129002c65f13a4 Mon Sep 17 00:00:00 2001 From: Tanaka Zakku <71482215+YamatoSecurity@users.noreply.github.com> Date: Mon, 8 Aug 2022 23:58:10 +0900 Subject: [PATCH 01/21] organize menu --- src/detections/configs.rs | 76 ++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index a0ac1b74..aecab75b 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -55,70 +55,73 @@ impl Default for ConfigReader<'_> { #[derive(Parser)] #[clap( name = "Hayabusa", - usage = "hayabusa.exe -f file.evtx [OPTIONS] / hayabusa.exe -d evtx-directory [OPTIONS]", + usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", version, term_width = 400 )] pub struct Config { /// Directory of multiple .evtx files - #[clap(short = 'd', long, value_name = "DIRECTORY")] + #[clap(help_heading = Some("INPUT"), short = 'd', long, value_name = "DIRECTORY")] pub directory: Option, /// File path to one .evtx file - #[clap(short = 'f', long, value_name = "FILE_PATH")] + #[clap(help_heading = Some("INPUT"), short = 'f', long = "file", value_name = "FILE")] pub filepath: Option, - /// Specify a rule directory or file (default: ./rules) + /// 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 = "RULE_DIRECTORY/RULE_FILE" + value_name = "DIRECTORY/FILE" )] pub rules: PathBuf, - /// Specify custom rule config folder (default: ./rules/config) + /// Specify custom rule config directory (default: ./rules/config) #[clap( + help_heading = Some("ADVANCED"), short = 'c', long = "rules-config", default_value = "./rules/config", hide_default_value = true, - value_name = "RULE_CONFIG_DIRECTORY" + value_name = "DIRECTORY" )] pub config: PathBuf, /// Save the timeline in CSV format (ex: results.csv) - #[clap(short = 'o', long, value_name = "CSV_TIMELINE")] + #[clap(help_heading = Some("OUTPUT"), short = 'o', long, value_name = "FILE")] pub output: Option, /// Output verbose information - #[clap(short = 'v', long)] + #[clap(help_heading = Some("DISPLAY-SETTINGS"), short = 'v', long)] pub verbose: bool, /// Output event frequency timeline - #[clap(short = 'V', long = "visualize-timeline")] + #[clap(help_heading = Some("DISPLAY-SETTINGS"), short = 'V', long = "visualize-timeline")] pub visualize_timeline: bool, /// Enable rules marked as deprecated - #[clap(long = "enable-deprecated-rules")] + #[clap(help_heading = Some("FILTERING"), long = "enable-deprecated-rules")] pub enable_deprecated_rules: bool, /// Disable event ID filter to scan all events - #[clap(short = 'D', long = "deep-scan")] + #[clap(help_heading = Some("FILTERING"), short = 'D', long = "deep-scan")] pub deep_scan: bool, /// Enable rules marked as noisy - #[clap(short = 'n', long = "enable-noisy-rules")] + #[clap(help_heading = Some("FILTERING"), short = 'n', long = "enable-noisy-rules")] pub enable_noisy_rules: bool, /// Update to the latest rules in the hayabusa-rules github repository - #[clap(short = 'u', long = "update-rules")] + #[clap(help_heading = Some("OTHER-ACTIONS"), short = 'u', long = "update-rules")] pub update_rules: bool, /// Minimum level for rules (default: informational) #[clap( + help_heading = Some("FILTERING"), short = 'm', long = "min-level", default_value = "informational", @@ -128,95 +131,96 @@ pub struct Config { pub min_level: String, /// Analyze the local C:\Windows\System32\winevt\Logs folder - #[clap(short = 'l', long = "live-analysis")] + #[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(long = "start-timeline", value_name = "START_TIMELINE")] + #[clap(help_heading = Some("FILTERING"), long = "timeline-start", value_name = "DATE")] pub start_timeline: Option, /// End time of the event logs to load (ex: "2022-02-22 23:59:59 +09:00") - #[clap(long = "end-timeline", value_name = "END_TIMELINE")] + #[clap(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(long = "RFC-2822")] + #[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(long = "RFC-3339")] + #[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(long = "US-time")] + #[clap(help_heading = Some("TIME-FORMAT"), long = "US-time")] pub us_time: bool, /// Output timestamp in US military time format (ex: 02-22-2022 22:00:00.123 -06:00) - #[clap(long = "US-military-time")] + #[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(long = "European-time")] + #[clap(help_heading = Some("TIME-FORMAT"), long = "European-time")] pub european_time: bool, /// Output time in UTC format (default: local time) - #[clap(short = 'U', long = "UTC")] + #[clap(help_heading = Some("TIME-FORMAT"), short = 'U', long = "UTC")] pub utc: bool, /// Disable color output - #[clap(long = "no-color")] + #[clap(help_heading = Some("DISPLAY-SETTINGS"), long = "no-color")] pub no_color: bool, /// Thread number (default: optimal number for performance) - #[clap(short, long = "thread-number", value_name = "NUMBER")] + #[clap(help_heading = Some("ADVANCED"), short, long = "thread-number", value_name = "NUMBER")] pub thread_number: Option, /// Print statistics of event IDs - #[clap(short, long)] + #[clap(help_heading = Some("OTHER-ACTIONS"), short, long)] pub statistics: bool, /// Print a summary of successful and failed logons - #[clap(short = 'L', long = "logon-summary")] + #[clap(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("ADVANCED"), long = "level-tuning", hide_default_value = true, - value_name = "LEVEL_TUNING_FILE" + value_name = "FILE" )] pub level_tuning: Option>, /// Quiet mode: do not display the launch banner - #[clap(short, long)] + #[clap(help_heading = Some("DISPLAY-SETTINGS"), short, long)] pub quiet: bool, /// Quiet errors mode: do not save error logs - #[clap(short = 'Q', long = "quiet-errors")] + #[clap(help_heading = Some("ADVANCED"), short = 'Q', long = "quiet-errors")] pub quiet_errors: bool, /// Create a list of pivot keywords - #[clap(short = 'p', long = "pivot-keywords-list")] + #[clap(help_heading = Some("OTHER-ACTIONS"), short = 'p', long = "pivot-keywords-list")] pub pivot_keywords_list: bool, /// Print the list of contributors - #[clap(long)] + #[clap(help_heading = Some("OTHER-ACTIONS"), long)] pub contributors: bool, /// Specify additional target file extensions (ex: evtx_data) (ex: evtx1 evtx2) - #[clap(long = "target-file-ext", multiple_values = true)] + #[clap(help_heading = Some("ADVANCED"), long = "target-file-ext", multiple_values = true)] pub evtx_file_ext: Option>, /// Ignore rules according to status (ex: experimental) (ex: stable test) - #[clap(long = "exclude-status", multiple_values = true)] + #[clap(help_heading = Some("FILTERING"), long = "exclude-status", multiple_values = true, value_name = "STATUS")] pub exclude_status: Option>, /// Specify output profile - #[clap(short = 'P', long = "profile")] + #[clap(help_heading = Some("OUTPUT-SETTINGS"), short = 'P', long = "profile")] pub profile: Option, /// Set default output profile - #[clap(long = "set-default-profile")] + #[clap(help_heading = Some("OUTPUT-SETTINGS"), long = "set-default-profile", value_name = "PROFILE")] pub set_default_profile: Option, } From a74681f8fd9e99d597629089767388dd97c41f36 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 10 Aug 2022 02:26:56 +0900 Subject: [PATCH 02/21] fixed organized menu when args is empty #651 --- src/detections/configs.rs | 1 + src/main.rs | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index aecab75b..7518db47 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -58,6 +58,7 @@ impl Default for ConfigReader<'_> { usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", version, + arg_required_else_help = true, term_width = 400 )] pub struct Config { diff --git a/src/main.rs b/src/main.rs index b7fe4801..f19bc556 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,13 +89,6 @@ impl App { return; } let analysis_start_time: DateTime = Local::now(); - // Show usage when no arguments. - if std::env::args().len() == 1 { - self.output_logo(); - configs::CONFIG.write().unwrap().app.print_help().ok(); - println!(); - return; - } if !configs::CONFIG.read().unwrap().args.quiet { self.output_logo(); println!(); From 5807aca14df318fe28f17de4aab8bc5420966b2f Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 10 Aug 2022 02:30:21 +0900 Subject: [PATCH 03/21] updated changelog #651 --- CHANGELOG-Japanese.md | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index b79fafdc..5fb9acd3 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -10,6 +10,7 @@ - ルールのアップデート機能のルールパスの出力から./を削除した。 (#642) (@hitenkoku) - MITRE ATT&CK関連のタグとその他タグを出力するための出力用のエイリアスを追加した。 (#637) (@hitenkoku) +- メニューを使いやすいようにグループ化した。 (#651) (@YamatoSecurity and @hitenkoku) **バグ修正:** diff --git a/CHANGELOG.md b/CHANGELOG.md index f27030c9..2f5ec70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Removed ./ from rule path when updating. (#642) (@hitenkoku) - Added new output alias for MITRE ATT&CK tags and other tags. (#637) (@hitenkoku) +- Organized menu (#651) (@YamatoSecurity and @hitenkoku) **Bug Fixes:** From b01a85136fe3527d593a36aa651b2fb4f9aeb42a Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 10 Aug 2022 02:40:54 +0900 Subject: [PATCH 04/21] updated usage options #651 --- README-Japanese.md | 88 +++++++++++++++++++++++++++------------------- README.md | 88 +++++++++++++++++++++++++++------------------- 2 files changed, 104 insertions(+), 72 deletions(-) diff --git a/README-Japanese.md b/README-Japanese.md index 5ad1a294..0a7f21ba 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -327,42 +327,58 @@ USAGE: hayabusa.exe -f file.evtx [OPTIONS] / hayabusa.exe -d evtx-directory [OPTIONS] OPTIONS: - --European-time ヨーロッパ形式で日付と時刻を出力する (例: 22-02-2022 22:00:00.123 +02:00) - --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) - -c, --rules-config ルールフォルダのコンフィグディレクトリ (デフォルト: ./rules/config) - --contributors コントリビュータの一覧表示 - -d, --directory .evtxファイルを持つディレクトリのパス - -D, --deep-scan すべてのイベントIDを対象にしたスキャンを行う - --enable-deprecated-rules Deprecatedルールを有効にする - --end-timeline 解析対象とするイベントログの終了時刻 (例: "2022-02-22 23:59:59 +09:00") - --exclude-status ... 読み込み対象外とするルール内でのステータス (ex: experimental) (ex: stable test) - -f, --filepath 1つの.evtxファイルに対して解析を行う - -h, --help ヘルプ情報を表示する - -l, --live-analysis ローカル端末のC:\Windows\System32\winevt\Logsフォルダを解析する - -L, --logon-summary 成功と失敗したログオン情報の要約を出力する - --level-tuning [] ルールlevelのチューニング (デフォルト: ./rules/config/level_tuning.txt) - -m, --min-level 結果出力をするルールの最低レベル (デフォルト: informational) - -n, --enable-noisy-rules Noisyルールを有効にする - --no_color カラー出力を無効にする - -o, --output タイムラインをCSV形式で保存する (例: results.csv) - -p, --pivot-keywords-list ピボットキーワードの一覧作成 - -P, --profile 利用する出力プロファイル名を指定する - -q, --quiet Quietモード: 起動バナーを表示しない - -Q, --quiet-errors Quiet errorsモード: エラーログを保存しない - -r, --rules ルールファイルまたはルールファイルを持つディレクトリ (デフォルト: ./rules) - -s, --statistics イベントIDの統計情報を表示する - --set-default-profile デフォルトの出力コンフィグを設定する - --start-timeline 解析対象とするイベントログの開始時刻 (例: "2020-02-22 00:00:00 +09:00") - -t, --thread-number スレッド数 (デフォルト: パフォーマンスに最適な数値) - --target-file-ext ... evtx以外の拡張子を解析対象に追加する。 (例1: evtx_data 例2:evtx1 evtx2) - -u, --update-rules rulesフォルダをhayabusa-rulesのgithubリポジトリの最新版に更新する - -U, --UTC UTC形式で日付と時刻を出力する (デフォルト: 現地時間) - -v, --verbose 詳細な情報を出力する - -V, --visualize-timeline イベント頻度タイムラインを出力する - --version バージョン情報を表示する + -h, --help ヘルプ情報を表示する + --version バージョン情報を表示する + +INPUT: + -d, --directory .evtxファイルを持つディレクトリのパス + -f, --file 1つの.evtxファイルに対して解析を行う + -l, --live-analysis ローカル端末のC:\Windows\System32\winevt\Logsフォルダを解析する + +ADVANCED: + -c, --rules-config ルールフォルダのコンフィグディレクトリ (デフォルト: ./rules/config) + --level-tuning [] ルールlevelのチューニング (デフォルト: ./rules/config/level_tuning.txt) + -Q, --quiet-errors Quiet errorsモード: エラーログを保存しない + -r, --rules ルールファイルまたはルールファイルを持つディレクトリ (デフォルト: ./rules) + -t, --thread-number スレッド数 (デフォルト: パフォーマンスに最適な数値) + --target-file-ext ... evtx以外の拡張子を解析対象に追加する。 (例1: evtx_data 例2:evtx1 evtx2) + +OUTPUT: + -o, --output タイムラインをCSV形式で保存する (例: results.csv) + +DISPLAY-SETTINGS: + --no-color カラー出力を無効にする + -q, --quiet Quietモード: 起動バナーを表示しない + -v, --verbose 詳細な情報を出力する + -V, --visualize-timeline イベント頻度タイムラインを出力する + +FILTERING: + -D, --deep-scan すべてのイベントIDを対象にしたスキャンを行う + --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 成功と失敗したログオン情報の要約を出力する + -p, --pivot-keywords-list ピボットキーワードの一覧作成 + -s, --statistics イベントIDの統計情報を表示する + -u, --update-rules rulesフォルダをhayabusa-rulesのgithubリポジトリの最新版に更新する + +TIME-FORMAT: + --European-time ヨーロッパ形式で日付と時刻を出力する (例: 22-02-2022 22:00:00.123 +02:00) + --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形式で日付と時刻を出力する (デフォルト: 現地時間) + +OUTPUT-SETTINGS: + -P, --profile 利用する出力プロファイル名を指定する + --set-default-profile デフォルトの出力コンフィグを設定する ``` ## 使用例 diff --git a/README.md b/README.md index 9928086c..a370afe6 100644 --- a/README.md +++ b/README.md @@ -323,42 +323,58 @@ USAGE: hayabusa.exe -f file.evtx [OPTIONS] / hayabusa.exe -d evtx-directory [OPTIONS] OPTIONS: - --European-time Output timestamp in European time format (ex: 22-02-2022 22:00:00.123 +02:00) - --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) - -c, --rules-config Specify custom rule config folder (default: ./rules/config) - --contributors Print the list of contributors - -d, --directory Directory of multiple .evtx files - -D, --deep-scan Disable event ID filter to scan all events - --enable-deprecated-rules Enable rules marked as deprecated - --end-timeline End time of the event logs to load (ex: "2022-02-22 23:59:59 +09:00") - --exclude-status ... Ignore rules according to status (ex: experimental) (ex: stable test) - -f, --filepath File path to one .evtx file - -h, --help Print help information - -l, --live-analysis Analyze the local C:\Windows\System32\winevt\Logs folder - -L, --logon-summary Print a summary of successful and failed logons - --level-tuning [] Tune alert levels (default: ./rules/config/level_tuning.txt) - -m, --min-level Minimum level for rules (default: informational) - -n, --enable-noisy-rules Enable rules marked as noisy - --no-color Disable color output - -o, --output Save the timeline in CSV format (ex: results.csv) - -p, --pivot-keywords-list Create a list of pivot keywords - -P, --profile Specify output profile - -q, --quiet Quiet mode: do not display the launch banner - -Q, --quiet-errors Quiet errors mode: do not save error logs - -r, --rules Specify a rule directory or file (default: ./rules) - -s, --statistics Print statistics of event IDs - --set-default-profile Set default output profile - --start-timeline Start time of the event logs to load (ex: "2020-02-22 00:00:00 +09:00") - -t, --thread-number Thread number (default: optimal number for performance) - --target-file-ext ... Specify additional target file extensions (ex: evtx_data) (ex: evtx1 evtx2) - -u, --update-rules Update to the latest rules in the hayabusa-rules github repository - -U, --UTC Output time in UTC format (default: local time) - -v, --verbose Output verbose information - -V, --visualize-timeline Output event frequency timeline - --version Print version information + -h, --help Print help information + --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) + --level-tuning [] Tune alert levels (default: ./rules/config/level_tuning.txt) + -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: + -o, --output Save the timeline in CSV format (ex: results.csv) + +DISPLAY-SETTINGS: + --no-color Disable color output + -q, --quiet Quiet mode: do not display the launch banner + -v, --verbose Output verbose information + -V, --visualize-timeline Output event frequency timeline + +FILTERING: + -D, --deep-scan Disable event ID filter to scan all events + --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 + -p, --pivot-keywords-list Create a list of pivot keywords + -s, --statistics Print statistics of event IDs + -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) + --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) + +OUTPUT-SETTINGS: + -P, --profile Specify output profile + --set-default-profile Set default output profile ``` ## Usage Examples From 92895ccc9a3de3d30ae647019c2dde22f4765261 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 10 Aug 2022 03:12:51 +0900 Subject: [PATCH 05/21] to adjust changed usage --- README-Japanese.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-Japanese.md b/README-Japanese.md index 6e68d697..1759e3f5 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -324,7 +324,7 @@ macOSの環境設定から「セキュリティとプライバシー」を開き ``` USAGE: - hayabusa.exe -f file.evtx [OPTIONS] / hayabusa.exe -d evtx-directory [OPTIONS] + hayabusa.exe [OTHER-ACTIONS] [OPTIONS] OPTIONS: -h, --help ヘルプ情報を表示する diff --git a/README.md b/README.md index b66ad376..e3e6ff89 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,7 @@ You should now be able to run hayabusa. ``` USAGE: - hayabusa.exe -f file.evtx [OPTIONS] / hayabusa.exe -d evtx-directory [OPTIONS] + hayabusa.exe [OTHER-ACTIONS] [OPTIONS] OPTIONS: -h, --help Print help information From e7f29a8c3083361c5f8ab027a0fe8137b841500a Mon Sep 17 00:00:00 2001 From: Tanaka Zakku <71482215+YamatoSecurity@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:38:31 +0900 Subject: [PATCH 06/21] ignore hayabusa binaries --- .gitignore | 3 ++- README-Japanese.md | 2 +- README.md | 2 +- hayabusa-logo.png => logo.png | Bin 4 files changed, 4 insertions(+), 3 deletions(-) rename hayabusa-logo.png => logo.png (100%) diff --git a/.gitignore b/.gitignore index eafef81f..eec35107 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ test_* .env /logs -*.csv \ No newline at end of file +*.csv +hayabusa* \ No newline at end of file diff --git a/README-Japanese.md b/README-Japanese.md index 1759e3f5..ad8f7b8a 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -1,6 +1,6 @@

- Hayabusa Logo + Hayabusa Logo

[English] | [日本語]
diff --git a/README.md b/README.md index e3e6ff89..0f23c0dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- Hayabusa Logo + Hayabusa Logo

[ English ] | [日本語]
diff --git a/hayabusa-logo.png b/logo.png similarity index 100% rename from hayabusa-logo.png rename to logo.png From c7f44bd315acabcf4cdb0ecdb89f31f1c2d43c4e Mon Sep 17 00:00:00 2001 From: Tanaka Zakku <71482215+YamatoSecurity@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:48:32 +0900 Subject: [PATCH 07/21] updated menu --- src/detections/configs.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 7518db47..637bf772 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -185,7 +185,7 @@ pub struct Config { /// Tune alert levels (default: ./rules/config/level_tuning.txt) #[clap( - help_heading = Some("ADVANCED"), + help_heading = Some("OTHER-ACTIONS"), long = "level-tuning", hide_default_value = true, value_name = "FILE" @@ -216,12 +216,12 @@ pub struct Config { #[clap(help_heading = Some("FILTERING"), long = "exclude-status", multiple_values = true, value_name = "STATUS")] pub exclude_status: Option>, - /// Specify output profile - #[clap(help_heading = Some("OUTPUT-SETTINGS"), short = 'P', long = "profile")] + /// Specify output profile (minimal, standard, verbose, verbose-all-field-info, verbose-details-and-all-field-info) + #[clap(help_heading = Some("OUTPUT"), short = 'P', long = "profile")] pub profile: Option, - /// Set default output profile - #[clap(help_heading = Some("OUTPUT-SETTINGS"), long = "set-default-profile", value_name = "PROFILE")] + /// Set default output profile (minimal, standard, verbose, verbose-all-field-info, verbose-details-and-all-field-info) + #[clap(help_heading = Some("OTHER-ACTIONS"), long = "set-default-profile", value_name = "PROFILE")] pub set_default_profile: Option, } From 09240212e87627fc4e32355c2d6ca9575ddea330 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 10 Aug 2022 20:44:26 +0900 Subject: [PATCH 08/21] add new line help --- src/detections/configs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 7518db47..b98b4f45 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -57,8 +57,9 @@ impl Default for ConfigReader<'_> { name = "Hayabusa", usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", + help_template = "\n{name}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", version, - arg_required_else_help = true, + arg_required_else_help (true), term_width = 400 )] pub struct Config { From 5d48ad4a2612d334108a49eee979b6eff18293d5 Mon Sep 17 00:00:00 2001 From: Yamato Security <71482215+YamatoSecurity@users.noreply.github.com> Date: Thu, 11 Aug 2022 00:29:48 +0900 Subject: [PATCH 09/21] update readme --- Cargo.lock | 85 +++++++++++--- README-Japanese.md | 223 +++++++++++++++++++++++-------------- README.md | 226 +++++++++++++++++++++++--------------- src/detections/configs.rs | 2 +- 4 files changed, 343 insertions(+), 193 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 809de233..8e1386c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -200,15 +209,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "3f725f340c3854e3cb3ab736dc21f0cca183303acea3b3ffec30f141503ac8eb" dependencies = [ - "libc", + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "serde", "time 0.1.44", + "wasm-bindgen", "winapi", ] @@ -292,6 +303,22 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "crc32fast" version = "1.3.2" @@ -793,7 +820,7 @@ checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 1.0.2", + "itoa 1.0.3", ] [[package]] @@ -842,7 +869,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.2", + "itoa 1.0.3", "pin-project-lite", "tokio", "tower-service", @@ -850,6 +877,19 @@ dependencies = [ "want", ] +[[package]] +name = "iana-time-zone" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1779539f58004e5dba1c1f093d44325ebeb244bfc04b791acdc0aaeca9c04570" +dependencies = [ + "android_system_properties", + "core-foundation", + "js-sys", + "wasm-bindgen", + "winapi", +] + [[package]] name = "idna" version = "0.2.3" @@ -930,9 +970,9 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "jemalloc-sys" @@ -964,6 +1004,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "krapslog" version = "0.4.0" @@ -993,9 +1042,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "64de3cc433455c14174d42e554d4027ee631c4d046d43e3ecc6efc4636cdc7a7" [[package]] name = "libgit2-sys" @@ -1586,18 +1635,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.141" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7af873f2c95b99fcb0bd0fe622a43e29514658873c8ceba88c4cb88833a22500" +checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.141" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75743a150d003dd863b51dc809bcad0d73f2102c53632f1e954e738192a3413f" +checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391" dependencies = [ "proc-macro2", "quote", @@ -1606,11 +1655,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" dependencies = [ - "itoa 1.0.2", + "itoa 1.0.3", "ryu", "serde", ] @@ -2002,9 +2051,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" [[package]] name = "unicode-normalization" diff --git a/README-Japanese.md b/README-Japanese.md index ad8f7b8a..2dee460d 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -48,19 +48,28 @@ Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/) - [32ビットWindowsバイナリのクロスコンパイル](#32ビットwindowsバイナリのクロスコンパイル) - [macOSでのコンパイルの注意点](#macosでのコンパイルの注意点) - [Linuxでのコンパイルの注意点](#linuxでのコンパイルの注意点) + - [LinuxのMUSLバイナリのクロスコンパイル](#linuxのmuslバイナリのクロスコンパイル) + - [Linuxでのコンパイルの注意点](#linuxでのコンパイルの注意点-1) - [Hayabusaの実行](#hayabusaの実行) - [注意: アンチウィルス/EDRの誤検知と遅い初回実行](#注意-アンチウィルスedrの誤検知と遅い初回実行) - [Windows](#windows) - [Linux](#linux) - [macOS](#macos) - [使用方法](#使用方法) + - [主なコマンド](#主なコマンド) - [コマンドラインオプション](#コマンドラインオプション) - [使用例](#使用例) - [ピボットキーワードの作成](#ピボットキーワードの作成) - [ログオン情報の要約](#ログオン情報の要約) - [サンプルevtxファイルでHayabusaをテストする](#サンプルevtxファイルでhayabusaをテストする) -- [Hayabusaの出力](#hayabusaの出力) - - [プロファイルによる出力のカスタマイズ](#プロファイルによる出力のカスタマイズ) +- [Hayabusaの出力プロファイル](#hayabusaの出力プロファイル) + - [1. `minimal`プロファイルの出力](#1-minimalプロファイルの出力) + - [2. `standard`プロファイルの出力](#2-standardプロファイルの出力) + - [3. `verbose`プロファイルの出力](#3-verboseプロファイルの出力) + - [4. `verbose-all-field-info`プロファイルの出力](#4-verbose-all-field-infoプロファイルの出力) + - [5. `verbose-details-and-all-field-info`プロファイルの出力](#5-verbose-details-and-all-field-infoプロファイルの出力) + - [プロファイルの比較](#プロファイルの比較) + - [Profile Field Aliases](#profile-field-aliases) - [Levelの省略](#levelの省略) - [MITRE ATT&CK戦術の省略](#mitre-attck戦術の省略) - [Channel情報の省略](#channel情報の省略) @@ -183,7 +192,7 @@ git clone https://github.com/Yamato-Security/hayabusa.git --recursive `git pull --recurse-submodules`コマンド、もしくは以下のコマンドで`rules`フォルダを同期し、Hayabusaの最新のルールを更新することができます: ```bash -hayabusa-1.4.3-win-x64.exe -u +hayabusa-1.5.0-win-x64.exe -u ``` アップデートが失敗した場合は、`rules`フォルダの名前を変更してから、もう一回アップデートしてみて下さい。 @@ -198,7 +207,6 @@ hayabusa-1.4.3-win-x64.exe -u Rustがインストールされている場合、以下のコマンドでソースコードからコンパイルすることができます: ```bash -cargo clean cargo build --release ``` @@ -254,6 +262,24 @@ Fedora系のディストロ: sudo yum install openssl-devel ``` +## LinuxのMUSLバイナリのクロスコンパイル + +まず、Linux OSでターゲットをインストールします。 + +```bash +rustup install stable-x86_64-unknown-linux-musl +rustup target add x86_64-unknown-linux-musl +``` + +以下のようにコンパイルします: + +``` +rustup run stable-x86_64-unknown-linux-musl cargo build --release +``` + +## Linuxでのコンパイルの注意点 + + # Hayabusaの実行 ## 注意: アンチウィルス/EDRの誤検知と遅い初回実行 @@ -268,20 +294,20 @@ Windows PC起動後の初回実行時に時間がかかる場合があります コマンドプロンプトやWindows Terminalから32ビットもしくは64ビットのWindowsバイナリをHayabusaのルートディレクトリから実行します。 -例: `hayabusa-1.4.3-windows-x64.exe` +例: `hayabusa-1.5.0-windows-x64.exe` ## Linux まず、バイナリに実行権限を与える必要があります。 ```bash -chmod +x ./hayabusa-1.4.3-linux-x64-gnu +chmod +x ./hayabusa-1.5.0-linux-x64-gnu ``` 次に、Hayabusaのルートディレクトリから実行します: ```bash -./hayabusa-1.4.3-linux-x64-gnu +./hayabusa-1.5.0-linux-x64-gnu ``` ## macOS @@ -289,13 +315,13 @@ chmod +x ./hayabusa-1.4.3-linux-x64-gnu まず、ターミナルやiTerm2からバイナリに実行権限を与える必要があります。 ```bash -chmod +x ./hayabusa-1.4.3-mac-intel +chmod +x ./hayabusa-1.5.0-mac-intel ``` 次に、Hayabusaのルートディレクトリから実行してみてください: ```bash -./hayabusa-1.4.3-mac-intel +./hayabusa-1.5.0-mac-intel ``` macOSの最新版では、以下のセキュリティ警告が出る可能性があります: @@ -309,7 +335,7 @@ macOSの環境設定から「セキュリティとプライバシー」を開き その後、ターミナルからもう一回実行してみてください: ```bash -./hayabusa-1.4.3-mac-intel +./hayabusa-1.5.0-mac-intel ``` 以下の警告が出るので、「開く」をクリックしてください。 @@ -319,6 +345,15 @@ macOSの環境設定から「セキュリティとプライバシー」を開き これで実行できるようになります。 # 使用方法 +## 主なコマンド + +* デフォルト: ファストフォレンジックタイムラインの作成。 +* `--level-tuning`: アラート`level`のカスタムチューニング +* `-L, --logon-summary`: ログオンイベントのサマリを出力する。 +* `-P, --pivot-keywords-list`: ピボットする不審なキーワードのリスト作成。 +* `-s, --statistics`: イベントIDに基づくイベントの合計と割合の集計を出力する。 +* `--set-default-profile`: デフォルトプロファイルを変更する。 +* `-u, --update`: GitHubの[hayabusa-rules](https://github.com/Yamato-Security/hayabusa-rules)リポジトリにある最新のルールに同期させる。 ## コマンドラインオプション @@ -326,10 +361,6 @@ macOSの環境設定から「セキュリティとプライバシー」を開き USAGE: hayabusa.exe [OTHER-ACTIONS] [OPTIONS] -OPTIONS: - -h, --help ヘルプ情報を表示する - --version バージョン情報を表示する - INPUT: -d, --directory .evtxファイルを持つディレクトリのパス -f, --file 1つの.evtxファイルに対して解析を行う @@ -337,14 +368,14 @@ INPUT: ADVANCED: -c, --rules-config ルールフォルダのコンフィグディレクトリ (デフォルト: ./rules/config) - --level-tuning [] ルールlevelのチューニング (デフォルト: ./rules/config/level_tuning.txt) -Q, --quiet-errors Quiet errorsモード: エラーログを保存しない -r, --rules ルールファイルまたはルールファイルを持つディレクトリ (デフォルト: ./rules) -t, --thread-number スレッド数 (デフォルト: パフォーマンスに最適な数値) --target-file-ext ... evtx以外の拡張子を解析対象に追加する。 (例1: evtx_data 例2:evtx1 evtx2) OUTPUT: - -o, --output タイムラインをCSV形式で保存する (例: results.csv) + -o, --output タイムラインをCSV形式で保存する (例: results.csv) + -P, --profile 利用する出力プロファイル名を指定する (minimal, standard, verbose, verbose-all-field-info, verbose-details-and-all-field-info) DISPLAY-SETTINGS: --no-color カラー出力を無効にする @@ -353,7 +384,7 @@ DISPLAY-SETTINGS: -V, --visualize-timeline イベント頻度タイムラインを出力する FILTERING: - -D, --deep-scan すべてのイベントIDを対象にしたスキャンを行う + -D, --deep-scan すべてのイベントIDを対象にしたスキャンを行う(遅くなる) --enable-deprecated-rules Deprecatedルールを有効にする --exclude-status ... 読み込み対象外とするルール内でのステータス (ex: experimental) (ex: stable test) -m, --min-level 結果出力をするルールの最低レベル (デフォルト: informational) @@ -364,8 +395,10 @@ FILTERING: OTHER-ACTIONS: --contributors コントリビュータの一覧表示 -L, --logon-summary 成功と失敗したログオン情報の要約を出力する + --level-tuning [] ルールlevelのチューニング (デフォルト: ./rules/config/level_tuning.txt) -p, --pivot-keywords-list ピボットキーワードの一覧作成 -s, --statistics イベントIDの統計情報を表示する + --set-default-profile デフォルトの出力コンフィグを設定する -u, --update-rules rulesフォルダをhayabusa-rulesのgithubリポジトリの最新版に更新する TIME-FORMAT: @@ -375,10 +408,6 @@ TIME-FORMAT: --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形式で日付と時刻を出力する (デフォルト: 現地時間) - -OUTPUT-SETTINGS: - -P, --profile 利用する出力プロファイル名を指定する - --set-default-profile デフォルトの出力コンフィグを設定する ``` ## 使用例 @@ -386,79 +415,84 @@ OUTPUT-SETTINGS: * 1つのWindowsイベントログファイルに対してHayabusaを実行します: ```bash -hayabusa-1.4.3-win-x64.exe -f eventlog.evtx +hayabusa-1.5.0-win-x64.exe -f eventlog.evtx ``` -* 複数のWindowsイベントログファイルのあるsample-evtxディレクトリに対して、Hayabusaを実行します: +* `verbose`プロファイルで複数のWindowsイベントログファイルのあるsample-evtxディレクトリに対して、Hayabusaを実行します: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -P verbose ``` -* 全てのフィールド情報も含めて1つのCSVファイルにエクスポートして、Excel、Timeline Explorer、Elastic Stack等でさらに分析することができます(注意: `-F`を有効にすると、出力するファイルのサイズがとても大きくなります!): +* 全てのフィールド情報も含めて1つのCSVファイルにエクスポートして、Excel、Timeline Explorer、Elastic Stack等でさらに分析することができます(注意: `verbose-details-and-all-field-info`プロファイルを使すると、出力するファイルのサイズがとても大きくなります!): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -o results.csv -F +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -o results.csv -P `verbose-details-and-all-field-info` ``` -* Hayabusaルールのみを実行します(デフォルトでは `-r .\rules` にあるすべてのルールが利用されます): +* Hayabusaルールのみを実行します(デフォルトでは`-r .\rules`にあるすべてのルールが利用されます): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa -o results.csv ``` * Windowsでデフォルトで有効になっているログに対してのみ、Hayabusaルールを実行します: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default -o results.csv ``` * Sysmonログに対してのみHayabusaルールを実行します: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\sysmon -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\sysmon -o results.csv ``` * Sigmaルールのみを実行します: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\sigma -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\sigma -o results.csv ``` * 廃棄(deprecated)されたルール(`status`が`deprecated`になっているルール)とノイジールール(`.\rules\config\noisy_rules.txt`にルールIDが書かれているルール)を有効にします: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx --enable-deprecated-rules --enable-noisy-rules -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx --enable-deprecated-rules --enable-noisy-rules -o results.csv ``` * ログオン情報を分析するルールのみを実行し、UTCタイムゾーンで出力します: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default\events\Security\Logons -U -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default\events\Security\Logons -U -o results.csv ``` * 起動中のWindows端末上で実行し(Administrator権限が必要)、アラート(悪意のある可能性のある動作)のみを検知します: ```bash -hayabusa-1.4.3-win-x64.exe -l -m low +hayabusa-1.5.0-win-x64.exe -l -m low ``` * criticalレベルのアラートからピボットキーワードの一覧を作成します(結果は結果毎に`keywords-Ip Address.txt`や`keywords-Users.txt`等に出力されます): ```bash -hayabusa-1.4.3-win-x64.exe -l -m critical -p -o keywords +hayabusa-1.5.0-win-x64.exe -l -m critical -p -o keywords ``` -* イベントIDの統計情報を取得します: +* イベントIDの統計情報を出力します: ```bash -hayabusa-1.4.3-win-x64.exe -f Security.evtx -s +hayabusa-1.5.0-win-x64.exe -f Security.evtx -s +``` +* ログオンサマリを出力します: + +```bash +hayabusa-1.5.0-win-x64.exe -L -f Security.evtx -s ``` * 詳細なメッセージを出力します(処理に時間がかかるファイル、パースエラー等を特定するのに便利): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -v +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -v ``` * Verbose出力の例: @@ -512,57 +546,77 @@ Hayabusaをテストしたり、新しいルールを作成したりするため git clone https://github.com/Yamato-Security/hayabusa-sample-evtx.git ``` -# Hayabusaの出力 +# Hayabusaの出力プロファイル -Hayabusaの結果を標準出力に表示しているとき(デフォルト)は、以下の情報を表示することができます: +Hayabusaの`config/profiles.yaml`設定ファイルでは、5つのプロファイルが定義されています: -* `Timestamp`: デフォルトでは`YYYY-MM-DD HH:mm:ss.sss +hh:mm`形式になっています。イベントログの``フィールドから来ています。デフォルトのタイムゾーンはローカルのタイムゾーンになりますが、`--utc` オプションで UTC に変更することができます。 -* `Computer`: イベントログの``フィールドから来ています。 -* `Channel`: ログ名です。イベントログの``フィールドから来ています。 -* `Event ID`: イベントログの``フィールドから来ています。 -* `Level`: YML検知ルールの`level`フィールドから来ています。(例:`informational`, `low`, `medium`, `high`, `critical`) デフォルトでは、すべてのレベルのアラートとイベントが出力されますが、`-m`オプションで最低のレベルを指定することができます。例えば`-m high`オプションを付けると、`high`と`critical`アラートしか出力されません。 -* `Title`: YML検知ルールの`title`フィールドから来ています。 -* `RecordID`: イベントレコードIDです。``フィールドから来ています。 -* `Details`: YML検知ルールの`details`フィールドから来ていますが、このフィールドはHayabusaルールにしかありません。このフィールドはアラートとイベントに関する追加情報を提供し、ログのフィールドから有用なデータを抽出することができます。イベントキーのマッピングが間違っている場合、もしくはフィールドが存在しない場合で抽出ができなかった箇所は`n/a` (not available)と記載されます。YML検知ルールに`details`フィールドが存在しない時のdetailsのメッセージを`./rules/config/default_details.txt`で設定できます。`default_details.txt`では`Provider Name`、`EventID`、`details`の組み合わせで設定することができます。default_details.txt`やYML検知ルールに対応するルールが記載されていない場合はすべてのフィールド情報を出力します。 -* `MitreTactics`: MITRE ATT&CKの戦術。 -* `MitreTags`: MITRE ATT&CKの戦術以外の情報。attack.g(グループ)、attack.t(技術)、attack.s(ソフトウェア)の情報を出力します。 -* `OtherTags`: YML検知ルールの`tags` フィールドから`MitreTactics`, `MitreTags` 以外の月情報を出力します。 -* `RuleFile`: アラートまたはイベントを生成した検知ルールのファイル名。 -* `EvtxFile`: アラートまたはイベントを起こしたevtxファイルへのパス。 -* `RecordInformation`: すべてのフィールド情報。 +1. `minimal` +2. `standard` (デフォルト) +3. `verbose` +4. `verbose-all-field-info` +5. `verbose-details-and-all-field-info` -## プロファイルによる出力のカスタマイズ +このファイルを編集することで、簡単に独自のプロファイルをカスタマイズしたり、追加したりすることができます。 +`--set-default-profile `オプションでデフォルトのプロファイルを変更することもできます。 -Hayabusaの出力内容はconfig/profiles.txtとconfig/default_profile.txtを変更することでカスタマイズできます。カスタマイズではHayabusaの出力で用いられている内容を以下のエイリアスで呼び出すことができます。 -もし、`config/profiles.txt`に書いてるプロファイルを用いたい場合は`-P/--profile`オプションを利用してください。 -default_profiles.txtをprofile.txtに書かれているプロファイルで上書きしたい場合は`--set-default-profile`オプションを利用してください。 +## 1. `minimal`プロファイルの出力 -|エイリアス名|Haysbusaの出力にある情報| -|:---|:---| -|%Timestamp% | `Timestamp` | -|%Computer% | `Computer` | -|%Channel% | `Channel` | -|%Level% | `Level` | -|%EventID% | `EventID` | -|%MitreTactics% | `MitreTactics` | -|%MitreTags% | `MitreTags` | -|%OtherTags% | `OtherTags` | -|%RecordID% | `RecordID` | -|%RuleTitle% | `Title` | -|%Details% | `Details` | -|%RecordInformation% | `RecordInformation` | -|%RuleFile% | `RuleFile` | -|%EvtxFile% | `EvtxFile` | +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%RuleTitle%`, `%Details%` -profiles.txtへの記載例: +## 2. `standard`プロファイルの出力 -```yaml -(profilename): - (column name): '%Timestamp%' - (column name2): '%Computer%' - (column name3): '%Channel%' -``` +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics%`, `%RecordID%`, `%RuleTitle%`, `%Details%` +## 3. `verbose`プロファイルの出力 + +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%Details%`, `%RuleFile%`, `%EvtxFile%` + +## 4. `verbose-all-field-info`プロファイルの出力 + +最小限の`details`情報を出力する代わりに、イベントにあるすべての`EventData`フィールド情報が出力されます。 + +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%AllFieldInfo%`, `%RuleFile%`, `%EvtxFile%` + +## 5. `verbose-details-and-all-field-info`プロファイルの出力 + +`verbose`プロファイルで出力される情報とイベントにあるすべての`EventData`フィールド情報が出力されます。 +(注意: 出力ファイルサイズは2倍になります!) + +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%Details%`, `%RuleFile%`, `%EvtxFile%`, `%AllFieldInfo%` + +### プロファイルの比較 + +以下のベンチマークは、2018年製のマックブックプロ上で7.5GBのEVTXデータに対して実施されました。 + +| プロファイル | 処理時間 | 結果のファイルサイズ | +| :---: | :---: | :---: | +| minimal | 16分18秒 | 690 MB | +| standard | 16分23秒 | 710 MB | +| verbose | 17分 | 990 MB | +| verbose-all-field-info | 16分50秒 | 1.6 GB | +| verbose-details-and-all-field-info | 17分12秒 | 2.1 GB | + +## Profile Field Aliases + +| エイリアス名 | Hayabusaの出力情報 | +| :--- | :--- | +|%Timestamp% | デフォルトでは`YYYY-MM-DD HH:mm:ss.sss +hh:mm`形式になっている。イベントログの``フィールドから来ている。デフォルトのタイムゾーンはローカルのタイムゾーンになるが、`--UTC`オプションでUTCに変更することができる。 | +|%Computer% | イベントログの``フィールド。 | +|%Channel% | ログ名。イベントログの``フィールド。 | +|%EventID% | イベントログの``フィールド。 | +|%Level% | YML検知ルールの`level`フィールド。(例:`informational`、`low`、`medium`、`high`、`critical`) | +|%MitreTactics% | MITRE ATT&CKの[戦術](https://attack.mitre.org/tactics/enterprise/) (例: Initial Access、Lateral Movement等々) | +|%MitreTags% | MITRE ATT&CKの戦術以外の情報。attack.g(グループ)、attack.t(技術)、attack.s(ソフトウェア)の情報を出力する。 | +|%OtherTags% | YML検知ルールの`tags`フィールドから`MitreTactics`、`MitreTags`以外のキーワードを出力する。| +|%RecordID% | ``フィールドのイベントレコードID。 | +|%RuleTitle% | YML検知ルールの`title`フィールド。 | +|%Details% | YML検知ルールの`details`フィールドから来ていますが、このフィールドはHayabusaルールにしかありません。このフィールドはアラートとイベントに関する追加情報を提供し、ログのフィールドから有用なデータを抽出することができます。イベントキーのマッピングが間違っている場合、もしくはフィールドが存在しない場合で抽出ができなかった箇所は`n/a` (not available)と記載されます。YML検知ルールに`details`フィールドが存在しない時のdetailsのメッセージを`./rules/config/default_details.txt`で設定できます。`default_details.txt`では`Provider Name`、`EventID`、`details`の組み合わせで設定することができます。default_details.txt`やYML検知ルールに対応するルールが記載されていない場合はすべてのフィールド情報を出力します。 | +|%AllFieldInfo% | すべてのフィールド情報。 | +|%RuleFile% | アラートまたはイベントを生成した検知ルールのファイル名。 | +|%EvtxFile% | アラートまたはイベントを起こしたevtxファイルへのパス。 | + +これらのエイリアスは、出力プロファイルで使用することができます。また、他の[イベントキーアライズ](https://github.com/Yamato-Security/hayabusa-rules/blob/main/README-Japanese.md#%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%82%AD%E3%83%BC%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9)を定義し、他のフィールドを出力することもできます。 + ## Levelの省略 簡潔に出力するためにLevelを以下のように省略し出力しています。 @@ -707,7 +761,7 @@ Hayabusaルールは、Windowsのイベントログ解析専用に設計され ## 検知レベルのlevelチューニング Hayabusaルール、Sigmaルールはそれぞれの作者が検知した際のリスクレベルを決めています。 -ユーザが独自のリスクレベルに設定するには`./rules/config/level_tuning.txt`に変換情報を書き、`hayabusa-1.4.3-win-x64.exe --level-tuning`を実行することでルールファイルが書き換えられます。 +ユーザが独自のリスクレベルに設定するには`./rules/config/level_tuning.txt`に変換情報を書き、`hayabusa-1.5.0-win-x64.exe --level-tuning`を実行することでルールファイルが書き換えられます。 ルールファイルが直接書き換えられることに注意して使用してください。 `./rules/config/level_tuning.txt`の例: @@ -720,9 +774,8 @@ id,new_level ## イベントIDフィルタリング -バージョン1.4.3以降では、デフォルトでパフォーマンスを上げるために、検知ルールでイベントIDが定義されていないイベントを無視しています。 -デフォルトでは`./rules/config/target_event_IDs.txt`で定義されたIDがスキャンされます。 -If you want to scan all events, please use the `-D, --deep-scan` option. +デフォルトではパフォーマンスを上げるために、検知ルールでイベントIDが定義されていないイベントを無視しています。 +`./rules/config/target_event_IDs.txt`で定義されたIDがスキャンされます。 すべてのイベントをスキャンしたい場合は、`-D, --deep-scan`オプションを使用してください。 # その他のWindowsイベントログ解析ツールおよび関連リソース diff --git a/README.md b/README.md index 0f23c0dc..78a24a64 100644 --- a/README.md +++ b/README.md @@ -47,19 +47,27 @@ Hayabusa is a **Windows event log fast forensics timeline generator** and **thre - [Cross-compiling 32-bit Windows Binaries](#cross-compiling-32-bit-windows-binaries) - [macOS Compiling Notes](#macos-compiling-notes) - [Linux Compiling Notes](#linux-compiling-notes) + - [Cross-compiling Linux MUSL Binaries](#cross-compiling-linux-musl-binaries) - [Running Hayabusa](#running-hayabusa) - [Caution: Anti-Virus/EDR Warnings and Slow Runtimes](#caution-anti-virusedr-warnings-and-slow-runtimes) - [Windows](#windows) - [Linux](#linux) - [macOS](#macos) - [Usage](#usage) + - [Main commands](#main-commands) - [Command Line Options](#command-line-options) - [Usage Examples](#usage-examples) - [Pivot Keyword Generator](#pivot-keyword-generator) - [Logon Summary Generator](#logon-summary-generator) - [Testing Hayabusa on Sample Evtx Files](#testing-hayabusa-on-sample-evtx-files) -- [Hayabusa Output](#hayabusa-output) - - [Output customize by profile](#output-customize-by-profile) +- [Hayabusa Output Profiles](#hayabusa-output-profiles) + - [1. `minimal` profile output](#1-minimal-profile-output) + - [2. `standard` profile output](#2-standard-profile-output) + - [3. `verbose` profile output](#3-verbose-profile-output) + - [4. `verbose-all-field-info` profile output](#4-verbose-all-field-info-profile-output) + - [5. `verbose-details-and-all-field-info` profile output](#5-verbose-details-and-all-field-info-profile-output) + - [Profile Comparison](#profile-comparison) + - [Profile Field Aliases](#profile-field-aliases) - [Level Abbrevations](#level-abbrevations) - [MITRE ATT&CK Tactics Abbreviations](#mitre-attck-tactics-abbreviations) - [Channel Abbreviations](#channel-abbreviations) @@ -176,7 +184,7 @@ Note: If you forget to use --recursive option, the `rules` folder, which is mana You can sync the `rules` folder and get latest Hayabusa rules with `git pull --recurse-submodules` or use the following command: ```bash -hayabusa-1.4.3-win-x64.exe -u +hayabusa-1.5.0-win-x64.exe -u ``` If the update fails, you may need to rename the `rules` folder and try again. @@ -191,7 +199,6 @@ If the update fails, you may need to rename the `rules` folder and try again. If you have Rust installed, you can compile from source with the following command: ```bash -cargo clean cargo build --release ``` @@ -250,6 +257,21 @@ Fedora-based distros: sudo yum install openssl-devel ``` +## Cross-compiling Linux MUSL Binaries + +On a Linux OS, first install the target. + +```bash +rustup install stable-x86_64-unknown-linux-musl +rustup target add x86_64-unknown-linux-musl +``` + +Compile with: + +``` +rustup run stable-x86_64-unknown-linux-musl cargo build --release +``` + # Running Hayabusa ## Caution: Anti-Virus/EDR Warnings and Slow Runtimes @@ -264,20 +286,20 @@ You may experience slow runtime especially on the first run after a reboot due t In a Command/PowerShell Prompt or Windows Terminal, just run the appropriate 32-bit or 64-bit Windows binary. -Example: `hayabusa-1.4.3-windows-x64.exe` +Example: `hayabusa-1.5.0-windows-x64.exe` ## Linux You first need to make the binary executable. ```bash -chmod +x ./hayabusa-1.4.3-linux-x64-gnu +chmod +x ./hayabusa-1.5.0-linux-x64-gnu ``` Then run it from the Hayabusa root directory: ```bash -./hayabusa-1.4.3-linux-x64-gnu +./hayabusa-1.5.0-linux-x64-gnu ``` ## macOS @@ -285,13 +307,13 @@ Then run it from the Hayabusa root directory: From Terminal or iTerm2, you first need to make the binary executable. ```bash -chmod +x ./hayabusa-1.4.3-mac-intel +chmod +x ./hayabusa-1.5.0-mac-intel ``` Then, try to run it from the Hayabusa root directory: ```bash -./hayabusa-1.4.3-mac-intel +./hayabusa-1.5.0-mac-intel ``` On the latest version of macOS, you may receive the following security error when you try to run it: @@ -305,7 +327,7 @@ Click "Cancel" and then from System Preferences, open "Security & Privacy" and f After that, try to run it again. ```bash -./hayabusa-1.4.3-mac-intel +./hayabusa-1.5.0-mac-intel ``` The following warning will pop up, so please click "Open". @@ -315,6 +337,15 @@ The following warning will pop up, so please click "Open". You should now be able to run hayabusa. # Usage +## Main commands + +* default: Create a fast forensics timeline. +* `--level-tuning`: Custom tune the alerts' `level`. +* `-L, --logon-summary`: Print a summary of logon events. +* `-P, --pivot-keywords-list`: Print a list of suspicious keywords to pivot on. +* `-s, --statistics`: Print metrics of the count and percentage of events based on Event ID. +* `--set-default-profile`: Change the default profile. +* `-u, --update`: Sync the rules to the latest rules in the [hayabusa-rules](https://github.com/Yamato-Security/hayabusa-rules) GitHub repository. ## Command Line Options @@ -322,10 +353,6 @@ You should now be able to run hayabusa. USAGE: hayabusa.exe [OTHER-ACTIONS] [OPTIONS] -OPTIONS: - -h, --help Print help information - --version Print version information - INPUT: -d, --directory Directory of multiple .evtx files -f, --file File path to one .evtx file @@ -333,14 +360,14 @@ INPUT: ADVANCED: -c, --rules-config Specify custom rule config directory (default: ./rules/config) - --level-tuning [] Tune alert levels (default: ./rules/config/level_tuning.txt) -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: - -o, --output Save the timeline in CSV format (ex: results.csv) + -o, --output Save the timeline in CSV format (ex: results.csv) + -P, --profile Specify output profile (minimal, standard, verbose, verbose-all-field-info, verbose-details-and-all-field-info) DISPLAY-SETTINGS: --no-color Disable color output @@ -349,7 +376,7 @@ DISPLAY-SETTINGS: -V, --visualize-timeline Output event frequency timeline FILTERING: - -D, --deep-scan Disable event ID filter to scan all events + -D, --deep-scan Disable event ID filter to scan all events (slower) --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) @@ -358,11 +385,13 @@ FILTERING: --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 - -p, --pivot-keywords-list Create a list of pivot keywords - -s, --statistics Print statistics of event IDs - -u, --update-rules Update to the latest rules in the hayabusa-rules github repository + --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) + -p, --pivot-keywords-list Create a list of pivot keywords + -s, --statistics Print statistics of event IDs + --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) @@ -371,90 +400,92 @@ TIME-FORMAT: --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) - -OUTPUT-SETTINGS: - -P, --profile Specify output profile - --set-default-profile Set default output profile ``` ## Usage Examples -* Run hayabusa against one Windows event log file: +* Run hayabusa against one Windows event log file with default standard profile: ```bash -hayabusa-1.4.3-win-x64.exe -f eventlog.evtx +hayabusa-1.5.0-win-x64.exe -f eventlog.evtx ``` -* Run hayabusa against the sample-evtx directory with multiple Windows event log files: +* Run hayabusa against the sample-evtx directory with multiple Windows event log files with the verbose profile: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -P verbose ``` -* Export to a single CSV file for further analysis with excel, timeline explorer, elastic stack, etc... and include all field information (Warning: your file output size will become much larger with `-F` enabled!): +* Export to a single CSV file for further analysis with excel, timeline explorer, elastic stack, etc... and include all field information (Warning: your file output size will become much larger with the `verbose-details-and-all-field-info` profile!): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -o results.csv -F +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -o results.csv -F ``` * Only run hayabusa rules (the default is to run all the rules in `-r .\rules`): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa -o results.csv ``` * Only run hayabusa rules for logs that are enabled by default on Windows: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default -o results.csv ``` * Only run hayabusa rules for sysmon logs: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\sysmon -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\sysmon -o results.csv ``` * Only run sigma rules: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\sigma -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\sigma -o results.csv ``` * Enable deprecated rules (those with `status` marked as `deprecated`) and noisy rules (those whose rule ID is listed in `.\rules\config\noisy_rules.txt`): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx --enable-noisy-rules --enable-deprecated-rules -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx --enable-noisy-rules --enable-deprecated-rules -o results.csv ``` * Only run rules to analyze logons and output in the UTC timezone: ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default\events\Security\Logons -U -o results.csv +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -r .\rules\hayabusa\default\events\Security\Logons -U -o results.csv ``` * Run on a live Windows machine (requires Administrator privileges) and only detect alerts (potentially malicious behavior): ```bash -hayabusa-1.4.3-win-x64.exe -l -m low +hayabusa-1.5.0-win-x64.exe -l -m low ``` * Create a list of pivot keywords from critical alerts and save the results. (Results will be saved to `keywords-Ip Addresses.txt`, `keywords-Users.txt`, etc...): ```bash -hayabusa-1.4.3-win-x64.exe -l -m critical -p -o keywords +hayabusa-1.5.0-win-x64.exe -l -m critical -p -o keywords ``` * Print Event ID statistics: ```bash -hayabusa-1.4.3-win-x64.exe -f Security.evtx -s +hayabusa-1.5.0-win-x64.exe -f Security.evtx -s +``` + +* Print logon summary: + +```bash +hayabusa-1.5.0-win-x64.exe -L -f Security.evtx -s ``` * Print verbose information (useful for determining which files take long to process, parsing errors, etc...): ```bash -hayabusa-1.4.3-win-x64.exe -d .\hayabusa-sample-evtx -v +hayabusa-1.5.0-win-x64.exe -d .\hayabusa-sample-evtx -v ``` * Verbose output example: @@ -509,58 +540,75 @@ You can download the sample evtx files to a new `hayabusa-sample-evtx` sub-direc git clone https://github.com/Yamato-Security/hayabusa-sample-evtx.git ``` -# Hayabusa Output +# Hayabusa Output Profiles -When hayabusa output is being displayed to the screen (the default), it can display the following information: +Hayabusa has 5 pre-defined profiles to use in `config/profiles.yaml`: -* `Timestamp`: Default is `YYYY-MM-DD HH:mm:ss.sss +hh:mm` format. This comes from the `` field in the event log. The default timezone will be the local timezone but you can change the timezone to UTC with the `--utc` option. -* `Computer`: This comes from the `` field in the event log. -* `Channel`: The name of log. This comes from the `` field in the event log. -* `Event ID`: This comes from the `` field in the event log. -* `Level`: This comes from the `level` field in the YML detection rule. (`informational`, `low`, `medium`, `high`, `critical`) By default, all level alerts will be displayed but you can set the minimum level with `-m`. For example, you can set `-m high`) in order to only scan for and display high and critical alerts. -* `RecordID`: This comes from the `` field in the event log. -* `Title`: This comes from the `title` field in the YML detection rule. -* `Details`: This comes from the `details` field in the YML detection rule, however, only hayabusa rules have this field. This field gives extra information about the alert or event and can extract useful data from the fields in event logs. For example, usernames, command line information, process information, etc... When a placeholder points to a field that does not exist or there is an incorrect alias mapping, it will be outputted as `n/a` (not available). If the `details` field is not specified (i.e. sigma rules), default `details` messages to extract fields defined in `./rules/config/default_details.txt` will be outputted. You can add more default `details` messages by adding the `Provider Name`, `EventID` and `details` message you want to output in `default_details.txt`. When no `details` field is defined in a rule nor in `default_details.txt`, all fields will be outputted to the `details` column. -* `MitreTactics`: MITRE ATT&CK tactics. -* `MitreTags`: MITRE ATT&CK group, technique, software. -* `OtherTags`: This comes from the `tags` field in YML detection rule which is excluded `MitreTactics` and `MitreTags`. -* `RuleFile`: The filename of the detection rule that generated the alert or event. -* `EvtxFile`: The evtx filename that caused the alert or event. -* `RecordInformation`: All field information. +1. `minimal` +2. `standard` (default) +3. `verbose` +4. `verbose-all-field-info` +5. `verbose-details-and-all-field-info` -## Output customize by profile +You can easily customize or add your own profiles by editing this file. +You can also easily change the default profile with `--set-default-profile `. -You can customize the output by modifiy `config/profiles.txt` and `config/default_profile.txt`. -You can be setting following alias. -If you want to use profile in `config/profiles.txt` , you use `-P/--profile` option. -Please use `--set-default-profile` option when you want to overwrite `default_profiles.txt` by profile in `config/profiles.txt`. +## 1. `minimal` profile output -|alias name| Hayabusa output information| -|:---|:---| -|%Timestamp% | `Timestamp` | -|%Computer% | `Computer` | -|%Channel% | `Channel` | -|%Level% | `Level` | -|%EventID% | `EventID` | -|%MitreTactics% | `MitreTactics` | -|%MitreTags% | `MitreTags` | -|%OtherTags% | `OtherTags` | -|%RecordID% | `RecordID` | -|%RuleTitle% | `Title` | -|%Details% | `Details` | -|%RecordInformation% | `RecordInformation` | -|%RuleFile% | `RuleFile` | -|%EvtxFile% | `EvtxFile` | +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%RuleTitle%`, `%Details%` -e.g. profile customize +## 2. `standard` profile output -```yaml -(profilename): - (column name): '%Timestamp%' - (column name2): '%Computer%' - (column name3): '%Channel%' -``` +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics%`, `%RecordID%`, `%RuleTitle%`, `%Details%` +## 3. `verbose` profile output + +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%Details%`, `%RuleFile%`, `%EvtxFile%` + +## 4. `verbose-all-field-info` profile output + +Instead of outputting the minimal `details` information, all field information in the `EventData` section will be outputted. + +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%AllFieldInfo%`, `%RuleFile%`, `%EvtxFile%` + +## 5. `verbose-details-and-all-field-info` profile output + +`verbose` profile plus all field information. (Warning: this will usually double the output file size!) + +`%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%Details%`, `%RuleFile%`, `%EvtxFile%`, `%AllFieldInfo%` + +### Profile Comparison + +The following benchmarks were conducted on a 2018 MBP with 7.5GB of evtx data. + +| Profile | Processing Time | Output Filesize | +| :---: | :---: | :---: | +| minimal | 16 minutes 18 seconds | 690 MB | +| standard | 16 minutes 23 seconds | 710 MB | +| verbose | 17 minutes | 990 MB | +| verbose-all-field-info | 16 minutes 50 seconds | 1.6 GB | +| verbose-details-and-all-field-info | 17 minutes 12 seconds | 2.1 GB | + +## Profile Field Aliases + +| Alias name | Hayabusa output information| +| :--- | :--- | +|%Timestamp% | Default is `YYYY-MM-DD HH:mm:ss.sss +hh:mm` format. `` field in the event log. The default timezone will be the local timezone but you can change the timezone to UTC with the `--UTC` option. | +|%Computer% | The `` field. | +|%Channel% | The name of log. `` field. | +|%EventID% | The `` field. | +|%Level% | The `level` field in the YML detection rule. (`informational`, `low`, `medium`, `high`, `critical`) | +|%MitreTactics% | MITRE ATT&CK [tactics](https://attack.mitre.org/tactics/enterprise/) (Ex: Initial Access, Lateral Movement, etc...). | +|%MitreTags% | MITRE ATT&CK Group ID, Technique ID and Software ID. | +|%OtherTags% | Any keyword in the `tags` field in a YML detection rule which is not included in `MitreTactics` or `MitreTags`. | +|%RecordID% | The Event Record ID from `` field. | +|%RuleTitle% | The `title` field in the YML detection rule. | +|%Details% | The `details` field in the YML detection rule, however, only hayabusa rules have this field. This field gives extra information about the alert or event and can extract useful data from the fields in event logs. For example, usernames, command line information, process information, etc... When a placeholder points to a field that does not exist or there is an incorrect alias mapping, it will be outputted as `n/a` (not available). If the `details` field is not specified (i.e. sigma rules), default `details` messages to extract fields defined in `./rules/config/default_details.txt` will be outputted. You can add more default `details` messages by adding the `Provider Name`, `EventID` and `details` message you want to output in `default_details.txt`. When no `details` field is defined in a rule nor in `default_details.txt`, all fields will be outputted to the `details` column. | +|%AllFieldInfo% | All field information. | +|%RuleFile% | The filename of the detection rule that generated the alert or event. | +|%EvtxFile% | The evtx filename that caused the alert or event. | + +You can use these aliases in your output profiles, as well as define other [event key alises](https://github.com/Yamato-Security/hayabusa-rules/blob/main/README.md#eventkey-aliases) to output other fields. ## Level Abbrevations @@ -705,7 +753,7 @@ You can also add a rule ID to `./rules/config/noisy_rules.txt` in order to ignor Hayabusa and Sigma rule authors will determine the risk level of the alert when writing their rules. However, the actual risk level will differ between environments. -You can tune the risk level of the rules by adding them to `./rules/config/level_tuning.txt` and executing `hayabusa-1.4.3-win-x64.exe --level-tuning` which will update the `level` line in the rule file. +You can tune the risk level of the rules by adding them to `./rules/config/level_tuning.txt` and executing `hayabusa-1.5.0-win-x64.exe --level-tuning` which will update the `level` line in the rule file. Please note that the rule file will be updated directly. `./rules/config/level_tuning.txt` sample line: @@ -719,8 +767,8 @@ In this case, the risk level of the rule with an `id` of `00000000-0000-0000-000 ## Event ID Filtering -As of version 1.4.3, by default, events are filtered by ID to improve performance by ignorning events that have no detection rules. -The IDs defined in `./rules/config/target_event_IDs.txt` will be scanned by default. +By default, events are filtered by ID to improve performance by ignorning events that have no detection rules. +The IDs defined in `./rules/config/target_event_IDs.txt` will be scanned. If you want to scan all events, please use the `-D, --deep-scan` option. # Other Windows Event Log Analyzers and Related Resources diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 637bf772..01d6786d 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -220,7 +220,7 @@ pub struct Config { #[clap(help_heading = Some("OUTPUT"), short = 'P', long = "profile")] pub profile: Option, - /// Set default output profile (minimal, standard, verbose, verbose-all-field-info, verbose-details-and-all-field-info) + /// Set default output profile #[clap(help_heading = Some("OTHER-ACTIONS"), long = "set-default-profile", value_name = "PROFILE")] pub set_default_profile: Option, } From c2807e36e45bd26fdba060aa0eb6e8cdb2c3ab8e Mon Sep 17 00:00:00 2001 From: Yamato Security <71482215+YamatoSecurity@users.noreply.github.com> Date: Thu, 11 Aug 2022 00:40:34 +0900 Subject: [PATCH 10/21] update readme --- README-Japanese.md | 45 +++++++++++++++++++++++++-------------------- README.md | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/README-Japanese.md b/README-Japanese.md index 2dee460d..c5b25a41 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -62,22 +62,24 @@ Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/) - [ピボットキーワードの作成](#ピボットキーワードの作成) - [ログオン情報の要約](#ログオン情報の要約) - [サンプルevtxファイルでHayabusaをテストする](#サンプルevtxファイルでhayabusaをテストする) -- [Hayabusaの出力プロファイル](#hayabusaの出力プロファイル) - - [1. `minimal`プロファイルの出力](#1-minimalプロファイルの出力) - - [2. `standard`プロファイルの出力](#2-standardプロファイルの出力) - - [3. `verbose`プロファイルの出力](#3-verboseプロファイルの出力) - - [4. `verbose-all-field-info`プロファイルの出力](#4-verbose-all-field-infoプロファイルの出力) - - [5. `verbose-details-and-all-field-info`プロファイルの出力](#5-verbose-details-and-all-field-infoプロファイルの出力) +- [Hayabusaの出力](#hayabusaの出力) + - [プロファイル](#プロファイル) + - [1. `minimal`プロファイルの出力](#1-minimalプロファイルの出力) + - [2. `standard`プロファイルの出力](#2-standardプロファイルの出力) + - [3. `verbose`プロファイルの出力](#3-verboseプロファイルの出力) + - [4. `verbose-all-field-info`プロファイルの出力](#4-verbose-all-field-infoプロファイルの出力) + - [5. `verbose-details-and-all-field-info`プロファイルの出力](#5-verbose-details-and-all-field-infoプロファイルの出力) - [プロファイルの比較](#プロファイルの比較) - - [Profile Field Aliases](#profile-field-aliases) + - [Profile Field Aliases](#profile-field-aliases) - [Levelの省略](#levelの省略) - [MITRE ATT&CK戦術の省略](#mitre-attck戦術の省略) - [Channel情報の省略](#channel情報の省略) - [プログレスバー](#プログレスバー) - [標準出力へのカラー設定](#標準出力へのカラー設定) - - [イベント頻度タイムライン](#イベント頻度タイムライン) - - [最多検知日の出力](#最多検知日の出力) - - [最多検知端末名の出力](#最多検知端末名の出力) + - [結果のサマリ](#結果のサマリ) + - [イベント頻度タイムライン](#イベント頻度タイムライン) + - [最多検知日の出力](#最多検知日の出力) + - [最多検知端末名の出力](#最多検知端末名の出力) - [Hayabusaルール](#hayabusaルール) - [Hayabusa v.s. 変換されたSigmaルール](#hayabusa-vs-変換されたsigmaルール) - [検知ルールのチューニング](#検知ルールのチューニング) @@ -546,7 +548,8 @@ Hayabusaをテストしたり、新しいルールを作成したりするため git clone https://github.com/Yamato-Security/hayabusa-sample-evtx.git ``` -# Hayabusaの出力プロファイル +# Hayabusaの出力 +## プロファイル Hayabusaの`config/profiles.yaml`設定ファイルでは、5つのプロファイルが定義されています: @@ -559,25 +562,25 @@ Hayabusaの`config/profiles.yaml`設定ファイルでは、5つのプロフ このファイルを編集することで、簡単に独自のプロファイルをカスタマイズしたり、追加したりすることができます。 `--set-default-profile `オプションでデフォルトのプロファイルを変更することもできます。 -## 1. `minimal`プロファイルの出力 +### 1. `minimal`プロファイルの出力 `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%RuleTitle%`, `%Details%` -## 2. `standard`プロファイルの出力 +### 2. `standard`プロファイルの出力 `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics%`, `%RecordID%`, `%RuleTitle%`, `%Details%` -## 3. `verbose`プロファイルの出力 +### 3. `verbose`プロファイルの出力 `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%Details%`, `%RuleFile%`, `%EvtxFile%` -## 4. `verbose-all-field-info`プロファイルの出力 +### 4. `verbose-all-field-info`プロファイルの出力 最小限の`details`情報を出力する代わりに、イベントにあるすべての`EventData`フィールド情報が出力されます。 `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%AllFieldInfo%`, `%RuleFile%`, `%EvtxFile%` -## 5. `verbose-details-and-all-field-info`プロファイルの出力 +### 5. `verbose-details-and-all-field-info`プロファイルの出力 `verbose`プロファイルで出力される情報とイベントにあるすべての`EventData`フィールド情報が出力されます。 (注意: 出力ファイルサイズは2倍になります!) @@ -596,7 +599,7 @@ Hayabusaの`config/profiles.yaml`設定ファイルでは、5つのプロフ | verbose-all-field-info | 16分50秒 | 1.6 GB | | verbose-details-and-all-field-info | 17分12秒 | 2.1 GB | -## Profile Field Aliases +### Profile Field Aliases | エイリアス名 | Hayabusaの出力情報 | | :--- | :--- | @@ -694,16 +697,18 @@ Hayabusaの結果は`level`毎に文字色が変わります。 形式は`level名,(6桁のRGBのカラーhex)`です。 カラー出力をしないようにしたい場合は`--no-color`オプションをご利用ください。 -## イベント頻度タイムライン +## 結果のサマリ + +### イベント頻度タイムライン `-V`または`--visualize-timeline`オプションを使うことで、検知したイベントの数が5以上の時、頻度のタイムライン(スパークライン)を画面に出力します。 マーカーの数は最大10個です。デフォルトのCommand PromptとPowerShell Promptでは文字化けがでるので、Windows TerminalやiTerm2等のターミナルをご利用ください。 -## 最多検知日の出力 +### 最多検知日の出力 各レベルで最も検知された日付を画面に出力します。 -## 最多検知端末名の出力 +### 最多検知端末名の出力 各レベルで多く検知されたユニークなイベントが多い端末名上位5つを画面に出力します。 diff --git a/README.md b/README.md index 78a24a64..e3b65770 100644 --- a/README.md +++ b/README.md @@ -60,22 +60,24 @@ Hayabusa is a **Windows event log fast forensics timeline generator** and **thre - [Pivot Keyword Generator](#pivot-keyword-generator) - [Logon Summary Generator](#logon-summary-generator) - [Testing Hayabusa on Sample Evtx Files](#testing-hayabusa-on-sample-evtx-files) -- [Hayabusa Output Profiles](#hayabusa-output-profiles) - - [1. `minimal` profile output](#1-minimal-profile-output) - - [2. `standard` profile output](#2-standard-profile-output) - - [3. `verbose` profile output](#3-verbose-profile-output) - - [4. `verbose-all-field-info` profile output](#4-verbose-all-field-info-profile-output) - - [5. `verbose-details-and-all-field-info` profile output](#5-verbose-details-and-all-field-info-profile-output) +- [Hayabusa Output](#hayabusa-output) + - [Profiles](#profiles) + - [1. `minimal` profile output](#1-minimal-profile-output) + - [2. `standard` profile output](#2-standard-profile-output) + - [3. `verbose` profile output](#3-verbose-profile-output) + - [4. `verbose-all-field-info` profile output](#4-verbose-all-field-info-profile-output) + - [5. `verbose-details-and-all-field-info` profile output](#5-verbose-details-and-all-field-info-profile-output) - [Profile Comparison](#profile-comparison) - - [Profile Field Aliases](#profile-field-aliases) + - [Profile Field Aliases](#profile-field-aliases) - [Level Abbrevations](#level-abbrevations) - [MITRE ATT&CK Tactics Abbreviations](#mitre-attck-tactics-abbreviations) - [Channel Abbreviations](#channel-abbreviations) - [Progress Bar](#progress-bar) - [Color Output](#color-output) - - [Event Fequency Timeline](#event-fequency-timeline) - - [Dates with most total detections](#dates-with-most-total-detections) - - [Top 5 computers with most unique detections](#top-5-computers-with-most-unique-detections) + - [Results Summary](#results-summary-1) + - [Event Fequency Timeline](#event-fequency-timeline) + - [Dates with most total detections](#dates-with-most-total-detections) + - [Top 5 computers with most unique detections](#top-5-computers-with-most-unique-detections) - [Hayabusa Rules](#hayabusa-rules) - [Hayabusa v.s. Converted Sigma Rules](#hayabusa-vs-converted-sigma-rules) - [Detection Rule Tuning](#detection-rule-tuning) @@ -540,7 +542,9 @@ You can download the sample evtx files to a new `hayabusa-sample-evtx` sub-direc git clone https://github.com/Yamato-Security/hayabusa-sample-evtx.git ``` -# Hayabusa Output Profiles +# Hayabusa Output + +## Profiles Hayabusa has 5 pre-defined profiles to use in `config/profiles.yaml`: @@ -553,25 +557,25 @@ Hayabusa has 5 pre-defined profiles to use in `config/profiles.yaml`: You can easily customize or add your own profiles by editing this file. You can also easily change the default profile with `--set-default-profile `. -## 1. `minimal` profile output +### 1. `minimal` profile output `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%RuleTitle%`, `%Details%` -## 2. `standard` profile output +### 2. `standard` profile output `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics%`, `%RecordID%`, `%RuleTitle%`, `%Details%` -## 3. `verbose` profile output +### 3. `verbose` profile output `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%Details%`, `%RuleFile%`, `%EvtxFile%` -## 4. `verbose-all-field-info` profile output +### 4. `verbose-all-field-info` profile output Instead of outputting the minimal `details` information, all field information in the `EventData` section will be outputted. `%Timestamp%`, `%Computer%`, `%Channel%`, `%EventID%`, `%Level%`, `%MitreTactics`, `%MitreTags%`, `%OtherTags%`, `%RecordID%`, `%RuleTitle%`, `%AllFieldInfo%`, `%RuleFile%`, `%EvtxFile%` -## 5. `verbose-details-and-all-field-info` profile output +### 5. `verbose-details-and-all-field-info` profile output `verbose` profile plus all field information. (Warning: this will usually double the output file size!) @@ -589,7 +593,7 @@ The following benchmarks were conducted on a 2018 MBP with 7.5GB of evtx data. | verbose-all-field-info | 16 minutes 50 seconds | 1.6 GB | | verbose-details-and-all-field-info | 17 minutes 12 seconds | 2.1 GB | -## Profile Field Aliases +### Profile Field Aliases | Alias name | Hayabusa output information| | :--- | :--- | @@ -686,16 +690,18 @@ The alerts will be outputted in color based on the alert `level`. You can change the default colors in the config file at `./config/level_color.txt` in the format of `level,(RGB 6-digit ColorHex)`. If you want to disable color output, you can use `--no-color` option. -## Event Fequency Timeline +## Results Summary + +### Event Fequency Timeline If you add `-V` 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... -## Dates with most total detections +### Dates with most total detections A summary of the dates with the most total detections categorized by level (`critical`, `high`, etc...). -## Top 5 computers with most unique detections +### Top 5 computers with most unique detections The top 5 computers with the most unique detections categorized by level (`critical`, `high`, etc...). From 9f7a8980d8a457d06e4715e940d27ec7dbd74278 Mon Sep 17 00:00:00 2001 From: Yamato Security <71482215+YamatoSecurity@users.noreply.github.com> Date: Thu, 11 Aug 2022 13:05:34 +0900 Subject: [PATCH 11/21] update readme --- README-Japanese.md | 4 +++- README.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README-Japanese.md b/README-Japanese.md index c5b25a41..05b59baf 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -276,9 +276,11 @@ rustup target add x86_64-unknown-linux-musl 以下のようにコンパイルします: ``` -rustup run stable-x86_64-unknown-linux-musl cargo build --release +cargo build --release --target=x86_64-unknown-linux-musl ``` +MUSLバイナリは`./target/x86_64-unknown-linux-musl/release/`ディレクトリ配下に作成されます。 + ## Linuxでのコンパイルの注意点 diff --git a/README.md b/README.md index e3b65770..ca248736 100644 --- a/README.md +++ b/README.md @@ -271,9 +271,11 @@ rustup target add x86_64-unknown-linux-musl Compile with: ``` -rustup run stable-x86_64-unknown-linux-musl cargo build --release +cargo build --release --target=x86_64-unknown-linux-musl ``` +The MUSL binary will be created in the `./target/x86_64-unknown-linux-musl/release/` directory. + # Running Hayabusa ## Caution: Anti-Virus/EDR Warnings and Slow Runtimes From bbe8bc9b69b5d5c13c062c61160a9eabcd604b9a Mon Sep 17 00:00:00 2001 From: Yamato Security <71482215+YamatoSecurity@users.noreply.github.com> Date: Thu, 11 Aug 2022 13:24:24 +0900 Subject: [PATCH 12/21] update readme --- README-Japanese.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README-Japanese.md b/README-Japanese.md index 05b59baf..aa0353bc 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -280,6 +280,7 @@ cargo build --release --target=x86_64-unknown-linux-musl ``` MUSLバイナリは`./target/x86_64-unknown-linux-musl/release/`ディレクトリ配下に作成されます。 +MUSLバイナリはGNUバイナリより約15%遅いです。 ## Linuxでのコンパイルの注意点 diff --git a/README.md b/README.md index ca248736..5a8db360 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,7 @@ cargo build --release --target=x86_64-unknown-linux-musl ``` The MUSL binary will be created in the `./target/x86_64-unknown-linux-musl/release/` directory. +MUSL binaries are are about 15% slower than the GNU binaries. # Running Hayabusa From c2a093fb1ed9041275034678565a37d023d7159f Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 11 Aug 2022 18:51:26 +0900 Subject: [PATCH 13/21] cargo fmt --- src/detections/configs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 9aa047fa..4cbf117f 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -59,7 +59,7 @@ impl Default for ConfigReader<'_> { author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", help_template = "\n{name}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", version, - arg_required_else_help (true), + arg_required_else_help(true), term_width = 400 )] pub struct Config { From acab188fec3b3277b67cabd6cfbb3f22ab3dc6db Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 11 Aug 2022 18:56:58 +0900 Subject: [PATCH 14/21] disabled version --- src/detections/configs.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 4cbf117f..2254014b 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -58,7 +58,6 @@ impl Default for ConfigReader<'_> { usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", help_template = "\n{name}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", - version, arg_required_else_help(true), term_width = 400 )] From 436a61a43660fccec604e0c45704c4c04e8c7a07 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 11 Aug 2022 19:48:36 +0900 Subject: [PATCH 15/21] passed test verstion (arg_required_else_help is false) --- src/detections/configs.rs | 2 +- src/main.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 2254014b..0fd82715 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -58,7 +58,7 @@ impl Default for ConfigReader<'_> { usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", help_template = "\n{name}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", - arg_required_else_help(true), + // arg_required_else_help(true), term_width = 400 )] pub struct Config { diff --git a/src/main.rs b/src/main.rs index f19bc556..b7fe4801 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,6 +89,13 @@ impl App { return; } let analysis_start_time: DateTime = Local::now(); + // Show usage when no arguments. + if std::env::args().len() == 1 { + self.output_logo(); + configs::CONFIG.write().unwrap().app.print_help().ok(); + println!(); + return; + } if !configs::CONFIG.read().unwrap().args.quiet { self.output_logo(); println!(); From 73028972e05a9b6eef1703aaa0dd9094720ff4dc Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 11 Aug 2022 20:10:27 +0900 Subject: [PATCH 16/21] added output percentage of detections in result summary #658 --- src/afterfact.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/afterfact.rs b/src/afterfact.rs index 7be9dec8..f16c35b7 100644 --- a/src/afterfact.rs +++ b/src/afterfact.rs @@ -437,6 +437,10 @@ fn _print_unique_results( // the order in which are registered and the order of levels to be displayed are reversed counts_by_level.reverse(); + + let total_count = counts_by_level + .iter() + .sum::(); // output total results write_color_buffer( &BufferWriter::stdout(ColorChoice::Always), @@ -445,10 +449,7 @@ fn _print_unique_results( "{} {}: {}", head_word, tail_word, - counts_by_level - .iter() - .sum::() - .to_formatted_string(&Locale::en), + total_count.to_formatted_string(&Locale::en), ), true, ) @@ -458,12 +459,18 @@ fn _print_unique_results( if "undefined" == *level_name { continue; } + let percent = if total_count == 0 { + 0 as f64 + } else { + (counts_by_level[i] as f64) / (total_count as f64) * 100.0 + }; let output_raw_str = format!( - "{} {} {}: {}", + "{} {} {}: {} ({:.2}%)", head_word, level_name, tail_word, - counts_by_level[i].to_formatted_string(&Locale::en) + counts_by_level[i].to_formatted_string(&Locale::en), + percent ); write_color_buffer( &BufferWriter::stdout(ColorChoice::Always), From 8e155d8000d02874cf4a873d7ca80d1f6cb7c363 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 11 Aug 2022 20:12:38 +0900 Subject: [PATCH 17/21] updated changelog #658 --- CHANGELOG-Japanese.md | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index f0042e46..ca3fab90 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -12,6 +12,7 @@ - ルールのアップデート機能のルールパスの出力から./を削除した。 (#642) (@hitenkoku) - MITRE ATT&CK関連のタグとその他タグを出力するための出力用のエイリアスを追加した。 (#637) (@hitenkoku) - 結果概要の数値をカンマをつけて見やすくした。 (#649) (@hitenkoku) +- 結果概要内の検知数にパーセント表示を追加した。 (#658) (@hitenkoku) **バグ修正:** diff --git a/CHANGELOG.md b/CHANGELOG.md index a14081c8..ad6d4f1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Removed ./ from rule path when updating. (#642) (@hitenkoku) - Added new output alias for MITRE ATT&CK tags and other tags. (#637) (@hitenkoku) - Added commas to summary numbers to make them easier to read. (#649) (@hitenkoku) +- Added output percentage of detections in Result Summary. (#658) (@hitenkoku) **Bug Fixes:** From 1491ecba07347bc8b3cc9ead366e04dadcea9ddc Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 11 Aug 2022 20:18:31 +0900 Subject: [PATCH 18/21] cargo fmt --- src/afterfact.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/afterfact.rs b/src/afterfact.rs index f16c35b7..21ce0ffb 100644 --- a/src/afterfact.rs +++ b/src/afterfact.rs @@ -437,10 +437,7 @@ fn _print_unique_results( // the order in which are registered and the order of levels to be displayed are reversed counts_by_level.reverse(); - - let total_count = counts_by_level - .iter() - .sum::(); + let total_count = counts_by_level.iter().sum::(); // output total results write_color_buffer( &BufferWriter::stdout(ColorChoice::Always), From 1ce5ffb0e3c4110dbc4677196e974bc5bc6c46d8 Mon Sep 17 00:00:00 2001 From: Yamato Security <71482215+YamatoSecurity@users.noreply.github.com> Date: Thu, 11 Aug 2022 22:19:08 +0900 Subject: [PATCH 19/21] add version in help menu --- Cargo.lock | 8 ++++---- src/detections/configs.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e1386c1..e6bcafe3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c794e162a5eff65c72ef524dfe393eb923c354e350bb78b9c7383df13f3bc142" +checksum = "508b352bb5c066aac251f6daf6b36eccd03e8a88e8081cd44959ea277a3af9a8" [[package]] name = "arrayref" @@ -879,9 +879,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1779539f58004e5dba1c1f093d44325ebeb244bfc04b791acdc0aaeca9c04570" +checksum = "9512e544c25736b82aebbd2bf739a47c8a1c935dfcc3a6adcde10e35cd3cd468" dependencies = [ "android_system_properties", "core-foundation", diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 0fd82715..93b4d972 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -54,7 +54,7 @@ impl Default for ConfigReader<'_> { #[derive(Parser)] #[clap( - name = "Hayabusa", + name = "Hayabusa 1.5.0-dev", usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", help_template = "\n{name}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", From 3e02cd683c9fe61493c70fa69fb1770e227537fb Mon Sep 17 00:00:00 2001 From: Yamato Security <71482215+YamatoSecurity@users.noreply.github.com> Date: Fri, 12 Aug 2022 08:27:49 +0900 Subject: [PATCH 20/21] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76d047ad..bd6bc155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - Removed ./ from rule path when updating. (#642) (@hitenkoku) - Added new output alias for MITRE ATT&CK tags and other tags. (#637) (@hitenkoku) -- Organized menu (#651) (@YamatoSecurity and @hitenkoku) +- Organized menu when `-h` is used. (#651) (@YamatoSecurity and @hitenkoku) - Added commas to summary numbers to make them easier to read. (#649) (@hitenkoku) - Added output percentage of detections in Result Summary. (#658) (@hitenkoku) From 3c9e0adaa9d2fe07b09e18f50fc2751744ba1045 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Fri, 12 Aug 2022 15:52:25 +0900 Subject: [PATCH 21/21] added version number --- src/detections/configs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 93b4d972..80a6d322 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -54,11 +54,11 @@ impl Default for ConfigReader<'_> { #[derive(Parser)] #[clap( - name = "Hayabusa 1.5.0-dev", + name = "Hayabusa", usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", - help_template = "\n{name}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", - // arg_required_else_help(true), + help_template = "\n{name} {version}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", + version, term_width = 400 )] pub struct Config {