forked from johnnykv/mnemosyne
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathkippo_events.py
59 lines (48 loc) · 2.09 KB
/
kippo_events.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (C) 2012 Johnny Vestergaard <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import json
from normalizer.modules.basenormalizer import BaseNormalizer
class KippoEvents(BaseNormalizer):
channels = ('kippo.sessions',)
def normalize(self, data, channel, submission_timestamp, ignore_rfc1918=True):
o_data = self.parse_record_data(data)
if ignore_rfc1918 and self.is_RFC1918_addr(o_data['peerIP']):
return []
session = {
'timestamp': submission_timestamp,
'source_ip': o_data['peerIP'],
'source_port': o_data['peerPort'],
'destination_port': o_data['hostPort'],
'honeypot': 'kippo',
'protocol': 'ssh',
'session_ssh': {'version': o_data['version']}
}
if 'ttylog' in o_data and o_data['ttylog'] is not None:
attachments = [
{
'description': 'Kippo session log (ttylog).',
'data': o_data['ttylog']
}, ]
session['attachments'] = attachments
if len(o_data['credentials']) > 0:
auth_attempts = []
for cred in o_data['credentials']:
auth_attempts.append({'login': cred[0],
'password': cred[1]})
session['auth_attempts'] = auth_attempts
relations = [{'session': session}, ]
return relations