mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
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:
@ -52,6 +52,14 @@ class command_cd(HoneyPotCommand):
|
||||
if newdir is None:
|
||||
self.writeln('bash: cd: %s: No such file or directory' % path)
|
||||
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):
|
||||
self.writeln('bash: cd: %s: Not a directory' % path)
|
||||
return
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user