From 05c1f8a7f4a8a1df02369aacd70506eaa254d620 Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Sat, 3 Feb 2018 06:58:45 +0000 Subject: [PATCH] assuming shell content is utf-8 --- cowrie/commands/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cowrie/commands/base.py b/cowrie/commands/base.py index a58847b6..0f864a79 100644 --- a/cowrie/commands/base.py +++ b/cowrie/commands/base.py @@ -143,13 +143,13 @@ class command_echo(HoneyPotCommand): # FIXME: Wrap in exception, Python escape cannot handle single digit \x codes (e.g. \x1) try: # replace r'\\x' with r'\x' - s = ' '.join(args).replace(b'\\\\x', b'\\x') + s = ' '.join(args).replace('\\\\x', '\\x') # replace single character escape \x0 with \x00 s = re.sub('(?<=\\\\)x([0-9a-fA-F])(?=\\\\|\"|\'|\s|$)', 'x0\g<1>', s) # strip single and double quotes - s = s.strip(b'\"\'') + s = s.strip('\"\'') # if the string ends with \c escape, strip it and set newline flag to False if s.endswith('\\c'): @@ -180,13 +180,13 @@ class command_printf(HoneyPotCommand): escape_fn = functools.partial(unicode.decode, encoding="string_escape") # replace r'\\x' with r'\x' - s = ''.join(self.args[0]).replace(b'\\\\x', b'\\x') + s = ''.join(self.args[0]).replace('\\\\x', '\\x') # replace single character escape \x0 with \x00 s = re.sub('(?<=\\\\)x([0-9a-fA-F])(?=\\\\|\"|\'|\s|$)', 'x0\g<1>', s) # strip single and double quotes - s = s.strip(b'\"\'') + s = s.strip('\"\'') # if the string ends with \c escape, strip it if s.endswith('\\c'):