-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from sifex/feature/sigma-filters
Adds support for Sigma Filters
- Loading branch information
Showing
9 changed files
with
739 additions
and
627 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
title: Filter Out Administrator account | ||
description: The valid administrator account start with adm_ | ||
logsource: | ||
category: process_creation | ||
product: windows | ||
filter: | ||
rules: | ||
- 5013332f-8a70-4e04-bcc1-06a98a2cca2e | ||
- 6f3e2987-db24-4c78-a860-b4f4095a7095 # Data Compressed - rar.exe | ||
- df0841c0-9846-4e9f-ad8a-7df91571771b # Login on jump host | ||
- 5d8fd9da-6916-45ef-8d4d-3fa9d19d1a64 # Base rule | ||
selection: | ||
User|startswith: "ADM_" | ||
condition: not selection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from click.testing import CliRunner | ||
|
||
from sigma.cli.convert import convert | ||
|
||
|
||
def test_filter_basic_operation(): | ||
cli = CliRunner( | ||
mix_stderr=True | ||
) | ||
result = cli.invoke( | ||
convert, ["-t", "text_query_test", "--filter", "tests/files/sigma_filter.yml", "tests/files/valid/sigma_rule.yml"], | ||
) | ||
assert 'ParentImage endswith "\\httpd.exe" and Image endswith "\\cmd.exe" and not User startswith "ADM_"\n' in result.stdout | ||
|
||
|
||
def test_filter_basic_from_stdin(): | ||
cli = CliRunner() | ||
with open("tests/files/valid/sigma_rule.yml", "rt") as yml_file: | ||
input = yml_file.read() | ||
result = cli.invoke( | ||
convert, | ||
[ | ||
"-t", | ||
"text_query_test", | ||
"--filter", | ||
"tests/files/sigma_filter.yml", | ||
"-", | ||
], | ||
input=input, | ||
) | ||
assert ( | ||
'ParentImage endswith "\\httpd.exe" and Image endswith "\\cmd.exe" and not User startswith "ADM_"\n' | ||
in result.stdout | ||
) | ||
|
||
|
||
def test_filter_with_pipeline_mapping(): | ||
cli = CliRunner( | ||
mix_stderr=True | ||
) | ||
result = cli.invoke( | ||
convert, [ | ||
"-t", | ||
"text_query_test", | ||
"-p", | ||
"tests/files/custom_pipeline.yml", | ||
"--filter", | ||
"tests/files/sigma_filter.yml", | ||
"tests/files/valid/sigma_rule.yml" | ||
], | ||
) | ||
|
||
assert 'some_other_string endswith "\\httpd.exe" and Image endswith "\\cmd.exe" and not username startswith "ADM_"\n' in result.stdout | ||
|
||
|
||
|
||
# def test_filter_with_correlation_rules(): | ||
# cli = CliRunner( | ||
# mix_stderr=True | ||
# ) | ||
# result = cli.invoke( | ||
# convert, [ | ||
# | ||
# "-t", | ||
# "text_query_test", | ||
# "-p", | ||
# "tests/files/custom_pipeline.yml", | ||
# "--filter", | ||
# "tests/files/sigma_filter.yml", | ||
# "./tests/files/valid/sigma_correlation_rules.yml" | ||
# ], | ||
# ) | ||
# | ||
# assert 'some_other_string endswith "\\httpd.exe" and Image endswith "\\cmd.exe" and not username startswith "ADM_"\n' in result.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters