Merge branch 'master' into output-plugin

This commit is contained in:
Michel Oosterhof 2015-03-10 09:22:12 +00:00
commit 85b3f0dcbf
5 changed files with 22 additions and 17 deletions

View File

@ -124,7 +124,8 @@ class HoneypotPublicKeyChecker:
def requestAvatarId(self, credentials):
_pubKey = keys.Key.fromString(credentials.blob)
log.msg( 'Public Key attempt for user %s with fingerprint %s' % ( credentials.username, _pubKey.fingerprint() ) )
log.msg(format='public key attempt for user %(username)s with fingerprint %(fingerprint)%s',
username=credentials.username, fingerprint=_pubKey.fingerprint())
return failure.Failure(error.ConchError("Incorrect signature"))
@implementer(ICredentialsChecker)

View File

@ -45,6 +45,7 @@ class DBLogger(object):
'KIPP0009': self.handleClientVersion,
'KIPP0010': self.handleTerminalSize,
'KIPP0011': self._connectionLost,
'KIPP0012': self.handleTTYLogClosed,
}
self.start(cfg)
@ -126,9 +127,13 @@ class DBLogger(object):
def createSession(self, peerIP, peerPort, hostIP, hostPort):
return 0
# args has: logfile
# args has: ttylog
def handleTTYLogOpened(self, session, args):
self.ttylogs[session] = args['logfile']
self.ttylogs[session] = args['ttylog']
# args has: ttylog
def handleTTYLogClosed(self, session, args):
self.ttylogs[session] = args['ttylog']
# args is empty
def handleConnectionLost(self, session, args):

View File

@ -35,8 +35,6 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol):
transport.factory.logDispatch(*msg,**args)
def connectionMade(self):
self.displayMOTD()
transport = self.terminal.transport.session.conn.transport
self.realClientIP = transport.transport.getPeer().host
@ -60,12 +58,6 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol):
self.kippoIP = s.getsockname()[0]
s.close()
def displayMOTD(self):
try:
self.writeln(self.fs.file_contents('/etc/motd'))
except:
pass
# this is only called on explicit logout, not on disconnect
def connectionLost(self, reason):
log.msg( eventid='KIPP0011', format='Connection lost')
@ -155,6 +147,7 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
HoneyPotBaseProtocol.__init__(self, avatar, env)
def connectionMade(self):
self.displayMOTD()
HoneyPotBaseProtocol.connectionMade(self)
recvline.HistoricRecvLine.connectionMade(self)
@ -177,6 +170,12 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
'\x15': self.handle_CTRL_U, # CTRL-U
})
def displayMOTD(self):
try:
self.writeln(self.fs.file_contents('/etc/motd'))
except:
pass
# this doesn't seem to be called upon disconnect, so please use
# HoneyPotTransport.connectionLost instead
def connectionLost(self, reason):
@ -239,8 +238,8 @@ class LoggingServerProtocol(insults.ServerProtocol):
time.strftime('%Y%m%d-%H%M%S'), transport.transportId )
self.ttylog_file = transport.ttylog_file
log.msg( eventid='KIPP0004', logfile=transport.ttylog_file,
format='Opening TTY Log: %(logfile)s')
log.msg( eventid='KIPP0004', ttylog=transport.ttylog_file,
format='Opening TTY Log: %(ttylog)s')
ttylog.ttylog_open(transport.ttylog_file, time.time())
self.ttylog_open = True

View File

@ -178,7 +178,7 @@ class HoneyPotRealm:
return interfaces[0], \
HoneyPotAvatar(avatarId, self.env), lambda: None
else:
raise Exception, "No supported interfaces found."
raise Exception("No supported interfaces found.")
class HoneyPotTransport(sshserver.KippoSSHServerTransport):
"""
@ -330,8 +330,8 @@ class HoneyPotAvatar(avatar.ConchUser):
cfg.get('honeypot', 'exec_enabled').lower() not in \
('yes', 'true', 'on'):
log.msg( 'Exec disabled. Not executing command: "%s"' % cmd )
raise exceptions.NotEnabledException, \
'exec_enabled not enabled in configuration file!'
raise exceptions.NotEnabledException(
'exec_enabled not enabled in configuration file!')
return
log.msg( 'exec command: "%s"' % cmd )

View File

@ -20,7 +20,7 @@ class ReconnectingConnectionPool(adbapi.ConnectionPool):
try:
return adbapi.ConnectionPool._runInteraction(
self, interaction, *args, **kw)
except MySQLdb.OperationalError, e:
except MySQLdb.OperationalError as e:
if e[0] not in (2006, 2013):
raise
log.msg("RCP: got error %s, retrying operation" %(e))