From 889d19a000a8977abbf55e4f35cbb3ba2c2fef3b Mon Sep 17 00:00:00 2001 From: kesslerm Date: Fri, 27 Apr 2018 09:55:39 -0600 Subject: [PATCH] Fix memory print when escape character encountered --- voltron/plugins/api/memory.py | 5 ++++- voltron/plugins/view/memory.py | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/voltron/plugins/api/memory.py b/voltron/plugins/api/memory.py index b638223..c40dea0 100644 --- a/voltron/plugins/api/memory.py +++ b/voltron/plugins/api/memory.py @@ -2,6 +2,7 @@ import voltron import logging import six import struct +import binascii from voltron.api import * @@ -108,7 +109,9 @@ class APIMemoryRequest(APIRequest): res = APIMemoryResponse() res.address = addr - res.memory = six.u(memory) + #don't use six.u since it processes escape sequences ie... breaks if we have 0x5C 0x37 in memory + #res.memory = six.u(memory) + res.memory = binascii.hexlify(memory) res.bytes = len(memory) res.deref = deref except TargetBusyException: diff --git a/voltron/plugins/view/memory.py b/voltron/plugins/view/memory.py index 09e4d65..8c8d467 100644 --- a/voltron/plugins/view/memory.py +++ b/voltron/plugins/view/memory.py @@ -1,5 +1,6 @@ import logging import six +import binascii import pygments import pygments.formatters from pygments.token import * @@ -83,6 +84,7 @@ class MemoryView(TerminalView): if m_res and m_res.is_success: bytes_per_chunk = self.args.words*target['addr_size'] if self.args.words else self.args.bytes + m_res.memory = binascii.unhexlify(m_res.memory) for c in range(0, m_res.bytes, bytes_per_chunk): chunk = m_res.memory[c:c + bytes_per_chunk] yield (Name.Label, self.format_address(m_res.address + c, size=target['addr_size'], pad=False)) @@ -94,8 +96,11 @@ class MemoryView(TerminalView): n = "%02X" % x token = Text if x else Comment if self.args.track and self.last_memory and self.last_address == m_res.address: - if x != six.indexbytes(self.last_memory, c + i): - token = Error + try: + if x != six.indexbytes(self.last_memory, c + i): + token = Error + except: + pass byte_array.append((token, n)) if self.args.words: