mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
less verbose logging at fs level. working imports
This commit is contained in:
@ -180,34 +180,35 @@ class HoneyPotFilesystem(object):
|
|||||||
# additions for SFTP support, try to keep functions here similar to os.*
|
# additions for SFTP support, try to keep functions here similar to os.*
|
||||||
|
|
||||||
def open(self, filename, openFlags, mode):
|
def open(self, filename, openFlags, mode):
|
||||||
print "fs.open %s" % filename
|
#print "fs.open %s" % filename
|
||||||
|
|
||||||
if (openFlags & os.O_APPEND == os.O_APPEND):
|
if (openFlags & os.O_APPEND == os.O_APPEND):
|
||||||
print "fs.open append"
|
#print "fs.open append"
|
||||||
|
|
||||||
if (openFlags & os.O_CREAT == os.O_CREAT):
|
if (openFlags & os.O_CREAT == os.O_CREAT):
|
||||||
print "fs.open creat"
|
#print "fs.open creat"
|
||||||
|
|
||||||
if (openFlags & os.O_TRUNC == os.O_TRUNC):
|
if (openFlags & os.O_TRUNC == os.O_TRUNC):
|
||||||
print "fs.open trunc"
|
#print "fs.open trunc"
|
||||||
|
|
||||||
if (openFlags & os.O_EXCL == os.O_EXCL):
|
if (openFlags & os.O_EXCL == os.O_EXCL):
|
||||||
print "fs.open excl"
|
#print "fs.open excl"
|
||||||
|
|
||||||
if openFlags & os.O_RDWR == os.O_RDWR:
|
if openFlags & os.O_RDWR == os.O_RDWR:
|
||||||
print "fs.open rdwr"
|
#print "fs.open rdwr"
|
||||||
raise notImplementedError
|
raise notImplementedError
|
||||||
|
|
||||||
elif openFlags & os.O_WRONLY == os.O_WRONLY:
|
elif openFlags & os.O_WRONLY == os.O_WRONLY:
|
||||||
# ensure we do not save with executable bit set
|
# ensure we do not save with executable bit set
|
||||||
realmode = mode & ~(stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
|
realmode = mode & ~(stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
|
||||||
|
|
||||||
print "fs.open wronly %s " % os.O_WRONLY
|
#print "fs.open wronly %s " % os.O_WRONLY
|
||||||
|
# TODO: safeoutfile could contains source IP address
|
||||||
safeoutfile = '%s/%s_%s' % \
|
safeoutfile = '%s/%s_%s' % \
|
||||||
(config().get('honeypot', 'download_path'),
|
(config().get('honeypot', 'download_path'),
|
||||||
time.strftime('%Y%m%d%H%M%S'),
|
time.strftime('%Y%m%d%H%M%S'),
|
||||||
re.sub('[^A-Za-z0-9]', '_', filename))
|
re.sub('[^A-Za-z0-9]', '_', filename))
|
||||||
print "fs.open file for writing, saving to %s" % safeoutfile
|
#print "fs.open file for writing, saving to %s" % safeoutfile
|
||||||
|
|
||||||
self.mkfile(filename, 0, 0, 0, stat.S_IFREG | mode)
|
self.mkfile(filename, 0, 0, 0, stat.S_IFREG | mode)
|
||||||
fd = os.open(safeoutfile, openFlags, realmode)
|
fd = os.open(safeoutfile, openFlags, realmode)
|
||||||
@ -216,7 +217,7 @@ class HoneyPotFilesystem(object):
|
|||||||
return fd
|
return fd
|
||||||
|
|
||||||
elif openFlags & os.O_RDONLY == os.O_RDONLY:
|
elif openFlags & os.O_RDONLY == os.O_RDONLY:
|
||||||
print "fs.open rdonly"
|
#print "fs.open rdonly"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -271,7 +272,7 @@ class HoneyPotFilesystem(object):
|
|||||||
raise notImplementedError
|
raise notImplementedError
|
||||||
|
|
||||||
def rename(self, oldpath, newpath):
|
def rename(self, oldpath, newpath):
|
||||||
print "rename %s to %s" % (oldpath, newpath)
|
#print "rename %s to %s" % (oldpath, newpath)
|
||||||
old = self.getfile(oldpath)
|
old = self.getfile(oldpath)
|
||||||
if old == False:
|
if old == False:
|
||||||
raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
|
raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
|
||||||
|
|||||||
@ -4,15 +4,20 @@
|
|||||||
import twisted
|
import twisted
|
||||||
from twisted.cred import portal
|
from twisted.cred import portal
|
||||||
from twisted.conch import avatar, interfaces as conchinterfaces
|
from twisted.conch import avatar, interfaces as conchinterfaces
|
||||||
from twisted.conch.ssh import factory, userauth, connection, keys, session, transport
|
from twisted.conch.ssh import factory, userauth, connection, keys, session, transport, filetransfer
|
||||||
from twisted.python import log
|
from twisted.conch.ssh.filetransfer import FXF_READ, FXF_WRITE, FXF_APPEND, FXF_CREAT, FXF_TRUNC, FXF_EXCL
|
||||||
|
import twisted.conch.ls
|
||||||
|
from twisted.python import log, components
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import copy
|
||||||
import time
|
import time
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
from kippo.core import ttylog, utils
|
from kippo.core import ttylog, utils, fs
|
||||||
from kippo.core.config import config
|
from kippo.core.config import config
|
||||||
import kippo.core.auth
|
import kippo.core.auth
|
||||||
import kippo.core.honeypot
|
import kippo.core.honeypot
|
||||||
@ -485,5 +490,4 @@ class KippoSFTPServer:
|
|||||||
|
|
||||||
components.registerAdapter( KippoSFTPServer, HoneyPotAvatar, conchinterfaces.ISFTPServer)
|
components.registerAdapter( KippoSFTPServer, HoneyPotAvatar, conchinterfaces.ISFTPServer)
|
||||||
|
|
||||||
|
|
||||||
# vim: set et sw=4 et:
|
# vim: set et sw=4 et:
|
||||||
|
|||||||
Reference in New Issue
Block a user