-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rules] Add community rule to detect ssh login activity based on osqu…
…ery events (#1127) * [rules] Add community rule to alert on ssh login activity based on osquery detection * address comments
- Loading branch information
1 parent
c1ec0c8
commit e500e1d
Showing
5 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Detect ssh login activity based on osquery last table""" | ||
from rules.matchers.matchers import OsqueryMatcher | ||
from streamalert.shared.rule import rule | ||
|
||
|
||
@rule(logs=['osquery:differential'], | ||
matchers=[OsqueryMatcher.added, OsqueryMatcher.user_login]) | ||
def ssh_login_activity(_): | ||
""" | ||
author: chunyong-lin | ||
description: Detect on ssh login activity to the linux host based on osquery | ||
last table. This rule assumes we use default osquery pack | ||
shipped with osquery package located at | ||
/usr/share/osquery/packs/incident-response.conf on the linux | ||
host. Update the pack name in rules/matchers/matchers.py if different. | ||
reference: https://osquery.io/schema/4.1.2#last | ||
""" | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
[ | ||
{ | ||
"data": { | ||
"action": "added", | ||
"calendarTime": "Wed Feb 12 21:38:11 2020 UTC", | ||
"columns": { | ||
"host": "10.0.2.2", | ||
"pid": 12345, | ||
"time": 1581542540, | ||
"tty": "ttys001", | ||
"type": "7", | ||
"username": "vagrant" | ||
}, | ||
"decorations": { | ||
"envIdentifier": "fake-environment", | ||
"roleIdentifier": "fake-role" | ||
}, | ||
"epoch": "0", | ||
"hostIdentifier": "...", | ||
"log_type": "result", | ||
"name": "pack_incident-response_last", | ||
"unixTime": "1581543491" | ||
}, | ||
"description": "This rule alerts on ssh logins to a linux host", | ||
"log": "osquery:differential", | ||
"service": "kinesis", | ||
"source": "prefix_cluster1_streamalert", | ||
"trigger_rules": [ | ||
"ssh_login_activity" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"action": "added", | ||
"calendarTime": "Wed Feb 12 21:38:11 2020 UTC", | ||
"columns": { | ||
"host": "10.0.2.2", | ||
"pid": 12345, | ||
"time": 1581542540, | ||
"tty": "ttys001", | ||
"type": "7", | ||
"username": "runlevel" | ||
}, | ||
"decorations": { | ||
"envIdentifier": "fake-environment", | ||
"roleIdentifier": "fake-role" | ||
}, | ||
"epoch": "0", | ||
"hostIdentifier": "...", | ||
"log_type": "result", | ||
"name": "pack_incident-response_last", | ||
"unixTime": "1581543491" | ||
}, | ||
"description": "This rule will not alert on runlevel ssh logins", | ||
"log": "osquery:differential", | ||
"service": "kinesis", | ||
"source": "prefix_cluster1_streamalert", | ||
"trigger_rules": [] | ||
}, | ||
{ | ||
"data": { | ||
"action": "added", | ||
"calendarTime": "Wed Feb 12 21:38:11 2020 UTC", | ||
"columns": { | ||
"host": "10.0.2.2", | ||
"pid": 12345, | ||
"time": 1581542540, | ||
"tty": "ttys001", | ||
"type": "8", | ||
"username": "runlevel" | ||
}, | ||
"decorations": { | ||
"envIdentifier": "fake-environment", | ||
"roleIdentifier": "fake-role" | ||
}, | ||
"epoch": "0", | ||
"hostIdentifier": "...", | ||
"log_type": "result", | ||
"name": "pack_incident-response_last", | ||
"unixTime": "1581543491" | ||
}, | ||
"description": "This rule will not alert on ssh logout(type: 8)", | ||
"log": "osquery:differential", | ||
"service": "kinesis", | ||
"source": "prefix_cluster1_streamalert", | ||
"trigger_rules": [] | ||
} | ||
] |