From c409459272b4c8584ee280151e449079a6bf232f Mon Sep 17 00:00:00 2001 From: HonigBij Date: Tue, 25 Aug 2015 11:07:21 +0200 Subject: [PATCH] Added is_link() to core/fs.py to enable cd into symbolic link in commands/fs.py --- cowrie/commands/fs.py | 3 +++ cowrie/core/fs.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/cowrie/commands/fs.py b/cowrie/commands/fs.py index 32b433d..994efa0 100644 --- a/cowrie/commands/fs.py +++ b/cowrie/commands/fs.py @@ -52,6 +52,9 @@ class command_cd(HoneyPotCommand): if newdir is None: self.writeln('bash: cd: %s: No such file or directory' % path) return + if self.fs.is_link(newpath): + f = self.fs.getfile(newpath) + newpath = f[A_TARGET] if not self.fs.is_dir(newpath): self.writeln('bash: cd: %s: Not a directory' % path) return diff --git a/cowrie/core/fs.py b/cowrie/core/fs.py index 74894ce..77119f2 100644 --- a/cowrie/core/fs.py +++ b/cowrie/core/fs.py @@ -185,6 +185,13 @@ class HoneyPotFilesystem(object): self.newcount += 1 return True + def is_link(self, path): + try: + f = self.getfile(path) + except: + return False + return f[A_TYPE] == T_LINK + def is_dir(self, path): if path == '/': return True