mirror of https://github.com/desaster/kippo.git
Allow sensor name to be configured in kippo.cfg
git-svn-id: https://kippo.googlecode.com/svn/trunk@119 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
parent
1b757c8f64
commit
4c19790e43
|
@ -10,6 +10,7 @@ filesystem_file = fs.pickle
|
|||
public_key = public.key
|
||||
private_key = private.key
|
||||
password = 123456
|
||||
;sensor_name=myhostname
|
||||
|
||||
;[database]
|
||||
;engine = mysql
|
||||
|
|
|
@ -26,13 +26,14 @@ class DBLogger(object):
|
|||
)]
|
||||
self.start(cfg)
|
||||
|
||||
if cfg.has_option('honeypot', 'sensor_name'):
|
||||
self.sensor = cfg.get('honeypot', 'sensor_name')
|
||||
else:
|
||||
self.sensor = socket.gethostbyaddr(socket.gethostname())[2][0]
|
||||
|
||||
def start():
|
||||
pass
|
||||
|
||||
def sensorName(self):
|
||||
# TODO: configurable sensor name
|
||||
return socket.gethostbyaddr(socket.gethostname())[2][0]
|
||||
|
||||
def nowUnix(self):
|
||||
"""return the current UTC time as an UNIX timestamp"""
|
||||
return int(time.mktime(datetime.datetime.utcnow().utctimetuple()))
|
||||
|
|
|
@ -13,7 +13,7 @@ class DBLogger(dblog.DBLogger):
|
|||
def createSession(self, ip):
|
||||
sql = 'INSERT INTO `session` (`starttime`, `sensor`, `ip`)' + \
|
||||
' VALUES (FROM_UNIXTIME(%s), %s, %s)'
|
||||
params = (self.nowUnix(), self.sensorName(), ip)
|
||||
params = (self.nowUnix(), self.sensor, ip)
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute(sql, params)
|
||||
return int(cursor.lastrowid)
|
||||
|
|
Loading…
Reference in New Issue