Feature/#187 change allowlist regexes filenames (#189)

* add risk level filter arguments #45

* fix default level in help #45

* add test yaml files #45

* refactoring and fix level argument usage.

* cargo fmt --all

* add risk level filter arguments #45

* fix default level in help #45

* add test yaml files #45

* refactoring and fix level argument usage.

* cargo fmt --all

* update

* change filename

* fix regexe and allowlist filename in document #187

Co-authored-by: DustInDark <nextsasasa@gmail.com>
This commit is contained in:
James
2021-11-12 13:53:09 +09:00
committed by GitHub
parent 22c8302c4c
commit 7d49b0b521
9 changed files with 18 additions and 18 deletions

View File

@@ -243,12 +243,12 @@ Currently, the following keywords can be specified.
* regexes: matches if one of the regular expressions in the file that you specify in this field matches.
* allowlist: rule will be skipped if there is any match found in the list of regular expressions in the file that you specify in this field.
### regexes.txt and allowlist.txt
Hayabusa provides built-in rules using regular expressions (defined in `regexes.txt`) and allowlisting (defined in `allowlist.txt`).
regexes.txt and allowlist.txt can be edited to change the behavior of all referenced rules at once.
### regexes and allowlist
Hayabusa provides built-in rules using regular expressions (defined in `config/regex/regexes_suspicous_service.txt`) and allowlisting (defined in `config/regex/allowlist_legimate_serviceimage.txt`).
regexes and allowlist can be edited to change the behavior of all referenced rules at once.
You can also specify to use different regexes and allowlist textfiles.
Please refer to the default regexes.txt and allowlist.txt when creating your own.
Please refer to the default regexes_suspicous_service.txt and allowlist_legimate_serviceimage.txt when creating your own.
## condition
With the notation we explained above, you can express AND and OR logic but it will be confusing if you are trying to define complex logic.

View File

@@ -238,10 +238,10 @@ detection:
* regexes: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致した`ものとして処理されます。
* allowlist: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致していない`ものとして処理されます。
### regexes.txtとallowlist.txt
hayabusaではregexesやallowlistを使用した組み込みのルールを用意しており、それらのルールはregexes.txtとallowlist.txtを参照しています。regexes.txtとallowlist.txtを書き換えることで、参照する全てのルールの挙動を一度に変更することが可能です。
### regexesとallowlist
hayabusaではregexesやallowlistを使用した組み込みのルールを用意しており、それらのルールはhayabusa/config/regex内にあるregexes_suspicous_service.txtとallowlist_legimate_serviceimage.txtを参照しています。これらのファイルを書き換えることで、参照する全てのルールの挙動を一度に変更することが可能です。
また、regexesやallowlistに指定するファイルは、ユーザーが独自に作成することも可能です。作成する場合、regexes.txtとallowlist.txtを参考にしてください。
また、regexesやallowlistに指定するファイルは、ユーザーが独自に作成することも可能です。作成する場合、regexes_suspicous_service.txtとallowlist_legimate_serviceimage.txtを参考にしてください。
## condition
これまでの記法を用いると、AND条件やOR条件を表現することができますが、ANDやOR等が複雑に入り組んだ条件を定義することは難しい場合があります。その場合、conditionというキーワードを使用することで、複雑な条件式を定義することができます。

View File

@@ -6,7 +6,7 @@ detection:
Channel: System
EventID: 7030
param1:
regexes: ./regexes.txt
regexes: ./config/regex/regexes_suspicous_service.txt
# condition: selection
falsepositives:
- unknown

View File

@@ -6,7 +6,7 @@ detection:
Channel: System
EventID: 7036
param1:
regexes: ./regexes.txt
regexes: ./config/regex/regexes_suspicous_service.txt
condition: selection
falsepositives:
- unknown

View File

@@ -6,10 +6,10 @@ detection:
Channel: System
EventID: 7045
ServiceName:
regexes: ./regexes.txt
regexes: ./config/regex/regexes_suspicous_service.txt
ImagePath:
min_length: 1000
allowlist: ./allowlist.txt
allowlist: ./config/regex/allowlist_legimate_serviceimage.txt
condition: selection
falsepositives:
- unknown

View File

@@ -519,8 +519,8 @@ mod tests {
- ホスト アプリケーション
ImagePath:
min_length: 1234321
regexes: ./regexes.txt
allowlist: ./allowlist.txt
regexes: ./config/regex/regexes_suspicous_service.txt
allowlist: ./config/regex/allowlist_legimate_serviceimage.txt
falsepositives:
- unknown
level: medium
@@ -1081,7 +1081,7 @@ mod tests {
selection:
EventID: 4103
Channel:
- allowlist: allowlist.txt
- allowlist: ./config/regex/allowlist_legimate_serviceimage.txt
output: 'command=%CommandLine%'
"#;
@@ -1113,7 +1113,7 @@ mod tests {
selection:
EventID: 4103
Channel:
- allowlist: allowlist.txt
- allowlist: ./config/regex/allowlist_legimate_serviceimage.txt
output: 'command=%CommandLine%'
"#;
@@ -1145,7 +1145,7 @@ mod tests {
selection:
EventID: 4103
Channel:
- allowlist: allowlist.txt
- allowlist: ./config/regex/allowlist_legimate_serviceimage.txt
output: 'command=%CommandLine%'
"#;

View File

@@ -153,7 +153,7 @@ mod tests {
#[test]
fn test_check_regex() {
let regexes = utils::read_txt("regexes.txt")
let regexes = utils::read_txt("./config/regex/regexes_suspicous_service.txt")
.unwrap()
.into_iter()
.map(|regex_str| Regex::new(&regex_str).unwrap())
@@ -168,7 +168,7 @@ mod tests {
#[test]
fn test_check_allowlist() {
let commandline = "\"C:\\Program Files\\Google\\Update\\GoogleUpdate.exe\"";
let allowlist = utils::read_txt("allowlist.txt")
let allowlist = utils::read_txt("./config/regex/allowlist_legimate_serviceimage.txt")
.unwrap()
.into_iter()
.map(|allow_str| Regex::new(&allow_str).unwrap())