diff --git a/kippo/core/auth.py b/kippo/core/auth.py index f0f2fde..49bda77 100644 --- a/kippo/core/auth.py +++ b/kippo/core/auth.py @@ -72,7 +72,7 @@ class UserDB(object): f.write('%s:%d:%s\n' % (login, uid, passwd)) f.close() - def checklogin(self, thelogin, thepasswd, src_ip = '0.0.0.0'): + def checklogin(self, thelogin, thepasswd, src_ip='0.0.0.0'): """ check entered username/password against database note that it allows multiple passwords for a single username diff --git a/kippo/core/dblog.py b/kippo/core/dblog.py index acec69e..9d28f5e 100644 --- a/kippo/core/dblog.py +++ b/kippo/core/dblog.py @@ -84,7 +84,7 @@ class DBLogger(object): sessionno = ev['sessionno'] self.sessions[sessionno] = \ self.createSession( - ev['src_ip'], ev['src_port'], ev['dst_ip'], ev['dst_port'] ) + ev['src_ip'], ev['src_port'], ev['dst_ip'], ev['dst_port']) return # use explicit sessionno if coming from dispatch @@ -103,7 +103,7 @@ class DBLogger(object): if 'eventid' in ev: if ev['eventid'] in self.events: - self.events[ev['eventid']]( self.sessions[sessionno], ev ) + self.events[ev['eventid']](self.sessions[sessionno], ev) return pass diff --git a/kippo/core/fs.py b/kippo/core/fs.py index 2484b6e..b879488 100644 --- a/kippo/core/fs.py +++ b/kippo/core/fs.py @@ -116,7 +116,7 @@ class HoneyPotFilesystem(object): if not f[A_REALFILE] and os.path.exists(realfile) and \ not os.path.islink(realfile) and os.path.isfile(realfile) and \ f[A_SIZE] < 25000000: - #log.msg( 'Updating realfile to %s' % realfile ) + #log.msg('Updating realfile to %s' % realfile) f[A_REALFILE] = realfile def realfile(self, f, path): @@ -140,11 +140,11 @@ class HoneyPotFilesystem(object): if x[A_NAME] == piece][0] return p - def file_contents(self, target, count = 0): + def file_contents(self, target, count=0): if count > 10: raise TooManyLevels path = self.resolve_path(target, os.path.dirname(target)) - #log.msg( '%s resolved into %s' % (target, path) ) + #log.msg('%s resolved into %s' % (target, path)) if not path or not self.exists(path): raise FileNotFound f = self.getfile(path) @@ -156,7 +156,7 @@ class HoneyPotFilesystem(object): if realfile: return file(realfile, 'rb').read() - def mkfile(self, path, uid, gid, size, mode, ctime = None): + def mkfile(self, path, uid, gid, size, mode, ctime=None): if self.newcount > 10000: return False if ctime is None: @@ -170,7 +170,7 @@ class HoneyPotFilesystem(object): self.newcount += 1 return True - def mkdir(self, path, uid, gid, size, mode, ctime = None): + def mkdir(self, path, uid, gid, size, mode, ctime=None): if self.newcount > 10000: return False if ctime is None: @@ -205,31 +205,31 @@ class HoneyPotFilesystem(object): # additions for SFTP support, try to keep functions here similar to os.* def open(self, filename, openFlags, mode): - #log.msg( "fs.open %s" % filename ) + #log.msg("fs.open %s" % filename) #if (openFlags & os.O_APPEND == os.O_APPEND): - # log.msg( "fs.open append" ) + # log.msg("fs.open append") #if (openFlags & os.O_CREAT == os.O_CREAT): - # log.msg( "fs.open creat" ) + # log.msg("fs.open creat") #if (openFlags & os.O_TRUNC == os.O_TRUNC): - # log.msg( "fs.open trunc" ) + # log.msg("fs.open trunc") #if (openFlags & os.O_EXCL == os.O_EXCL): - # log.msg( "fs.open excl" ) + # log.msg("fs.open excl") # treat O_RDWR same as O_WRONLY if openFlags & os.O_WRONLY == os.O_WRONLY or openFlags & os.O_RDWR == os.O_RDWR: # ensure we do not save with executable bit set realmode = mode & ~(stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) - #log.msg( "fs.open wronly" ) + #log.msg("fs.open wronly") tempfile = '%s/%s_%s' % \ (config().get('honeypot', 'download_path'), time.strftime('%Y%m%d%H%M%S'), re.sub('[^A-Za-z0-9]', '_', filename)) - #log.msg( "fs.open file for writing, saving to %s" % safeoutfile ) + #log.msg("fs.open file for writing, saving to %s" % safeoutfile) self.mkfile(filename, 0, 0, 0, stat.S_IFREG | mode) fd = os.open(tempfile, openFlags, realmode) @@ -262,7 +262,7 @@ class HoneyPotFilesystem(object): else: os.rename(self.tempfiles[fd], shasumfile) os.symlink(shasum, self.tempfiles[fd]) - self.update_realfile( self.getfile(self.filenames[fd]), shasumfile ) + self.update_realfile(self.getfile(self.filenames[fd]), shasumfile) del self.tempfiles[fd] del self.filenames[fd] return os.close(fd) @@ -322,7 +322,7 @@ class HoneyPotFilesystem(object): raise notImplementedError def rename(self, oldpath, newpath): - #log.msg( "rename %s to %s" % (oldpath, newpath) ) + #log.msg("rename %s to %s" % (oldpath, newpath)) old = self.getfile(oldpath) if old == False: raise OSError(errno.ENOENT, os.strerror(errno.ENOENT)) @@ -342,7 +342,7 @@ class HoneyPotFilesystem(object): def lstat(self, path): # need to treat / as exception if (path == "/"): - p = { A_TYPE:T_DIR, A_UID:0, A_GID:0, A_SIZE:4096, A_MODE:16877, A_CTIME:time.time() } + p = {A_TYPE:T_DIR, A_UID:0, A_GID:0, A_SIZE:4096, A_MODE:16877, A_CTIME:time.time()} else: p = self.getfile(path) @@ -363,7 +363,7 @@ class HoneyPotFilesystem(object): def stat(self, path): if (path == "/"): - p = { A_TYPE:T_DIR, A_UID:0, A_GID:0, A_SIZE:4096, A_MODE:16877, A_CTIME:time.time() } + p = {A_TYPE:T_DIR, A_UID:0, A_GID:0, A_SIZE:4096, A_MODE:16877, A_CTIME:time.time()} else: p = self.getfile(path) diff --git a/kippo/core/honeypot.py b/kippo/core/honeypot.py index 8a74175..a521d8a 100644 --- a/kippo/core/honeypot.py +++ b/kippo/core/honeypot.py @@ -36,12 +36,12 @@ class HoneyPotCommand(object): self.honeypot.cmdstack[-1].resume() def ctrl_c(self): - log.msg( 'Received CTRL-C, exiting..' ) + log.msg('Received CTRL-C, exiting..') self.writeln('^C') self.exit() def lineReceived(self, line): - log.msg( 'INPUT: %s' % line ) + log.msg('INPUT: %s' % line) def resume(self): pass @@ -50,7 +50,7 @@ class HoneyPotCommand(object): pass class HoneyPotShell(object): - def __init__(self, protocol, interactive = True): + def __init__(self, protocol, interactive=True): self.honeypot = protocol self.interactive = interactive self.showPrompt() @@ -60,10 +60,10 @@ class HoneyPotShell(object): } def lineReceived(self, line): - log.msg( 'CMD: %s' % line ) + log.msg('CMD: %s' % line) line = line[:500] - comment = re.compile( '^\s*#' ) - for i in [x.strip() for x in re.split(';|&&|\n',line.strip())[:10]]: + comment = re.compile('^\s*#') + for i in [x.strip() for x in re.split(';|&&|\n', line.strip())[:10]]: if not len(i): continue if comment.match(i): @@ -129,12 +129,12 @@ class HoneyPotShell(object): rargs.append(arg) cmdclass = self.honeypot.getCommand(cmd, envvars['PATH'].split(':')) if cmdclass: - log.msg( eventid='KIPP0005', input=line, format='Command found: %(input)s' ) + log.msg(eventid='KIPP0005', input=line, format='Command found: %(input)s') #self.honeypot.logDispatch('Command found: %s' % (line,)) self.honeypot.call_command(cmdclass, *rargs) else: - log.msg( eventid='KIPP0006', - input=line, format='Command not found: %(input)s' ) + log.msg(eventid='KIPP0006', + input=line, format='Command not found: %(input)s') #self.honeypot.logDispatch('Command not found: %s' % (line,)) if len(line): self.honeypot.writeln('bash: %s: command not found' % cmd) diff --git a/kippo/core/interact.py b/kippo/core/interact.py index fb8804b..61c2ea7 100644 --- a/kippo/core/interact.py +++ b/kippo/core/interact.py @@ -120,7 +120,7 @@ class Interact(telnet.Telnet): session.realClientIP.ljust(15), session.clientVersion)) - def cmd_help(self, args = ''): + def cmd_help(self, args=''): self.transport.write('List of commands:\r\n') self.transport.write(' list - list all active sessions\r\n') self.transport.write( @@ -146,7 +146,7 @@ class Interact(telnet.Telnet): return self.transport.write('** No such session found.\r\n') - def cmd_exit(self, args = ''): + def cmd_exit(self, args=''): self.transport.loseConnection() def makeInteractFactory(honeypotFactory): diff --git a/kippo/core/protocol.py b/kippo/core/protocol.py index 894dba4..d3cd60e 100644 --- a/kippo/core/protocol.py +++ b/kippo/core/protocol.py @@ -32,8 +32,8 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol): def logDispatch(self, *msg, **args): transport = self.terminal.transport.session.conn.transport - args['sessionno']=transport.transport.sessionno - transport.factory.logDispatch(*msg,**args) + args['sessionno'] = transport.transport.sessionno + transport.factory.logDispatch(*msg, **args) def connectionMade(self): transport = self.terminal.transport.session.conn.transport @@ -71,7 +71,7 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol): def txtcmd(self, txt): class command_txtcmd(honeypot.HoneyPotCommand): def call(self): - log.msg( 'Reading txtcmd from "%s"' % txt ) + log.msg('Reading txtcmd from "%s"' % txt) f = file(txt, 'r') self.write(f.read()) f.close() @@ -122,7 +122,7 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol): transport = self.terminal.transport.session.conn.transport transport.interactors.remove(interactor) - def uptime(self, reset = None): + def uptime(self, reset=None): transport = self.terminal.transport.session.conn.transport r = time.time() - transport.factory.starttime if reset: @@ -247,10 +247,10 @@ class LoggingServerProtocol(insults.ServerProtocol): transport = self.transport.session.conn.transport transport.ttylog_file = '%s/tty/%s-%s.log' % \ (config().get('honeypot', 'log_path'), - time.strftime('%Y%m%d-%H%M%S'), transport.transportId ) + time.strftime('%Y%m%d-%H%M%S'), transport.transportId) self.ttylog_file = transport.ttylog_file - log.msg( eventid='KIPP0004', ttylog=transport.ttylog_file, + log.msg(eventid='KIPP0004', ttylog=transport.ttylog_file, format='Opening TTY Log: %(ttylog)s') ttylog.ttylog_open(transport.ttylog_file, time.time()) @@ -258,12 +258,12 @@ class LoggingServerProtocol(insults.ServerProtocol): self.stdinlog_file = '%s/%s-%s-stdin.log' % \ (config().get('honeypot', 'download_path'), - time.strftime('%Y%m%d-%H%M%S'), transport.transportId ) + time.strftime('%Y%m%d-%H%M%S'), transport.transportId) self.stdinlog_open = False insults.ServerProtocol.connectionMade(self) - def write(self, bytes, noLog = False): + def write(self, bytes, noLog=False): transport = self.transport.session.conn.transport for i in transport.interactors: i.sessionWrite(bytes) @@ -273,14 +273,14 @@ class LoggingServerProtocol(insults.ServerProtocol): insults.ServerProtocol.write(self, bytes) - def dataReceived(self, data, noLog = False): + def dataReceived(self, data, noLog=False): transport = self.transport.session.conn.transport if self.ttylog_open and not noLog: ttylog.ttylog_write(transport.ttylog_file, len(data), ttylog.TYPE_INPUT, time.time(), data) if self.stdinlog_open and not noLog: - log.msg( "Saving stdin log: %s" % self.stdinlog_file ) - f = file( self.stdinlog_file, 'ab' ) + log.msg("Saving stdin log: %s" % self.stdinlog_file) + f = file(self.stdinlog_file, 'ab') f.write(data) f.close @@ -293,10 +293,10 @@ class LoggingServerProtocol(insults.ServerProtocol): # FIXME: this method is called 4 times on logout.... # it's called once from Avatar.closed() if disconnected def connectionLost(self, reason): - # log.msg( "received call to LSP.connectionLost" ) + # log.msg("received call to LSP.connectionLost") transport = self.transport.session.conn.transport if self.ttylog_open: - log.msg( eventid='KIPP0012', format='Closing TTY Log: %(ttylog)s', + log.msg(eventid='KIPP0012', format='Closing TTY Log: %(ttylog)s', ttylog=transport.ttylog_file) ttylog.ttylog_close(transport.ttylog_file, time.time()) self.ttylog_open = False diff --git a/kippo/core/ssh.py b/kippo/core/ssh.py index 39dbda2..287887f 100644 --- a/kippo/core/ssh.py +++ b/kippo/core/ssh.py @@ -44,7 +44,7 @@ class HoneyPotSSHUserAuthServer(userauth.SSHUserAuthServer): try: honeyfs = cfg.get('honeypot', 'contents_path') issuefile = honeyfs + "/etc/issue.net" - data = file( issuefile ).read() + data = file(issuefile).read() except IOError: return if not data or not len(data.strip()): @@ -113,7 +113,7 @@ class HoneyPotSSHFactory(factory.SSHFactory): lcfg.add_section('honeypot') for i in cfg.options('honeypot'): lcfg.set('honeypot', i, cfg.get('honeypot', i)) - log.msg( 'Loading dblog engine: %s' % (engine,) ) + log.msg('Loading dblog engine: %s' % (engine,)) dblogger = __import__( 'kippo.dblog.%s' % (engine,), globals(), locals(), ['dblog']).DBLogger(lcfg) @@ -134,7 +134,7 @@ class HoneyPotSSHFactory(factory.SSHFactory): lcfg.add_section('honeypot') for i in cfg.options('honeypot'): lcfg.set('honeypot', i, cfg.get('honeypot', i)) - log.msg( 'Loading output engine: %s' % (engine,) ) + log.msg('Loading output engine: %s' % (engine,)) output = __import__( 'kippo.output.%s' % (engine,), globals(), locals(), ['output']).Output(lcfg) @@ -159,27 +159,27 @@ class HoneyPotSSHFactory(factory.SSHFactory): t = HoneyPotTransport() if cfg.has_option('honeypot', 'ssh_version_string'): - t.ourVersionString = cfg.get('honeypot','ssh_version_string') + t.ourVersionString = cfg.get('honeypot', 'ssh_version_string') else: t.ourVersionString = "SSH-2.0-OpenSSH_5.1p1 Debian-5" t.supportedPublicKeys = self.privateKeys.keys() try: - self.primes = primes.parseModuliFile( _moduli ) + self.primes = primes.parseModuliFile(moduli) except IOError as err: - log.err( err ) + log.err(err) if not self.primes: - log.msg( "Disabling diffie-hellman-group-exchange-sha1" ) + log.msg("Disabling diffie-hellman-group-exchange-sha1") ske = t.supportedKeyExchanges[:] ske.remove('diffie-hellman-group-exchange-sha1') t.supportedKeyExchanges = ske # reorder supported ciphers to resemble current openssh more - t.supportedCiphers = ['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc' ] + t.supportedCiphers = ['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc'] t.supportedPublicKeys = ['ssh-rsa', 'ssh-dss'] - t.supportedMACs = [ 'hmac-md5', 'hmac-sha1'] + t.supportedMACs = ['hmac-md5', 'hmac-sha1'] t.factory = self return t @@ -206,11 +206,11 @@ class HoneyPotTransport(sshserver.KippoSSHServerTransport): self.transportId = uuid.uuid4().hex[:8] self.interactors = [] - log.msg( eventid='KIPP0001', + log.msg(eventid='KIPP0001', format='New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(sessionno)s]', src_ip=self.transport.getPeer().host, src_port=self.transport.getPeer().port, dst_ip=self.transport.getHost().host, dst_port=self.transport.getHost().port, - sessionno=self.transport.sessionno ) + sessionno=self.transport.sessionno) sshserver.KippoSSHServerTransport.connectionMade(self) @@ -232,16 +232,16 @@ class HoneyPotTransport(sshserver.KippoSSHServerTransport): k = getNS(packet[16:], 10) strings, rest = k[:-1], k[-1] (kexAlgs, keyAlgs, encCS, encSC, macCS, macSC, compCS, compSC, langCS, langSC) = [s.split(',') for s in strings] - log.msg('KEXINIT: client supported key exchange: %s' % kexAlgs ) - log.msg('KEXINIT: client supported public keys: %s' % keyAlgs ) - log.msg('KEXINIT: client supported encryption: %s' % encCS ) - log.msg('KEXINIT: client supported MAC: %s' % macCS ) - log.msg('KEXINIT: client supported compression: %s' % compCS ) - log.msg('KEXINIT: client supported lang: %s' % langCS ) + log.msg('KEXINIT: client supported key exchange: %s' % kexAlgs) + log.msg('KEXINIT: client supported public keys: %s' % keyAlgs) + log.msg('KEXINIT: client supported encryption: %s' % encCS) + log.msg('KEXINIT: client supported MAC: %s' % macCS) + log.msg('KEXINIT: client supported compression: %s' % compCS) + log.msg('KEXINIT: client supported lang: %s' % langCS) - log.msg( eventid='KIPP0009', version=self.otherVersionString, + log.msg(eventid='KIPP0009', version=self.otherVersionString, kexAlgs=kexAlgs, keyAlgs=keyAlgs, encCS=encCS, macCS=macCS, - compCS=compCS, format='Remote SSH version: %(version)s' ) + compCS=compCS, format='Remote SSH version: %(version)s') return sshserver.KippoSSHServerTransport.ssh_KEXINIT(self, packet) @@ -252,7 +252,7 @@ class HoneyPotTransport(sshserver.KippoSSHServerTransport): if self.transport.sessionno in self.factory.sessions: del self.factory.sessions[self.transport.sessionno] sshserver.KippoSSHServerTransport.connectionLost(self, reason) - log.msg( eventid='KIPP0011', format='Connection lost') + log.msg(eventid='KIPP0011', format='Connection lost') class HoneyPotSSHSession(session.SSHSession): @@ -265,15 +265,15 @@ class HoneyPotSSHSession(session.SSHSession): value, rest = getNS(rest) if rest: raise ValueError("Bad data given in env request") - log.msg( eventid='KIPP0013', format='request_env: %(name)s=%(value)s', name=name, value=value ) + log.msg(eventid='KIPP0013', format='request_env: %(name)s=%(value)s', name=name, value=value) return 0 def request_agent(self, data): - log.msg('request_agent: %s' % repr(data) ) + log.msg('request_agent: %s' % repr(data)) return 0 def request_x11_req(self, data): - log.msg('request_x11: %s' % repr(data) ) + log.msg('request_x11: %s' % repr(data)) return 0 # this is reliably called on session close/disconnect and calls the avatar @@ -297,7 +297,7 @@ class HoneyPotSSHSession(session.SSHSession): session.SSHSession.loseConnection(self) def channelClosed(self): - log.msg( "Called channelClosed in SSHSession") + log.msg("Called channelClosed in SSHSession") # FIXME: recent twisted conch avatar.py uses IConchuser here @implementer(conchinterfaces.ISession) @@ -316,7 +316,7 @@ class HoneyPotAvatar(avatar.ConchUser): # sftp support enabled only when option is explicitly set if self.env.cfg.has_option('honeypot', 'sftp_enabled'): - if ( self.env.cfg.get('honeypot', 'sftp_enabled') == "true" ): + if (self.env.cfg.get('honeypot', 'sftp_enabled') == "true"): self.subsystemLookup['sftp'] = filetransfer.FileTransferServer self.uid = self.gid = auth.UserDB().getUID(self.username) @@ -335,9 +335,9 @@ class HoneyPotAvatar(avatar.ConchUser): self.protocol = proto def getPty(self, terminal, windowSize, attrs): - #log.msg( 'Terminal size: %s %s' % windowSize[0:2] ) - log.msg( eventid='KIPP0010', width=windowSize[0], height=windowSize[1], - format='Terminal Size: %(width)s %(height)s' ) + #log.msg('Terminal size: %s %s' % windowSize[0:2]) + log.msg(eventid='KIPP0010', width=windowSize[0], height=windowSize[1], + format='Terminal Size: %(width)s %(height)s') self.windowSize = windowSize return None @@ -347,7 +347,7 @@ class HoneyPotAvatar(avatar.ConchUser): if not cfg.has_option('honeypot', 'exec_enabled') or \ cfg.get('honeypot', 'exec_enabled').lower() not in \ ('yes', 'true', 'on'): - log.msg( 'Exec disabled. Not executing command: "%s"' % cmd ) + log.msg('Exec disabled. Not executing command: "%s"' % cmd) raise exceptions.NotEnabledException( 'exec_enabled not enabled in configuration file!') return @@ -376,7 +376,7 @@ def getRSAKeys(): public_key = cfg.get('honeypot', 'rsa_public_key') private_key = cfg.get('honeypot', 'rsa_private_key') if not (os.path.exists(public_key) and os.path.exists(private_key)): - log.msg( "Generating new RSA keypair..." ) + log.msg("Generating new RSA keypair...") from Crypto.PublicKey import RSA from twisted.python import randbytes KEY_LENGTH = 2048 @@ -399,7 +399,7 @@ def getDSAKeys(): public_key = cfg.get('honeypot', 'dsa_public_key') private_key = cfg.get('honeypot', 'dsa_private_key') if not (os.path.exists(public_key) and os.path.exists(private_key)): - log.msg( "Generating new DSA keypair..." ) + log.msg("Generating new DSA keypair...") from Crypto.PublicKey import DSA from twisted.python import randbytes KEY_LENGTH = 1024 @@ -455,7 +455,7 @@ class KippoSFTPFile: self.contents = self.server.fs.file_contents(self.filename) def close(self): - if ( self.bytes_written > 0 ): + if (self.bytes_written > 0): self.server.fs.update_size(self.filename, self.bytes_written) return self.server.fs.close(self.fd) @@ -531,34 +531,34 @@ class KippoSFTPServer: return {} def openFile(self, filename, flags, attrs): - log.msg( "SFTP openFile: %s" % filename ) + log.msg("SFTP openFile: %s" % filename) return KippoSFTPFile(self, self._absPath(filename), flags, attrs) def removeFile(self, filename): - log.msg( "SFTP removeFile: %s" % filename ) + log.msg("SFTP removeFile: %s" % filename) return self.fs.remove(self._absPath(filename)) def renameFile(self, oldpath, newpath): - log.msg( "SFTP renameFile: %s %s" % (oldpath, newpath) ) + log.msg("SFTP renameFile: %s %s" % (oldpath, newpath)) return self.fs.rename(self._absPath(oldpath), self._absPath(newpath)) def makeDirectory(self, path, attrs): - log.msg( "SFTP makeDirectory: %s" % path ) + log.msg("SFTP makeDirectory: %s" % path) path = self._absPath(path) self.fs.mkdir2(path) self._setAttrs(path, attrs) return def removeDirectory(self, path): - log.msg( "SFTP removeDirectory: %s" % path ) + log.msg("SFTP removeDirectory: %s" % path) return self.fs.rmdir(self._absPath(path)) def openDirectory(self, path): - log.msg( "SFTP OpenDirectory: %s" % path ) + log.msg("SFTP OpenDirectory: %s" % path) return KippoSFTPDirectory(self, self._absPath(path)) def getAttrs(self, path, followLinks): - log.msg( "SFTP getAttrs: %s" % path ) + log.msg("SFTP getAttrs: %s" % path) path = self._absPath(path) if followLinks: s = self.fs.stat(path) @@ -567,33 +567,33 @@ class KippoSFTPServer: return self._getAttrs(s) def setAttrs(self, path, attrs): - log.msg( "SFTP setAttrs: %s" % path ) + log.msg("SFTP setAttrs: %s" % path) path = self._absPath(path) return self._setAttrs(path, attrs) def readLink(self, path): - log.msg( "SFTP readLink: %s" % path ) + log.msg("SFTP readLink: %s" % path) path = self._absPath(path) return self.fs.readlink(path) def makeLink(self, linkPath, targetPath): - log.msg( "SFTP makeLink: %s" % path ) + log.msg("SFTP makeLink: %s" % path) linkPath = self._absPath(linkPath) targetPath = self._absPath(targetPath) return self.fs.symlink(targetPath, linkPath) def realPath(self, path): - log.msg( "SFTP realPath: %s" % path ) + log.msg("SFTP realPath: %s" % path) return self.fs.realpath(self._absPath(path)) def extendedRequest(self, extName, extData): raise NotImplementedError -components.registerAdapter( KippoSFTPServer, HoneyPotAvatar, conchinterfaces.ISFTPServer) +components.registerAdapter(KippoSFTPServer, HoneyPotAvatar, conchinterfaces.ISFTPServer) def KippoOpenConnectForwardingClient(remoteWindow, remoteMaxPacket, data, avatar): remoteHP, origHP = twisted.conch.ssh.forwarding.unpackOpen_direct_tcpip(data) - log.msg( "direct-tcp connection attempt to %s:%i" % remoteHP ) + log.msg("direct-tcp connection attempt to %s:%i" % remoteHP) return KippoConnectForwardingChannel(remoteHP, remoteWindow=remoteWindow, remoteMaxPacket=remoteMaxPacket, @@ -602,10 +602,10 @@ def KippoOpenConnectForwardingClient(remoteWindow, remoteMaxPacket, data, avatar class KippoConnectForwardingChannel(forwarding.SSHConnectForwardingChannel): def channelOpen(self, specificData): - log.msg( "Faking channel open %s:%i" % self.hostport ) + log.msg("Faking channel open %s:%i" % self.hostport) def dataReceived(self, data): - log.msg( "received data %s" % repr( data )) + log.msg("received data %s" % repr(data)) # vim: set et sw=4 et: diff --git a/kippo/core/ttylog.py b/kippo/core/ttylog.py index b5fa025..11dddbd 100644 --- a/kippo/core/ttylog.py +++ b/kippo/core/ttylog.py @@ -8,7 +8,7 @@ import struct OP_OPEN, OP_CLOSE, OP_WRITE, OP_EXEC = 1, 2, 3, 4 TYPE_INPUT, TYPE_OUTPUT, TYPE_INTERACT = 1, 2, 3 -def ttylog_write(logfile, len, direction, stamp, data = None): +def ttylog_write(logfile, len, direction, stamp, data=None): f = file(logfile, 'ab') sec, usec = int(stamp), int(1000000 * (stamp - int(stamp))) f.write(struct.pack(' 0: - s += str(days) + " " + (days == 1 and "day" or "days" ) + ", " + s += str(days) + " " + (days == 1 and "day" or "days") + ", " if len(s) > 0 or hours > 0: s += '%s:%s' % (str(hours).rjust(2), str(minutes).rjust(2, '0')) else: