assuming shell content is utf-8

This commit is contained in:
Michel Oosterhof 2018-02-03 06:58:45 +00:00
parent c4a9550b92
commit 05c1f8a7f4
1 changed files with 4 additions and 4 deletions

View File

@ -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'):