Yamato-Security / hayabusa

Hayabusa (隼) is a sigma-based threat hunting and fast forensics timeline generator for Windows event logs.
GNU Affero General Public License v3.0
2.25k stars 199 forks source link

Implement `utf16/utf16be/utf16le/wide` modifiers #1432

Open YamatoSecurity opened 5 days ago

YamatoSecurity commented 5 days ago

Although not used in any rules yet, we would like to support the following modifiers for sigma support completeness:

Probably no need to support as base64offset is usually used instead of base64:

Example:

detection:
  selection:
    CommandLine|wide|base64offset|contains: "ping"

Info: https://sigmahq.io/docs/basics/modifiers.html#wide

Prepends a byte order mark and encodes UTF16, (only used in combination with base64 modifiers)

Don't end with utf16, utf16le, utf16be or wide

The value modifier chain must not end with character set encoding modifiers (utf16, utf16le, utf16be and wide). The resulting values are internally represented as byte sequences instead of text strings and contain null characters which are usually difficult to handle in queries. Therefore the should be followed by an encoding modifier (base64, base64offset)

I think we should implement utf16 to check both utf16be and utf16le variants. wide should be an alias for utf16le in Windows.

We should probably investigate if these encodings are being used inside base64 encoded payloads to begin with. If not, then it probably is not worth implementing.

hitenkoku commented 4 days ago

The value modifier chain must not end with character set encoding modifiers (utf16, utf16le, utf16be and wide). The resulting values are internally represented as byte sequences instead of text strings and contain null characters which are usually difficult to handle in queries. Therefore the should be followed by an encoding modifier (base64, base64offset) Usually it doesn't makes sense to combine the re type modifier with any other modifier.

https://github.com/SigmaHQ/sigma/wiki/Rule-Creation-Guide

YamatoSecurity commented 4 days ago

@hitenkoku Thanks for the information! I was mistaken on how it was being used. I updated the specifications.