Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only load and scan evtx files based on loaded rules #1318

Closed
hitenkoku opened this issue Mar 17, 2024 · 0 comments · Fixed by #1334
Closed

Only load and scan evtx files based on loaded rules #1318

hitenkoku opened this issue Mar 17, 2024 · 0 comments · Fixed by #1334
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@hitenkoku
Copy link
Collaborator

hitenkoku commented Mar 17, 2024

refs: #1317

Updated by Zach:
For clarification, for example, if a user chooses to scan with only a single rule that searches for events that have Channel: Security, then we should not load evtx files that have a Channel that is not Security. In most scenarios, there will not be multiple channels in a single .evtx file (unless the file was artificially created), so Hayabusa can check what channel is being used in the .evtx file by checking the first record's Channel field. In order to provide the ability to search all .evtx files regardless of rules, we will need to add a --scan-all-evtx-files option.
Determining what Channel a rule uses should be based on the Channel field defined in the rule (if there is one).
One thing we need to be careful about though, is that some rules do not have a service or category defined, and therefore do not have the Channel field defined on purpose because they are designed to scan all logs. There are currently only 2 rules that do this.

The first rule looks in all .evtx files for keywords that are related to Mimikatz and the second one searches all logs for hidden shellcode.

If these rules are enabled, then I think we should not add any .evtx files to load based on them or else all .evtx files would have to be loaded and it would not be possible to implement this issue. So for example, if a user ran the -r option and specified only one of these rules and did NOT also specify the --scan-all-evtx-files option, then Hayabusa should not load any .evtx files and the scan should finish immediately with no results.

This issue is to be implemented in csv-timeline and json-timeline commands.

Here is the flow of what I am thinking of.
+-----------------------+
| Load Sigma Rules |
| Extract Channels |
+-----------------------+
|
V
+-----------------------+
| Scan .evtx Directories|
| Read 1st Record of |
| Each .evtx for Channel|
+-----------------------+
|
V
+-----------------------+
| Match .evtx Channels |
| with Sigma Channels |
+-----------------------+
|
V
+-----------------------+
| Load Matched .evtx |
| Files Only |
+-----------------------+
|
V
+-----------------------+
| Filter Sigma Rules |
| Based on .evtx |
| File Channels |
+-----------------------+
|
V
+-----------------------+
| Process Scans Using |
| Applicable Sigma Rules|
+-----------------------+

This issue should be implemented before the issue of enabling only applicable sigma rules. (#1317)

I also want to inform the user about how many .evtx files are actually being scanned and how many .yml rules are actually being enabled.

Before:

Noisy rules: 12 (Disabled)

Stable rules: 107 (6.16%)
Test rules: 1,629 (93.84%)

Hayabusa rules: 19
Sigma rules: 1,717
Total enabled detection rules: 1,736

Output profile: standard

Scanning in progress. Please wait.

After:

Noisy rules: 12 (Disabled)

Stable rules: 107 (6.16%)
Test rules: 1,629 (93.84%)

Hayabusa rules: 19
Sigma rules: 1,717
Total specified detection rules: 1,736

Evtx files loaded after channel filter: XXX
Detection rules loaded after channel filter: XXX

Output profile: standard

Scanning in progress. Please wait.
  • The .evtx files shown in the progress bar should change depending on whether the Channel filter is enabled or not.
  • If --enable-all-rules is enabled, then we do not display Detection rules loaded after channel filter: xxxx
  • If --scan-all-evtx-files is enabled, then we do not display Evtx files loaded after channel filter: xxx
@hitenkoku hitenkoku added the enhancement New feature or request label Mar 17, 2024
@hitenkoku hitenkoku added this to the v3.0 milestone Mar 17, 2024
@YamatoSecurity YamatoSecurity modified the milestones: v3.0, v2.15.0 Mar 17, 2024
@YamatoSecurity YamatoSecurity modified the milestones: v2.15.0, v2.16.0 Apr 20, 2024
@YamatoSecurity YamatoSecurity changed the title Only load scannable evtx file to loaded rule Only load and scan evtx files based on loaded rules Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants