2017-02-13 23:14:40 +01:00
|
|
|
# Output backends for sigmac
|
2018-07-24 00:01:16 +02:00
|
|
|
# Copyright 2016-2017 Thomas Patzke, Ben de Haan
|
2017-12-07 21:55:43 +01:00
|
|
|
|
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
2017-02-13 23:14:40 +01:00
|
|
|
|
2017-02-22 22:47:12 +01:00
|
|
|
import re
|
|
|
|
|
import sigma
|
2018-07-20 23:30:32 +02:00
|
|
|
from .base import SingleTextQueryBackend
|
2017-02-13 23:14:40 +01:00
|
|
|
|
2017-06-02 23:43:45 +02:00
|
|
|
class LogPointBackend(SingleTextQueryBackend):
|
2017-03-18 11:12:06 +01:00
|
|
|
"""Converts Sigma rule into LogPoint query"""
|
|
|
|
|
identifier = "logpoint"
|
|
|
|
|
active = True
|
2019-11-03 23:32:50 +01:00
|
|
|
config_required = False
|
|
|
|
|
default_config = ["sysmon", "logpoint-windows"]
|
2017-03-18 11:12:06 +01:00
|
|
|
|
2019-02-02 00:18:58 +01:00
|
|
|
# \ -> \\
|
|
|
|
|
# \* -> \*
|
|
|
|
|
# \\* -> \\*
|
|
|
|
|
reEscape = re.compile('("|(?<!\\\\)\\\\(?![*?\\\\]))')
|
2017-06-02 23:43:45 +02:00
|
|
|
reClear = None
|
|
|
|
|
andToken = " "
|
|
|
|
|
orToken = " OR "
|
|
|
|
|
notToken = " -"
|
|
|
|
|
subExpression = "(%s)"
|
|
|
|
|
listExpression = "[%s]"
|
|
|
|
|
listSeparator = ", "
|
|
|
|
|
valueExpression = "\"%s\""
|
2017-10-29 23:57:39 +01:00
|
|
|
nullExpression = "-%s=*"
|
|
|
|
|
notNullExpression = "%s=*"
|
2017-06-02 23:43:45 +02:00
|
|
|
mapExpression = "%s=%s"
|
|
|
|
|
mapListsSpecialHandling = True
|
|
|
|
|
mapListValueExpression = "%s IN %s"
|
2018-04-06 17:36:11 +02:00
|
|
|
|
2017-06-19 15:21:29 +02:00
|
|
|
def generateAggregation(self, agg):
|
|
|
|
|
if agg == None:
|
|
|
|
|
return ""
|
2018-07-27 00:02:07 +02:00
|
|
|
if agg.aggfunc == sigma.parser.condition.SigmaAggregationParser.AGGFUNC_NEAR:
|
2017-08-05 23:48:28 +02:00
|
|
|
raise NotImplementedError("The 'near' aggregation operator is not yet implemented for this backend")
|
2017-06-19 15:21:29 +02:00
|
|
|
if agg.groupfield == None:
|
2018-08-10 15:02:48 +02:00
|
|
|
return " | chart %s(%s) as val | search val %s %s" % (agg.aggfunc_notrans, agg.aggfield or "", agg.cond_op, agg.condition)
|
2017-06-19 15:21:29 +02:00
|
|
|
else:
|
2018-08-10 15:02:48 +02:00
|
|
|
return " | chart %s(%s) as val by %s | search val %s %s" % (agg.aggfunc_notrans, agg.aggfield or "", agg.groupfield or "", agg.cond_op, agg.condition)
|