From a77aa94d33ecb7c9f87d8300dbb2476911d9661f Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Wed, 12 Aug 2015 16:23:27 -0700 Subject: [PATCH] update 'cat' to wait on stdin. --- cowrie/commands/fs.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/cowrie/commands/fs.py b/cowrie/commands/fs.py index 700b6173..2ce863be 100644 --- a/cowrie/commands/fs.py +++ b/cowrie/commands/fs.py @@ -11,16 +11,24 @@ from cowrie.core.fs import * commands = {} class command_cat(HoneyPotCommand): - def call(self): - for arg in self.args: - path = self.fs.resolve_path(arg, self.honeypot.cwd) - if self.fs.is_dir(path): - self.writeln('cat: %s: Is a directory' % (arg,)) - continue - try: - self.write(self.fs.file_contents(path)) - except: - self.writeln('cat: %s: No such file or directory' % (arg,)) + def start(self): + if not self.args or self.args[0] == '>': + pass + else: + for arg in self.args: + path = self.fs.resolve_path(arg, self.honeypot.cwd) + if self.fs.is_dir(path): + self.writeln('cat: %s: Is a directory' % (arg,)) + continue + try: + self.write(self.fs.file_contents(path)) + except: + self.writeln('cat: %s: No such file or directory' % (arg,)) + self.exit() + + def lineReceived(self, line): + log.msg( eventid='KIPP0008', realm='cat', input=line, + format='INPUT (%(realm)s): %(input)s' ) commands['/bin/cat'] = command_cat