use relative style imports instead of absolute paths

This commit is contained in:
Michel Oosterhof
2015-02-19 12:01:07 +00:00
parent dd2ee20a90
commit 687870c45c
6 changed files with 43 additions and 38 deletions

View File

@ -16,7 +16,7 @@ from twisted.python import log, failure
from twisted.conch import error
from twisted.conch.ssh import keys
from kippo.core.config import config
from config import config
# by Walter de Jong <walter@sara.nl>
class UserDB(object):

View File

@ -9,9 +9,10 @@ import copy
import pickle
from twisted.python import log
from kippo.core import fs
from kippo.core.config import config
import kippo.core.exceptions
import fs
import exceptions
from config import config
class HoneyPotCommand(object):
def __init__(self, protocol, *args):

View File

@ -6,7 +6,7 @@ import time
from twisted.internet import protocol
from twisted.conch import telnet, recvline
from kippo.core import ttylog
import ttylog
class Interact(telnet.Telnet):

View File

@ -10,9 +10,9 @@ from twisted.conch import recvline
from twisted.conch.insults import insults
from twisted.python import log
from kippo.core import ttylog
from kippo.core.config import config
from kippo import core
import honeypot
import ttylog
from config import config
class HoneyPotBaseProtocol(insults.TerminalProtocol):
def __init__(self, avatar, env):
@ -77,7 +77,7 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol):
#del self.commands
def txtcmd(self, txt):
class command_txtcmd(core.honeypot.HoneyPotCommand):
class command_txtcmd(honeypot.HoneyPotCommand):
def call(self):
log.msg( 'Reading txtcmd from "%s"' % txt )
f = file(txt, 'r')
@ -147,7 +147,7 @@ class HoneyPotExecProtocol(HoneyPotBaseProtocol):
HoneyPotBaseProtocol.connectionMade(self)
self.terminal.transport.session.conn.transport.stdinlog_open = True
self.cmdstack = [core.honeypot.HoneyPotShell(self, interactive=False)]
self.cmdstack = [honeypot.HoneyPotShell(self, interactive=False)]
self.cmdstack[0].lineReceived(self.execcmd)
class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLine):
@ -160,7 +160,7 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
HoneyPotBaseProtocol.connectionMade(self)
recvline.HistoricRecvLine.connectionMade(self)
self.cmdstack = [core.honeypot.HoneyPotShell(self)]
self.cmdstack = [honeypot.HoneyPotShell(self)]
transport = self.terminal.transport.session.conn.transport
transport.factory.sessions[transport.transport.sessionno] = self

View File

@ -21,13 +21,17 @@ from twisted.conch.ssh.common import NS, getNS
import ConfigParser
from kippo.core import ttylog, utils, fs, sshserver
from kippo.core.config import config
import kippo.core.auth
import kippo.core.honeypot
import kippo.core.ssh
import kippo.core.protocol
from kippo import core
import ttylog
import utils
import fs
import sshserver
import auth
import honeypot
import ssh
import protocol
import sshserver
import exceptions
from config import config
class HoneyPotSSHUserAuthServer(userauth.SSHUserAuthServer):
def serviceStarted(self):
@ -145,7 +149,7 @@ class HoneyPotRealm:
def __init__(self):
# I don't know if i'm supposed to keep static stuff here
self.env = core.honeypot.HoneyPotEnvironment()
self.env = honeypot.HoneyPotEnvironment()
def requestAvatar(self, avatarId, mind, *interfaces):
if conchinterfaces.IConchUser in interfaces:
@ -154,7 +158,7 @@ class HoneyPotRealm:
else:
raise Exception, "No supported interfaces found."
class HoneyPotTransport(kippo.core.sshserver.KippoSSHServerTransport):
class HoneyPotTransport(sshserver.KippoSSHServerTransport):
"""
@ivar logintime: time of login
@ -181,16 +185,16 @@ class HoneyPotTransport(kippo.core.sshserver.KippoSSHServerTransport):
self.transport.getHost().host, self.transport.getHost().port,
self.transport.sessionno) )
kippo.core.sshserver.KippoSSHServerTransport.connectionMade(self)
sshserver.KippoSSHServerTransport.connectionMade(self)
def sendKexInit(self):
# Don't send key exchange prematurely
if not self.gotVersion:
return
kippo.core.sshserver.KippoSSHServerTransport.sendKexInit(self)
sshserver.KippoSSHServerTransport.sendKexInit(self)
def dataReceived(self, data):
kippo.core.sshserver.KippoSSHServerTransport.dataReceived(self, data)
sshserver.KippoSSHServerTransport.dataReceived(self, data)
# later versions seem to call sendKexInit again on their own
if twisted.version.major < 11 and \
not self._hadVersion and self.gotVersion:
@ -208,7 +212,7 @@ class HoneyPotTransport(kippo.core.sshserver.KippoSSHServerTransport):
log.msg('KEXINIT: client supported compression: %s' % compCS )
log.msg('KEXINIT: client supported lang: %s' % langCS )
log.msg( 'Remote SSH version: %s' % self.otherVersionString,)
return kippo.core.sshserver.KippoSSHServerTransport.ssh_KEXINIT(self, packet)
return sshserver.KippoSSHServerTransport.ssh_KEXINIT(self, packet)
def lastlogExit(self):
starttime = time.strftime('%a %b %d %H:%M',
@ -230,7 +234,7 @@ class HoneyPotTransport(kippo.core.sshserver.KippoSSHServerTransport):
if self.ttylog_open:
ttylog.ttylog_close(self.ttylog_file, time.time())
self.ttylog_open = False
kippo.core.sshserver.KippoSSHServerTransport.connectionLost(self, reason)
sshserver.KippoSSHServerTransport.connectionLost(self, reason)
class HoneyPotSSHSession(session.SSHSession):
@ -277,38 +281,38 @@ class HoneyPotAvatar(avatar.ConchUser):
if ( self.env.cfg.get('honeypot', 'sftp_enabled') == "true" ):
self.subsystemLookup['sftp'] = filetransfer.FileTransferServer
self.uid = self.gid = core.auth.UserDB().getUID(self.username)
self.uid = self.gid = auth.UserDB().getUID(self.username)
if not self.uid:
self.home = '/root'
else:
self.home = '/home/' + username
def openShell(self, protocol):
serverProtocol = core.protocol.LoggingServerProtocol(
core.protocol.HoneyPotInteractiveProtocol, self, self.env)
serverProtocol.makeConnection(protocol)
protocol.makeConnection(session.wrapProtocol(serverProtocol))
def openShell(self, proto):
serverProtocol = protocol.LoggingServerProtocol(
protocol.HoneyPotInteractiveProtocol, self, self.env)
serverProtocol.makeConnection(proto)
proto.makeConnection(session.wrapProtocol(serverProtocol))
def getPty(self, terminal, windowSize, attrs):
log.msg( 'Terminal size: %s %s' % windowSize[0:2] )
self.windowSize = windowSize
return None
def execCommand(self, protocol, cmd):
def execCommand(self, proto, cmd):
cfg = config()
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 )
raise core.exceptions.NotEnabledException, \
raise exceptions.NotEnabledException, \
'exec_enabled not enabled in configuration file!'
return
log.msg( 'exec command: "%s"' % cmd )
serverProtocol = kippo.core.protocol.LoggingServerProtocol(
kippo.core.protocol.HoneyPotExecProtocol, self, self.env, cmd)
serverProtocol.makeConnection(protocol)
protocol.makeConnection(session.wrapProtocol(serverProtocol))
serverProtocol = protocol.LoggingServerProtocol(
protocol.HoneyPotExecProtocol, self, self.env, cmd)
serverProtocol.makeConnection(proto)
proto.makeConnection(session.wrapProtocol(serverProtocol))
def closed(self):
pass

View File

@ -1,7 +1,7 @@
# Copyright (c) 2010-2014 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information
from kippo.core.config import config
from config import config
def addToLastlog(message):
f = file('%s/lastlog.txt' % config().get('honeypot', 'data_path'), 'a')