mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
move fscopy out of sftp/protocol into avatar. rename user to avatar
This commit is contained in:
@ -2,10 +2,10 @@
|
||||
# See the COPYRIGHT file for more information
|
||||
|
||||
import twisted
|
||||
from copy import deepcopy, copy
|
||||
import os
|
||||
import shlex
|
||||
import re
|
||||
import copy.copy
|
||||
|
||||
from twisted.python import log
|
||||
from kippo.core import fs
|
||||
@ -97,7 +97,7 @@ class HoneyPotShell(object):
|
||||
return
|
||||
|
||||
# probably no reason to be this comprehensive for just PATH...
|
||||
envvars = copy(self.envvars)
|
||||
envvars = copy.copy(self.envvars)
|
||||
cmd = None
|
||||
while len(cmdAndArgs):
|
||||
piece = cmdAndArgs.pop(0)
|
||||
|
@ -5,13 +5,13 @@ import os
|
||||
import random
|
||||
import time
|
||||
import struct
|
||||
import copy.copy
|
||||
|
||||
from twisted.conch import recvline
|
||||
from twisted.conch.ssh import transport
|
||||
from twisted.conch.insults import insults
|
||||
from twisted.internet import protocol
|
||||
from twisted.python import log
|
||||
from copy import deepcopy, copy
|
||||
|
||||
from kippo.core import ttylog, fs
|
||||
from kippo.core.config import config
|
||||
@ -20,13 +20,13 @@ import kippo.core.honeypot
|
||||
from kippo import core
|
||||
|
||||
class HoneyPotBaseProtocol(insults.TerminalProtocol):
|
||||
def __init__(self, user, env):
|
||||
self.user = user
|
||||
def __init__(self, avatar, env):
|
||||
self.user = avatar
|
||||
self.env = env
|
||||
self.hostname = self.env.cfg.get('honeypot', 'hostname')
|
||||
self.fs = fs.HoneyPotFilesystem(deepcopy(self.env.fs))
|
||||
if self.fs.exists(user.home):
|
||||
self.cwd = user.home
|
||||
self.fs = avatar.fs
|
||||
if self.fs.exists(avatar.home):
|
||||
self.cwd = avatar.home
|
||||
else:
|
||||
self.cwd = '/'
|
||||
# commands is also a copy so we can add stuff on the fly
|
||||
@ -134,9 +134,9 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol):
|
||||
|
||||
class HoneyPotExecProtocol(HoneyPotBaseProtocol):
|
||||
|
||||
def __init__(self, user, env, execcmd):
|
||||
def __init__(self, avatar, env, execcmd):
|
||||
self.execcmd = execcmd
|
||||
HoneyPotBaseProtocol.__init__(self, user, env)
|
||||
HoneyPotBaseProtocol.__init__(self, avatar, env)
|
||||
|
||||
def connectionMade(self):
|
||||
HoneyPotBaseProtocol.connectionMade(self)
|
||||
@ -153,9 +153,9 @@ class HoneyPotExecProtocol(HoneyPotBaseProtocol):
|
||||
|
||||
class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLine):
|
||||
|
||||
def __init__(self, user, env):
|
||||
def __init__(self, avatar, env):
|
||||
recvline.HistoricRecvLine.__init__(self)
|
||||
HoneyPotBaseProtocol.__init__(self, user, env)
|
||||
HoneyPotBaseProtocol.__init__(self, avatar, env)
|
||||
|
||||
def connectionMade(self):
|
||||
HoneyPotBaseProtocol.connectionMade(self)
|
||||
|
@ -5,6 +5,7 @@ import os
|
||||
import copy
|
||||
import time
|
||||
import uuid
|
||||
import copy.deepcopy
|
||||
|
||||
from zope.interface import implementer
|
||||
|
||||
@ -261,17 +262,17 @@ class HoneyPotAvatar(avatar.ConchUser):
|
||||
avatar.ConchUser.__init__(self)
|
||||
self.username = username
|
||||
self.env = env
|
||||
self.fs = fs.HoneyPotFilesystem(copy.deepcopy(self.env.fs))
|
||||
|
||||
self.channelLookup.update({'session': HoneyPotSSHSession})
|
||||
self.channelLookup['direct-tcpip'] = KippoOpenConnectForwardingClient
|
||||
|
||||
userdb = core.auth.UserDB()
|
||||
self.uid = self.gid = userdb.getUID(self.username)
|
||||
|
||||
# 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" ):
|
||||
self.subsystemLookup['sftp'] = filetransfer.FileTransferServer
|
||||
|
||||
self.uid = self.gid = core.auth.UserDB().getUID(self.username)
|
||||
if not self.uid:
|
||||
self.home = '/root'
|
||||
else:
|
||||
@ -445,8 +446,7 @@ class KippoSFTPServer:
|
||||
|
||||
def __init__(self, avatar):
|
||||
self.avatar = avatar
|
||||
# FIXME we should not copy fs here, but do this at avatar instantiation
|
||||
self.fs = fs.HoneyPotFilesystem(copy.deepcopy(self.avatar.env.fs))
|
||||
self.fs = self.avatar.env.fs
|
||||
|
||||
def _absPath(self, path):
|
||||
home = self.avatar.home
|
||||
|
Reference in New Issue
Block a user