command_echo: fix new line bug (#696)

This commit is contained in:
fe7ch
2018-03-13 15:11:26 +02:00
committed by Michel Oosterhof
parent 7d57dff367
commit dd99fde736

View File

@ -140,7 +140,6 @@ class command_echo(HoneyPotCommand):
except: except:
args = self.args args = self.args
# FIXME: Wrap in exception, Python escape cannot handle single digit \x codes (e.g. \x1)
try: try:
# replace r'\\x' with r'\x' # replace r'\\x' with r'\x'
s = ' '.join(args).replace('\\\\x', '\\x') s = ' '.join(args).replace('\\\\x', '\\x')
@ -156,13 +155,14 @@ class command_echo(HoneyPotCommand):
s = s[:-2] s = s[:-2]
newline = False newline = False
if newline is True:
s += '\n'
self.write(escape_fn(s)) self.write(escape_fn(s))
except ValueError as e: except ValueError as e:
log.msg("echo command received Python incorrect hex escape") log.msg("echo command received Python incorrect hex escape")
if newline is True:
self.write('\n')
commands['/bin/echo'] = command_echo commands['/bin/echo'] = command_echo