From d0437202725859b4e12b107abf69e804416c76e0 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Mon, 15 Jan 2018 23:12:34 +0100 Subject: [PATCH] syntax: highlight code for chain format during enhance (#400) --- pwndbg/color/syntax_highlight.py | 2 +- pwndbg/enhance.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pwndbg/color/syntax_highlight.py b/pwndbg/color/syntax_highlight.py index 0156b2b43..f5cd7dbf7 100644 --- a/pwndbg/color/syntax_highlight.py +++ b/pwndbg/color/syntax_highlight.py @@ -33,7 +33,7 @@ def check_style(): style.value = style.default -def syntax_highlight(code, filename): +def syntax_highlight(code, filename='.asm'): # No syntax highlight if pygment is not installed if not pygments: return code diff --git a/pwndbg/enhance.py b/pwndbg/enhance.py index c554659ec..77ea14e34 100644 --- a/pwndbg/enhance.py +++ b/pwndbg/enhance.py @@ -20,12 +20,14 @@ import gdb import pwndbg.arch import pwndbg.color as color import pwndbg.color.enhance as E +import pwndbg.config import pwndbg.disasm import pwndbg.memoize import pwndbg.memory import pwndbg.strings import pwndbg.symbol import pwndbg.typeinfo +from pwndbg.color.syntax_highlight import syntax_highlight bad_instrs = [ '.byte', @@ -100,6 +102,8 @@ def enhance(value, code = True): instr = pwndbg.disasm.one(value) if instr: instr = "%-6s %s" % (instr.mnemonic, instr.op_str) + if pwndbg.config.syntax_highlight: + instr = syntax_highlight(instr) szval = pwndbg.strings.get(value) or None szval0 = szval