diff --git a/pwndbg/commands/context.py b/pwndbg/commands/context.py index c02e5b1f5..705951b92 100644 --- a/pwndbg/commands/context.py +++ b/pwndbg/commands/context.py @@ -66,9 +66,12 @@ def context_stack(): result.extend(telescope) return result -def context_backtrace(frame_count=10): +def context_backtrace(frame_count=10, with_banner=True): result = [] - result.append(pwndbg.color.blue(pwndbg.ui.banner("backtrace"))) + + if with_banner: + result.append(pwndbg.color.blue(pwndbg.ui.banner("backtrace"))) + this_frame = gdb.selected_frame() newest_frame = this_frame oldest_frame = this_frame @@ -93,7 +96,10 @@ def context_backtrace(frame_count=10): i = 0 while True: prefix = '> ' if frame == this_frame else ' ' - addrsz = pwndbg.symbol.get(frame.pc()) or pwndbg.ui.addrsz(frame.pc()) + addrsz = pwndbg.ui.addrsz(frame.pc()) + symbol = pwndbg.symbol.get(frame.pc()) + if symbol: + addrsz = addrsz + ' ' + symbol line = map(str, (prefix, 'f', i, addrsz)) line = ' '.join(line) result.append(line) diff --git a/pwndbg/commands/ida.py b/pwndbg/commands/ida.py index dcfc2b51d..2153096f9 100644 --- a/pwndbg/commands/ida.py +++ b/pwndbg/commands/ida.py @@ -1,15 +1,47 @@ import gdb import pwndbg.commands +import pwndbg.commands.context import pwndbg.ida import pwndbg.regs - @pwndbg.commands.ParsedCommand @pwndbg.commands.OnlyWhenRunning +@pwndbg.events.stop def j(*args): - pc = pwndbg.regs.pc + pc = int(gdb.selected_frame().pc()) pwndbg.ida.Jump(pc) + +if pwndbg.ida.available(): + @pwndbg.commands.Command + @pwndbg.commands.OnlyWhenRunning + def up(): + f = gdb.selected_frame() + o = f.older() + + if o: + o.select() + + bt = pwndbg.commands.context.context_backtrace(with_banner=False) + print('\n'.join(bt)) + + j() + + @pwndbg.commands.Command + @pwndbg.commands.OnlyWhenRunning + def down(): + f = gdb.selected_frame() + o = f.newer() + + if o: + o.select() + + bt = pwndbg.commands.context.context_backtrace(with_banner=False) + print('\n'.join(bt)) + + j() + + class ida(gdb.Function): """ Return a value from IDA that can be used in diff --git a/pwndbg/commands/shell.py b/pwndbg/commands/shell.py index c3c82accc..b3d7cd797 100644 --- a/pwndbg/commands/shell.py +++ b/pwndbg/commands/shell.py @@ -24,8 +24,8 @@ shellcmds = [ "grep", "htop", "id", - "kill", - "killall", + # "kill", + # "killall", "less", "ln", "ls", diff --git a/pwndbg/events.py b/pwndbg/events.py index f1d587888..8dd79afba 100644 --- a/pwndbg/events.py +++ b/pwndbg/events.py @@ -9,7 +9,7 @@ import traceback import gdb import sys -debug = False +debug = True pause = 0 # In order to support reloading, we must be able to re-fire @@ -37,6 +37,7 @@ def connect(func, event_handler, name=''): except Exception as e: if debug: print(traceback.format_exc()) raise e + if debug: sys.stdout.write('DONE %r %s.%s %r\n' % (name, func.__module__, func.__name__, a)) registered[event_handler].append(caller) caller.name = func.__name__ event_handler.connect(caller) diff --git a/pwndbg/ida.py b/pwndbg/ida.py index f07fae234..79cd5e311 100644 --- a/pwndbg/ida.py +++ b/pwndbg/ida.py @@ -184,11 +184,6 @@ colored_pc = None # SetColor(colored_pc, 0xffffff) # colored_pc = None -@pwndbg.events.stop -@withIDA -def Auto_Jump(): - Jump(pwndbg.regs.pc) - @withIDA @returns_address @pwndbg.memoize.reset_on_objfile