From 3d6bd1d285f6f2534d0bbbc114d880df56111e89 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Fri, 1 Jul 2016 14:14:15 +0200 Subject: [PATCH] Force conversion to int() before hex() to avoid 0xdeadbeefL --- pwndbg/commands/elf.py | 2 +- pwndbg/commands/gdbinit.py | 2 +- pwndbg/commands/segments.py | 4 ++-- pwndbg/symbol.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pwndbg/commands/elf.py b/pwndbg/commands/elf.py index 5b726e036..5994f22cc 100755 --- a/pwndbg/commands/elf.py +++ b/pwndbg/commands/elf.py @@ -65,7 +65,7 @@ def print_symbols_in_section(section_name, filter_text=''): symbols = get_symbols_in_region(start, end, filter_text) for symbol, addr in symbols: - print(hex(addr) + ': ' + symbol) + print(hex(int(addr)) + ': ' + symbol) def get_symbols_in_region(start, end, filter_text=''): symbols = [] diff --git a/pwndbg/commands/gdbinit.py b/pwndbg/commands/gdbinit.py index b45cb2b21..a5106e404 100644 --- a/pwndbg/commands/gdbinit.py +++ b/pwndbg/commands/gdbinit.py @@ -42,4 +42,4 @@ def libs(): def entry_point(): """GDBINIT compatibility alias to print the entry point. See also the 'entry' command.""" - print(hex(pwndbg.elf.entry())) + print(hex(int(pwndbg.elf.entry()))) diff --git a/pwndbg/commands/segments.py b/pwndbg/commands/segments.py index 1ff45f9ab..1b62e8013 100644 --- a/pwndbg/commands/segments.py +++ b/pwndbg/commands/segments.py @@ -25,7 +25,7 @@ def fsbase(): """ Prints out the FS base address. See also $fsbase. """ - print(hex(pwndbg.regs.fsbase)) + print(hex(int(pwndbg.regs.fsbase))) @pwndbg.commands.ParsedCommand @@ -34,4 +34,4 @@ def gsbase(): """ Prints out the GS base address. See also $gsbase. """ - print(hex(pwndbg.regs.gsbase)) + print(hex(int(pwndbg.regs.gsbase))) diff --git a/pwndbg/symbol.py b/pwndbg/symbol.py index 0abca672a..ec4994c5b 100644 --- a/pwndbg/symbol.py +++ b/pwndbg/symbol.py @@ -138,13 +138,13 @@ def autofetch(): except elftools.common.exceptions.ELFError: continue - gdb_command = ['add-symbol-file', local_path, hex(base)] + gdb_command = ['add-symbol-file', local_path, hex(int(base))] for section in elf.iter_sections(): name = section.name.decode('latin-1') section = section.header if not section.sh_flags & elftools.elf.constants.SH_FLAGS.SHF_ALLOC: continue - gdb_command += ['-s', name, hex(base + section.sh_addr)] + gdb_command += ['-s', name, hex(int(base + section.sh_addr))] print(' '.join(gdb_command)) # gdb.execute(' '.join(gdb_command), from_tty=False, to_string=True)