AlienVault Plugin User Guide
AlienVault Plugin User Guide
AUTHOR: Blueliv
DATE: April 16, 2015
Restricted access document
Contents
1 Installation 2
1.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Getting started 5
2.1 CrimeServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Annexes 9
A Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Plugin code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Plugin Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
Installation
1.1 Requirements
This plugin has been tested on a 4.6.1 version of AlienVault OSSIM. For
the full functionality of this plugin, a standalone install of python 2.7 must be
present.
blueliv.sql [4]: SQL script to add the required entries to enable the plugin.
config.cfg [2]: Configuration file to set-up the access to Bluelivs data feeds.
1.3 Installation
2
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
[ alienvault ]
host =
port = 514
3. Edit blueliv.cfg (Listing 3) to set your desired plugin id (defaul 9002) under
section [DEFAULT] property plugin_id.
[DEFAULT]
plugin_id=9002
4. Make sure that the plugin_id on blueliv.cfg is the same as the plugin_id in
blueliv.sql (Listing 4).
Replace your-plugin-ip-here with the IP from where you are going to ex-
ecute your plugin. In order to not over populate this log file, configure
a rotation rule for this file at /etc/logrotate.d/rsyslog by including the file
/var/log/blueliv.log. This will force all logs coming from the specified IP to
write at /var/log/blueliv.log.
7. Execute
> cat blueliv.sql | ossim-db
and
> /etc/init.d/ossim-server restart
9. Execute
> python BluelivAlienVaultPlugin.py -feed FEED_NAME
from where you saved the plugin. Replace FEED_NAME with the feed that
you want to activate (botips, crimeservers or all).
3
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
Go to Sensor Configuration.
Search for blueliv in Plugins available list, add it to Plugins enabled and
apply changes.
4
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
Getting started
2.1 CrimeServer
{
" _id " : "5698945b43fe63f4caa3d2aef42b690
aa6fd3979f905d89f97c5d792fbd4f2b6" ,
" url " : " http : / / 0 rrkut2012 . j e . ro " ,
" type " : "C_AND_C" ,
"subType" : "ZEUS" ,
" country " : "KR" ,
"countryName" : " Republic of Korea" ,
" status " : "ONLINE" ,
"domain" : " je . ro " ,
" host " : "0rrkut2012 . je . ro " ,
" latitude " : 37 . 57 ,
" longitude " : 126 . 98 ,
" ip " : "66.232.140.226" ,
" createdAt " : "20110119T21:34:59+0100" ,
"updatedAt" : "20141125T13:53:25+0100" ,
"asnDesc" : " Enterprise Networks" ,
" firstSeenAt " : "20110119T21:34:59+0100" ,
" lastSeenAt " : "20110119T21:34:59+0100"
}
All this parameters are mapped into a syslog event that will be parsed by a
regexp from the OSSIM. This mapping is described below.
src_ip: CrimeServer IP
5
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
6
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
This data allows you to detect infected hosts inside your networks and ana-
lyze the level of compromise thanks to the context provided such as the Operat-
ing System, BotNet, portal domain, etc.
All this parameters are mapped into a syslog event that will be parsed by a
regexp from the OSSIM. This mapping is described below.
src_ip: Bot IP
dst_ip: BotNet IP
2.3 Events
7
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
8
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
Annexes
9
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
A Files
Plugin code
4 import argparse
5 import u r l l i b
6 import sys
7 import json
8 import ConfigParser
9 import socket
10 import datetime
11 import logging
12 import logging . handlers
13 import time
14 import threading
15 from BotIps import BotIps
16 from CrimeServers import CrimeServers
17 from l i b . dateutil import parser
18 from SyslogConverter import SyslogConverter
19
20 class AlienVaultPlugin ( ) :
21
24 def _ _ i n i t _ _ ( self ) :
25 #LOGGER
26 self . logger = logging . getLogger ( "MainApp" )
27 self . logger . setLevel ( logging .INFO)
28 # Create the logging f i l e handler
29 l o g f i l e = " blueliv . log "
30 fh = logging . handlers . RotatingFileHandler ( l o g f i l e , maxBytes=2097152,
backupCount=5)
31 formatter = logging . Formatter ( %(process )d %(asctime ) s %(name) s %(
levelname ) s %(message) s )
32 fh . setFormatter ( formatter )
33 # Add handler to logger object
34 self . logger . addHandler ( fh )
35 #CONFIG FILE
36 self . config = ConfigParser . SafeConfigParser ( )
37 self . config . read ( config . cfg )
38
10
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
39 try :
40 AlienVaultHost = self . config . get ( alienvault , host )
41 AlienVaultPort = self . config . getint ( alienvault , port )
42 i f AlienVaultHost == :
43 raise
44 except Exception as e :
45 self . logger . error ( " AlienVault Host and Port must be set in b l u e l iv . cfg " )
46 print " AlienVault Host and Port must be set in b l u e l iv . cfg "
47 sys . e x i t ( 1)
48
49 #SYSLOG
50 self . loggerlt = logging . getLogger ( " alienvault " )
51 self . loggerlt . setLevel ( logging .DEBUG)
52 ce = logging . handlers . SysLogHandler ( address=(AlienVaultHost , AlienVaultPort ) )
53 formatter = logging . Formatter ( %(message) s )
54 ce . setFormatter ( formatter )
55 self . loggerlt . addHandler ( ce )
56
57 try :
58 token = self . config . get ( b l u el i v , token )
59 apiHost = self . config . get ( b l u e li v , host )
60 i f token == or apiHost == :
61 raise
62 except Exception as e :
63 self . logger . error ( " Blueliv Host and token must be set in b l u e l iv . cfg " )
64 print " Blueliv Host and token must be set in b l u e l iv . cfg "
65 sys . e x i t ( 1)
66 try :
67 self .__SCHEDULER_TIME_CS_SECONDS = self . config . getint ( crimeservers , t t l )
*60
68 except :
69 self . logger . warning ( "No scheduler configured , using default 15 minutes" )
70 self .__SCHEDULER_TIME_CS_SECONDS = 15*60
71
72 try :
73 self .__SCHEDULER_TIME_BOTIPS_SECONDS = self . config . getint ( botips , t t l )
*60
74 except :
75 self . logger . warning ( "No scheduler configured , using default 10 minutes" )
76 self .__SCHEDULER_TIME_BOTIPS_SECONDS = 10*60
77
78 try :
79 i f self . config . getboolean ( proxy , enable ) is True :
80 i f not self . config . get ( proxy , host ) :
11
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
104 cs_mapping = [
105 url ,
106 type ,
107 ip ,
108 host ,
109 country ,
110 asnDesc ,
111 status ,
112 subType ,
113 firstSeenAt ,
114 lastSeenAt
115 ]
116
117 bots_mapping = [
118 ip ,
119 botnetType ,
120 portalUrl ,
12
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
121 portalDomain ,
122 countryName ,
123 city ,
124 asnDesc ,
125 operatingSystem ,
126 botnetIp ,
127 destinationPort ,
128 botnetUrl ,
129 seenAt ,
130 ]
131
13
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
160 severity = 5
161 try :
162 i f "seenAt" not in apiDict :
163 apiDict [ "seenAt" ] = apiDict [ " createdAt " ]
164 event = self . bots_converter . convert ( apiDict , botips , severity )
165 except Exception , err :
166 self . logger . error ( " Impossible to translate info : {0}" . format( err ) )
167 event = None
168
14
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
211 try :
212 for crimeserver in crimeservers :
213 event = self . __cs_to_event ( crimeserver )
214 i f event :
215 self . loggerlt . info ( event )
216 except Exception as msg:
217 self . logger . error ( " Error : {}" . format(msg) )
218 print " Error pushing data to AlienVault : {}" . format(msg)
219 raise Exception
220 finally :
221 crimeservers = None
222 except Exception , err :
223 self . logger . error ( " Error while pushing data : {0}" . format( err ) )
224 else :
225 self . logger . info ( "Saving l a s t updated At : {}" . format( updatedAt ) )
226 self . setLastExecutionDate ( " crimeservers " , updatedAt = updatedAt )
227 finally :
228 print " Waiting for more updates crimeservers "
229 time . sleep ( self .__SCHEDULER_TIME_CS_SECONDS)
230
231
232
15
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
264 bots . j o i n ( )
265 crimeservers . j o i n ( )
266
267 else :
268 sys . e x i t ( "Not a valid feed . Choose between botips or crimeservers by feed
botips or feed crimeservers " )
Plugin Configuration
1 [ proxy ]
2 enable = False
3 host =
4 user =
5 password =
6 port =
7
8 [ b l u el i v ]
9 token =
10 host = https : / / api . blueliv .com
11
12 [ crimeservers ]
13 updatedat =
14 t t l = 15
15 nupdates = 96
16
17 [ botips ]
16
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
18 updatedat =
19 t t l = 10
20 nupdates = 6
21
22 [ alienvault ]
23 host =
24 port = 514
9 [DEFAULT]
10 plugin_id=9002
11
12 [ config ]
13 type=detector
14 enable=yes
15
16 source=log
17 location=/var / log / blueliv . log
18 c r e a t e _ f i l e=yes
19
20 process=
21 s t a r t=no
22 stop=no
23 startup=
24 shutdown=
25
26 [ translation ]
27 C_AND_C=1
28 EXPLOIT_KIT=2
29 BACKDOOR=3
30 MALWARE=4
31 PHISHING=5
32 DEFAULT_=9999
33
17
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
34
18
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
Restricted access document
19
Blueliv is a registered trademark of Leap In Value S.L., all rights reserved
IMPROVE YOUR CYBER THREAT VISIBILITY
[email protected] www.blueliv.com