2015-02-26 21:42:51 +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
|
|
|
|
|
|
|
|
from lib.alerttask import AlertTask
|
2018-10-17 01:33:58 +03:00
|
|
|
from mozdef_util.query_models import SearchQuery, TermMatch, ExistsMatch
|
2016-08-03 23:40:10 +03:00
|
|
|
|
2015-02-26 21:42:51 +03:00
|
|
|
|
|
|
|
class AlertSSLBlacklistHit(AlertTask):
|
|
|
|
def main(self):
|
2016-08-03 23:40:10 +03:00
|
|
|
search_query = SearchQuery(minutes=15)
|
|
|
|
|
|
|
|
search_query.add_must([
|
2016-08-19 22:50:16 +03:00
|
|
|
TermMatch('eventsource', 'nsm'),
|
|
|
|
TermMatch('category', 'brointel'),
|
|
|
|
TermMatch('details.sources', 'abuse.ch SSLBL'),
|
2016-08-19 22:53:16 +03:00
|
|
|
ExistsMatch('details.sourceipaddress')
|
2016-08-03 23:40:10 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
self.filtersManual(search_query)
|
2015-02-26 21:42:51 +03:00
|
|
|
|
|
|
|
# Search events
|
|
|
|
self.searchEventsSimple()
|
|
|
|
self.walkEvents()
|
|
|
|
|
|
|
|
# Set alert properties
|
|
|
|
def onEvent(self, event):
|
|
|
|
category = 'correlatedalerts'
|
|
|
|
tags = ['nsm,bro,correlated']
|
|
|
|
severity = 'NOTICE'
|
|
|
|
hostname = event['_source']['hostname']
|
|
|
|
|
|
|
|
# the summary of the alert is the same as the event
|
|
|
|
summary = '{0} {1}'.format(hostname, event['_source']['summary'])
|
|
|
|
|
|
|
|
# Create the alert object based on these properties
|
|
|
|
return self.createAlertDict(summary, category, tags, [event], severity)
|