MozDef/alerts/http_auth_bruteforce.py

47 строки
1.6 KiB
Python
Исходник Обычный вид История

2017-06-15 22:56:47 +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/.
2017-05-27 00:05:15 +03:00
# Copyright (c) 2017 Mozilla Corporation
2017-06-15 22:56:47 +03:00
#
# Contributors:
# Michal Purzynski michal@mozilla.com
2017-05-27 00:05:15 +03:00
# Brandon Myers bmyers@mozilla.com
2017-06-15 22:56:47 +03:00
from lib.alerttask import AlertTask
from query_models import SearchQuery, TermMatch, ExistsMatch, PhraseMatch
2017-06-15 22:56:47 +03:00
class AlertHTTPBruteforce(AlertTask):
def main(self):
2017-05-27 00:05:15 +03:00
self.parse_config('httpauthbruteforce.conf', ['url'])
search_query = SearchQuery(minutes=15)
search_query.add_must([
TermMatch('_type', 'bro'),
TermMatch('eventsource', 'nsm'),
TermMatch('category', 'bronotice'),
ExistsMatch('details.sourceipaddress'),
PhraseMatch('details.note', 'AuthBruteforcing::HTTP_AuthBruteforcing_Attacker'),
])
2017-06-15 22:56:47 +03:00
self.filtersManual(search_query)
2017-06-15 22:56:47 +03:00
# Search events
self.searchEventsSimple()
self.walkEvents()
# Set alert properties
def onEvent(self, event):
category = 'httperrors'
tags = ['http']
severity = 'WARNING'
2017-06-15 22:56:47 +03:00
hostname = event['_source']['hostname']
2017-05-27 00:05:15 +03:00
url = self.config.url
2017-06-15 22:56:47 +03:00
# 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=severity, url=url)