From 8c28c8acd6ccdbb410585f8d65494dc709a2ffc5 Mon Sep 17 00:00:00 2001 From: fe7ch Date: Fri, 21 Oct 2016 14:14:42 +0300 Subject: [PATCH] Replace single character escape with double character escape (#299) --- cowrie/commands/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cowrie/commands/base.py b/cowrie/commands/base.py index e5756e2..4240f1e 100644 --- a/cowrie/commands/base.py +++ b/cowrie/commands/base.py @@ -5,6 +5,7 @@ import time import datetime import functools import getopt +import re from twisted.python import failure, log @@ -138,7 +139,7 @@ class command_echo(HoneyPotCommand): # FIXME: Wrap in exception, Python escape cannot handle single digit \x codes (e.g. \x1) try: - self.write(escape_fn(' '.join(args))) + self.write(escape_fn(re.sub('(?<=\\\\)x([0-9a-fA-F]{1})(?=\\\\|\"|\s|$)', 'x0\g<1>', ' '.join(args)))) except ValueError as e: log.msg("echo command received Python incorrect hex escape")