Skip to content

Commit 123f68f

Browse files
peace-makerArusekk
andauthored
Fix highlight of unaligned nullbyte in disasm cmd (Gallopsled#2182)
"1001" would highlight the "00" even though it's not a null byte in the input. Group the bytes correctly to look for real null bytes and newlines only ignoring accidental matches of adjacent bytes. Co-authored-by: Arusekk <[email protected]>
1 parent 5a84bbf commit 123f68f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pwnlib/commandline/disasm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def main(args):
8282
instrs = disasm(dat, vma=safeeval.const(args.address), byte=False, offset=False)
8383
# instrs = highlight(instrs, PwntoolsLexer(), TerminalFormatter())
8484

85+
highlight_bytes = lambda t: ''.join(map(lambda x: x.replace('00', text.red('00')).replace('0a', text.red('0a')), group(2, t)))
8586
for o,b,i in zip(*map(str.splitlines, (offsets, bytes, instrs))):
86-
b = b.replace('00', text.red('00'))
87-
b = b.replace('0a', text.red('0a'))
87+
b = ' '.join(highlight_bytes(bb) for bb in b.split(' '))
8888
i = highlight(i.strip(), PwntoolsLexer(), TerminalFormatter()).strip()
8989
i = i.replace(',',', ')
9090

0 commit comments

Comments
 (0)