From e7ff1d95acd94dd0db1e04f5f58710c10e64af4c Mon Sep 17 00:00:00 2001 From: HonigBij Date: Tue, 25 Aug 2015 13:10:15 +0200 Subject: [PATCH] Support for multiple symlink levels in command_cd --- cowrie/commands/fs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cowrie/commands/fs.py b/cowrie/commands/fs.py index 994efa0..a897031 100644 --- a/cowrie/commands/fs.py +++ b/cowrie/commands/fs.py @@ -52,9 +52,13 @@ 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): + count = 0 + while self.fs.is_link(newpath): f = self.fs.getfile(newpath) newpath = f[A_TARGET] + count += 1 + if count > 10: + raise self.fs.TooManyLevels if not self.fs.is_dir(newpath): self.writeln('bash: cd: %s: Not a directory' % path) return