Merge remote-tracking branch 'origin/master'

This commit is contained in:
Florian Roth 2018-11-22 19:14:12 +01:00
commit e7762c71ce
4 changed files with 29 additions and 28 deletions

View File

@ -8,9 +8,8 @@ logsource:
category: proxy category: proxy
detection: detection:
selection: selection:
UserAgent: # Empty string - as used by Powershell's (New-Object Net.WebClient).DownloadString
# Empty string - as used by Powershell's (New-Object Net.WebClient).DownloadString UserAgent: ''
- ''
condition: selection condition: selection
fields: fields:
- ClientIP - ClientIP

View File

@ -26,7 +26,7 @@ class ElasticsearchQuerystringBackend(SingleTextQueryBackend):
identifier = "es-qs" identifier = "es-qs"
active = True active = True
reEscape = re.compile("([+\\-=!(){}\\[\\]^\"~:/]|\\\\(?![*?])|\\\\u|&&|\\|\\|)") reEscape = re.compile("([\\s+\\-=!(){}\\[\\]^\"~:/]|\\\\(?![*?])|\\\\u|&&|\\|\\|)")
reClear = re.compile("[<>]") reClear = re.compile("[<>]")
andToken = " AND " andToken = " AND "
orToken = " OR " orToken = " OR "
@ -34,12 +34,19 @@ class ElasticsearchQuerystringBackend(SingleTextQueryBackend):
subExpression = "(%s)" subExpression = "(%s)"
listExpression = "(%s)" listExpression = "(%s)"
listSeparator = " " listSeparator = " "
valueExpression = "\"%s\"" valueExpression = "%s"
nullExpression = "NOT _exists_:%s" nullExpression = "NOT _exists_:%s"
notNullExpression = "_exists_:%s" notNullExpression = "_exists_:%s"
mapExpression = "%s:%s" mapExpression = "%s:%s"
mapListsSpecialHandling = False mapListsSpecialHandling = False
def generateValueNode(self, node):
result = super().generateValueNode(node)
if result == "" or result.isspace():
return '""'
else:
return result
class ElasticsearchDSLBackend(RulenameCommentMixin, BaseBackend): class ElasticsearchDSLBackend(RulenameCommentMixin, BaseBackend):
"""ElasticSearch DSL backend""" """ElasticSearch DSL backend"""
identifier = 'es-dsl' identifier = 'es-dsl'

View File

@ -24,6 +24,24 @@ COND_OR = 2
COND_NOT = 3 COND_NOT = 3
COND_NULL = 4 COND_NULL = 4
# Debugging code
def dumpNode(node, indent=''): # pragma: no cover
"""
Recursively print the AST rooted at *node* for debugging.
"""
if hasattr(node, 'items'):
print("%s%s<%s>" % (indent, type(node).__name__,
type(node.items).__name__))
if type(node.items) != list:
dumpNode(node.items, indent + ' ')
else:
for item in node.items:
dumpNode(item, indent + ' ')
else:
print("%s%s=%s" % (indent, type(node).__name__,
repr(node)))
return node
# Condition Tokenizer # Condition Tokenizer
class SigmaConditionToken: class SigmaConditionToken:
"""Token of a Sigma condition expression""" """Token of a Sigma condition expression"""
@ -271,23 +289,6 @@ class SigmaConditionOptimizer:
""" """
Optimizer for the parsed AST. Optimizer for the parsed AST.
""" """
def _dumpNode(self, node, indent=''): # pragma: no cover
"""
Recursively print the AST rooted at *node* for debugging.
"""
if hasattr(node, 'items'):
print("%s%s<%s>" % (indent, type(node).__name__,
type(node.items).__name__))
if type(node.items) != list:
self._dumpNode(node.items, indent + ' ')
else:
for item in node.items:
self._dumpNode(item, indent + ' ')
else:
print("%s%s=%s" % (indent, type(node).__name__,
repr(node)))
return node
def _stripSubexpressionNode(self, node): def _stripSubexpressionNode(self, node):
""" """
Recursively strips all subexpressions (i.e. brackets) from the AST. Recursively strips all subexpressions (i.e. brackets) from the AST.

View File

@ -87,12 +87,6 @@ class SigmaParser:
fields = [ fields ] fields = [ fields ]
for field in fields: for field in fields:
cond.add(ConditionNULLValue(val=field)) cond.add(ConditionNULLValue(val=field))
elif value == "not null":
fields = mapping.resolve_fieldname(key)
if type(fields) == str:
fields = [ fields ]
for field in fields:
cond.add(ConditionNotNULLValue(val=field))
else: else:
cond.add(mapping.resolve(key, value, self)) cond.add(mapping.resolve(key, value, self))