Merge pull request #33 from SecPascal/cdlink

Added is_link() to core/fs.py to enable cd into symbolic link
This commit is contained in:
Michel Oosterhof
2015-08-25 18:28:45 +04:00
2 changed files with 15 additions and 0 deletions

View File

@ -52,6 +52,14 @@ class command_cd(HoneyPotCommand):
if newdir is None: if newdir is None:
self.writeln('bash: cd: %s: No such file or directory' % path) self.writeln('bash: cd: %s: No such file or directory' % path)
return return
count = 0
while self.fs.is_link(newpath):
f = self.fs.getfile(newpath)
newpath = f[A_TARGET]
count += 1
if count > 10:
self.writeln('bash: cd: %s: Too many levels of symbolic links' % path)
return
if not self.fs.is_dir(newpath): if not self.fs.is_dir(newpath):
self.writeln('bash: cd: %s: Not a directory' % path) self.writeln('bash: cd: %s: Not a directory' % path)
return return

View File

@ -185,6 +185,13 @@ class HoneyPotFilesystem(object):
self.newcount += 1 self.newcount += 1
return True 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): def is_dir(self, path):
if path == '/': if path == '/':
return True return True