diff --git a/kippo.cfg.dist b/kippo.cfg.dist index 34ee375..a0e5243 100644 --- a/kippo.cfg.dist +++ b/kippo.cfg.dist @@ -10,6 +10,7 @@ filesystem_file = fs.pickle public_key = public.key private_key = private.key password = 123456 +;sensor_name=myhostname ;[database] ;engine = mysql diff --git a/kippo/core/dblog.py b/kippo/core/dblog.py index a3fec4f..d35d32a 100644 --- a/kippo/core/dblog.py +++ b/kippo/core/dblog.py @@ -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())) diff --git a/kippo/dblog/mysql.py b/kippo/dblog/mysql.py index 0eb5e21..b5dae13 100644 --- a/kippo/dblog/mysql.py +++ b/kippo/dblog/mysql.py @@ -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)