Skip to content

incorrect conversion of regular expressions #177

Description

@conitrade-as

Trying to convert sigma rules to an elasticsearch backend with the sysmon pipeline does not convert regular expressions. Consider the following example:

title: Test Rule with Regular Expression
logsource:
    category: process_creation
    product: windows
detection:
    selection:
        Image|endswith: '\svchost.exe'
    filter_main_flags:
        CommandLine|re: '-k\s\w{1,64}(\s?(-p|-s))?'
    condition: selection and not 1 of filter_main_*

The following command line is used for conversion:

sigma convert -t lucene -p sysmon -p ecs_windows rule.yaml

Converting the rule currently yields the following:

winlog.channel:Microsoft\-Windows\-Sysmon\/Operational AND (event.code:1 AND (process.executable:*\\svchost.exe AND (NOT process.command_line:SigmaRegularExpression\(regexp\=SigmaString\(\['\-k\\s\\w\{1,64\}\(\\s',\ \<SpecialChars.WILDCARD_SINGLE\:\ 2\>,\ '\(\-p\|\-s\)\)',\ \<SpecialChars.WILDCARD_SINGLE\:\ 2\>\]\),\ flags\=set\(\)\))))

Reverting changes from 8914d68 however yields the following:

winlog.channel:Microsoft\-Windows\-Sysmon\/Operational AND (event.code:1 AND (process.executable:*\\svchost.exe AND (NOT process.command_line:/-k\s\w{1,64}(\s?(-p|-s))?/)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions