diff --git a/tools/sigma/backends/csharp.py b/tools/sigma/backends/csharp.py new file mode 100644 index 000000000..388b72ca9 --- /dev/null +++ b/tools/sigma/backends/csharp.py @@ -0,0 +1,165 @@ +# Output backends for sigmac +# Copyright 2020 Danijel Grah (dgrah@nil.com) + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . + +# How to use it in your CSharp program: +# public Dictionary sigmas = new Dictionary(); +# Dictionary evnt = new Dictionary(); +# this.evnt.Add(Key, Value); +# sigmas["rules/windows/process_creation/win_cmdkey_recon.yml"] = THE OUTPUT OF csharp BACKEND + +import re +import sigma +from .base import SingleTextQueryBackend +from .mixins import MultiRuleOutputMixin + +class CSharpBackend(SingleTextQueryBackend): + """Converts Sigma rule into CSharp Regex in LINQ query.""" + identifier = "csharp" + active = True + config_required = False + default_config = ["sysmon"] + + + reEscape = re.compile('((?