From 742465164a1ae59416e672cc7192c466679c35cf Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 29 Jun 2022 20:36:44 +0900 Subject: [PATCH 1/6] Add: default output when no details are defined #606 --- src/detections/detection.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/detections/detection.rs b/src/detections/detection.rs index a507c2dc..6f40002b 100644 --- a/src/detections/detection.rs +++ b/src/detections/detection.rs @@ -243,10 +243,11 @@ impl Detection { .unwrap_or_default(); let eid = get_serde_number_to_string(&record_info.record["Event"]["System"]["EventID"]) .unwrap_or_else(|| "-".to_owned()); - let default_output = DEFAULT_DETAILS - .get(&format!("{}_{}", provider, &eid)) - .unwrap_or(&"-".to_string()) - .to_string(); + let default_output = match DEFAULT_DETAILS + .get(&format!("{}_{}", provider, &eid)) { + Some(str) => str.to_owned(), + None => recinfo.as_ref().unwrap_or(&"-".to_string()).to_string(), + }; let detect_info = DetectInfo { filepath: record_info.evtx_filepath.to_string(), rulepath: rule.rulepath.to_string(), From a2d8b9bb24d2d2727d0532031fe39278560fc9fa Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 29 Jun 2022 20:51:54 +0900 Subject: [PATCH 2/6] updated changelog #606 --- CHANGELOG-Japanese.md | 15 +++++++++++++++ CHANGELOG.md | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index 4398808e..6e74e58c 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -1,5 +1,20 @@ # 変更点 +## v1.4.1 [2022/0X/XX] + +**New Features:** + +- XX + +**Enhancements:** + +- ルールや`default_details.txt` に対応する`details`の記載がない場合、すべてのフィールド情報を結果の``Details`列に出力するようにした (#606) (@hitenkoku) + +**Bug Fixes:** + +- XX + + ## v1.4.0 [2022/06/26] **新機能:** diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e223709..08e626df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changes +## v1.4.1 [2022/0X/XX] + +**New Features:** + +- XX + +**Enhancements:** + +- Changed output all field info when no details are defined in rule and `default_details.txt` . (#606) (@hitenkoku) + +**Bug Fixes:** + +- XX + ## v1.4.0 [2022/06/26] **New Features:** From 59f79161beaa47f9f4815a3f5687d0554cd34ab8 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 29 Jun 2022 20:52:15 +0900 Subject: [PATCH 3/6] updated readme #606 --- 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 b8670c98..03711e05 100644 --- a/README-Japanese.md +++ b/README-Japanese.md @@ -505,7 +505,7 @@ Hayabusaの結果を標準出力に表示しているとき(デフォルト) * `Level`: YML検知ルールの`level`フィールドから来ています。(例:`informational`, `low`, `medium`, `high`, `critical`) デフォルトでは、すべてのレベルのアラートとイベントが出力されますが、`-m`オプションで最低のレベルを指定することができます。例えば`-m high`オプションを付けると、`high`と`critical`アラートしか出力されません。 * `Title`: YML検知ルールの`title`フィールドから来ています。 * `RecordID`: イベントレコードIDです。``フィールドから来ています。`-R`もしくは`--hide-record-id`オプションを付けると表示されません。 -* `Details`: YML検知ルールの`details`フィールドから来ていますが、このフィールドはHayabusaルールにしかありません。このフィールドはアラートとイベントに関する追加情報を提供し、ログのフィールドから有用なデータを抽出することができます。イベントキーのマッピングが間違っている場合、もしくはフィールドが存在しない場合で抽出ができなかった箇所は`n/a` (not available)と記載されます。YML検知ルールに`details`フィールドが存在しない時のdetailsのメッセージを`./rules/config/default_details.txt`で設定できます。`default_details.txt`では`Provider Name`、`EventID`、`details`の組み合わせで設定することができます。 +* `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検知ルールに対応するルールが記載されていない場合はすべてのフィールド情報を出力します。 CSVファイルとして保存する場合、以下の列が追加されます: diff --git a/README.md b/README.md index bfb4e366..b3d70e3c 100644 --- a/README.md +++ b/README.md @@ -502,7 +502,7 @@ When hayabusa output is being displayed to the screen (the default), it will dis * `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. You can hidde this output with the `-R` or `--hide-record-id` option. * `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`. +* `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 description in `default_details.txt` and the YML detection rule, all fields information will be outputted. The following additional columns will be added to the output when saving to a CSV file: From 8bf5752cc73c5de20693f4284f53f03a99b7fcfa Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 29 Jun 2022 22:15:35 +0900 Subject: [PATCH 4/6] mv: full-data option check #606 --- src/detections/detection.rs | 8 +++++++- src/detections/utils.rs | 7 ++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/detections/detection.rs b/src/detections/detection.rs index 6f40002b..90c86113 100644 --- a/src/detections/detection.rs +++ b/src/detections/detection.rs @@ -248,6 +248,12 @@ impl Detection { Some(str) => str.to_owned(), None => recinfo.as_ref().unwrap_or(&"-".to_string()).to_string(), }; + let opt_record_info = if configs::CONFIG.read().unwrap().args.full_data { + recinfo + } else { + None + }; + let detect_info = DetectInfo { filepath: record_info.evtx_filepath.to_string(), rulepath: rule.rulepath.to_string(), @@ -260,7 +266,7 @@ impl Detection { alert: rule.yaml["title"].as_str().unwrap_or("").to_string(), detail: String::default(), tag_info: tag_info.join(" | "), - record_information: recinfo, + record_information: opt_record_info, record_id: rec_id, }; MESSAGES.lock().unwrap().insert( diff --git a/src/detections/utils.rs b/src/detections/utils.rs index 49236e4a..bfbc0a3b 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -235,11 +235,8 @@ pub fn create_rec_info(data: Value, path: String, keys: &[String]) -> EvtxRecord // EvtxRecordInfoを作る let data_str = data.to_string(); - let rec_info = if configs::CONFIG.read().unwrap().args.full_data { - Option::Some(create_recordinfos(&data)) - } else { - Option::None - }; + let rec_info = Option::Some(create_recordinfos(&data)); + EvtxRecordInfo { evtx_filepath: path, record: data, From b10ffa07d8c325f24deb68693312275058ece2b1 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Wed, 29 Jun 2022 22:18:16 +0900 Subject: [PATCH 5/6] cargo fmt --- src/detections/detection.rs | 7 +++---- src/detections/utils.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/detections/detection.rs b/src/detections/detection.rs index 90c86113..5ed131cc 100644 --- a/src/detections/detection.rs +++ b/src/detections/detection.rs @@ -243,10 +243,9 @@ impl Detection { .unwrap_or_default(); let eid = get_serde_number_to_string(&record_info.record["Event"]["System"]["EventID"]) .unwrap_or_else(|| "-".to_owned()); - let default_output = match DEFAULT_DETAILS - .get(&format!("{}_{}", provider, &eid)) { - Some(str) => str.to_owned(), - None => recinfo.as_ref().unwrap_or(&"-".to_string()).to_string(), + let default_output = match DEFAULT_DETAILS.get(&format!("{}_{}", provider, &eid)) { + Some(str) => str.to_owned(), + None => recinfo.as_ref().unwrap_or(&"-".to_string()).to_string(), }; let opt_record_info = if configs::CONFIG.read().unwrap().args.full_data { recinfo diff --git a/src/detections/utils.rs b/src/detections/utils.rs index bfbc0a3b..18754e3d 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -236,7 +236,7 @@ pub fn create_rec_info(data: Value, path: String, keys: &[String]) -> EvtxRecord // EvtxRecordInfoを作る let data_str = data.to_string(); let rec_info = Option::Some(create_recordinfos(&data)); - + EvtxRecordInfo { evtx_filepath: path, record: data, From 220bac46e42a19f0019c532ffa9676dbd468924a Mon Sep 17 00:00:00 2001 From: Tanaka Zakku <71482215+YamatoSecurity@users.noreply.github.com> Date: Wed, 29 Jun 2022 23:21:14 +0900 Subject: [PATCH 6/6] update changelog --- CHANGELOG-Japanese.md | 11 ++--------- CHANGELOG.md | 13 +++---------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index 31aebdf6..b1933b2a 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -1,19 +1,12 @@ # 変更点 -## v1.4.1 [2022/xx/xx] - -**新機能:** - -- XXX +## v1.4.1 [2022/06/30] **改善:** - ルールや`default_details.txt` に対応する`details`の記載がない場合、すべてのフィールド情報を結果の``Details`列に出力するようにした (#606) (@hitenkoku) - `--deep-scan`オプションの追加。 このオプションがない場合、`config/target_event_ids.txt`で指定されたイベントIDのみをスキャン対象とします。 このオプションをつけることですべてのイベントIDをスキャン対象とします。(#608) (@hitenkoku) - -**バグ修正:** - -- XXX +- `-U, --update-rules`オプションで`channel_abbreviations.txt`、`statistics_event_info.txt`、`target_event_IDs.txt`を更新できるように、`config`ディレクトリから`rules/config`ディレクトリに移動した。 ## v1.4.0 [2022/06/26] diff --git a/CHANGELOG.md b/CHANGELOG.md index da110b22..dfc0dbe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,12 @@ # Changes -## v1.4.1 [2022/xx/xx] - -**New Features:** - -- XXX +## v1.4.1 [2022/06/30] **Enhancements:** -- Changed output all field info when no details are defined in rule and `default_details.txt` . (#606) (@hitenkoku) +- When no `details` field is defined in rule nor `default_details.txt`, all fields will be outputted to the `details` column. (#606) (@hitenkoku) - Added the `-D, --deep-scan` option. Now by default, events are filtered by Event IDs that there are detection rules for defined in `rules/config/target_event_IDs.txt`. This should improve performance by 25~55% while still detecting almost everything. If you want to do a thorough scan on all events, you can disable the event ID filter with `-D, --deep-scan`. (#608) (@hitenkoku) - -**Bug Fixes:** - -- XXX +- `channel_abbreviations.txt`, `statistics_event_info.txt` and `target_event_IDs.txt` have been moved from the `config` directory to the `rules/config` directory in order to provide updates with `-U, --update-rules`. ## v1.4.0 [2022/06/26]