2017-03-16 01:17:41 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
# Copyright (c) 2014 Mozilla Corporation
|
|
|
|
#
|
2017-12-23 00:01:51 +03:00
|
|
|
# This code alerts on every successfully opened session on any of the host from a given list
|
2017-03-16 01:17:41 +03:00
|
|
|
|
|
|
|
from lib.alerttask import AlertTask
|
2018-10-17 01:33:58 +03:00
|
|
|
from mozdef_util.query_models import SearchQuery, TermMatch, QueryStringMatch, PhraseMatch
|
2017-03-16 01:17:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
class PromiscAudit(AlertTask):
|
|
|
|
def main(self):
|
|
|
|
search_query = SearchQuery(minutes=2)
|
|
|
|
|
|
|
|
search_query.add_must([
|
|
|
|
TermMatch('category', 'promiscuous'),
|
|
|
|
PhraseMatch('summary', 'promiscuous'),
|
2018-03-03 00:29:30 +03:00
|
|
|
PhraseMatch('summary', 'on')
|
2017-03-16 01:17:41 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
search_query.add_must_not([
|
|
|
|
QueryStringMatch('details.dev: veth*'),
|
|
|
|
])
|
|
|
|
|
|
|
|
self.filtersManual(search_query)
|
|
|
|
self.searchEventsSimple()
|
|
|
|
self.walkEvents()
|
|
|
|
|
|
|
|
def onEvent(self, event):
|
|
|
|
category = 'promisc'
|
2017-03-27 20:15:57 +03:00
|
|
|
severity = 'WARNING'
|
2017-03-16 01:17:41 +03:00
|
|
|
tags = ['promisc', 'audit']
|
|
|
|
|
|
|
|
summary = 'Promiscuous mode enabled on {0}'.format(event['_source']['hostname'])
|
|
|
|
|
|
|
|
return self.createAlertDict(summary, category, tags, [event], severity)
|