mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-25 09:54:24 +01:00
move factory initialization to startFactory instead of __init__
This commit is contained in:
@@ -88,9 +88,10 @@ class HoneyPotSSHFactory(factory.SSHFactory):
|
||||
output.logDispatch(*msg, **args)
|
||||
|
||||
def __init__(self, cfg):
|
||||
|
||||
self.cfg = cfg
|
||||
|
||||
def startFactory(self):
|
||||
|
||||
# protocol^Wwhatever instances are kept here for the interact feature
|
||||
self.sessions = {}
|
||||
|
||||
@@ -107,18 +108,18 @@ class HoneyPotSSHFactory(factory.SSHFactory):
|
||||
|
||||
# load db loggers
|
||||
self.dbloggers = []
|
||||
for x in cfg.sections():
|
||||
for x in self.cfg.sections():
|
||||
if not x.startswith('database_'):
|
||||
continue
|
||||
engine = x.split('_')[1]
|
||||
dbengine = 'database_' + engine
|
||||
lcfg = ConfigParser.ConfigParser()
|
||||
lcfg.add_section(dbengine)
|
||||
for i in cfg.options(x):
|
||||
lcfg.set(dbengine, i, cfg.get(x, i))
|
||||
for i in self.cfg.options(x):
|
||||
lcfg.set(dbengine, i, self.cfg.get(x, i))
|
||||
lcfg.add_section('honeypot')
|
||||
for i in cfg.options('honeypot'):
|
||||
lcfg.set('honeypot', i, cfg.get('honeypot', i))
|
||||
for i in self.cfg.options('honeypot'):
|
||||
lcfg.set('honeypot', i, self.cfg.get('honeypot', i))
|
||||
log.msg('Loading dblog engine: %s' % (engine,))
|
||||
dblogger = __import__(
|
||||
'cowrie.dblog.%s' % (engine,),
|
||||
@@ -128,18 +129,18 @@ class HoneyPotSSHFactory(factory.SSHFactory):
|
||||
|
||||
# load new output modules
|
||||
self.output_plugins = [];
|
||||
for x in cfg.sections():
|
||||
for x in self.cfg.sections():
|
||||
if not x.startswith('output_'):
|
||||
continue
|
||||
engine = x.split('_')[1]
|
||||
output = 'output_' + engine
|
||||
lcfg = ConfigParser.ConfigParser()
|
||||
lcfg.add_section(output)
|
||||
for i in cfg.options(x):
|
||||
lcfg.set(output, i, cfg.get(x, i))
|
||||
for i in self.cfg.options(x):
|
||||
lcfg.set(output, i, self.cfg.get(x, i))
|
||||
lcfg.add_section('honeypot')
|
||||
for i in cfg.options('honeypot'):
|
||||
lcfg.set('honeypot', i, cfg.get('honeypot', i))
|
||||
for i in self.cfg.options('honeypot'):
|
||||
lcfg.set('honeypot', i, self.cfg.get('honeypot', i))
|
||||
log.msg('Loading output engine: %s' % (engine,))
|
||||
output = __import__(
|
||||
'cowrie.output.%s' % (engine,)
|
||||
@@ -147,6 +148,8 @@ class HoneyPotSSHFactory(factory.SSHFactory):
|
||||
log.addObserver(output.emit)
|
||||
self.output_plugins.append(output)
|
||||
|
||||
factory.SSHFactory.startFactory(self)
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
"""
|
||||
Create an instance of the server side of the SSH protocol.
|
||||
|
||||
Reference in New Issue
Block a user