Add more Windbg compat

pull/23/merge
Zach Riggle 10 years ago
parent 70ebcd24dc
commit 8f6587395d

@ -24,8 +24,8 @@ class _Command(gdb.Command):
count = 0
commands = []
def __init__(self, function, inc=True):
super(_Command, self).__init__(function.__name__, gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION)
def __init__(self, function, inc=True, prefix=False):
super(_Command, self).__init__(function.__name__, gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION, prefix=prefix)
self.function = function
if inc:
@ -40,15 +40,20 @@ class _Command(gdb.Command):
def invoke(self, argument, from_tty):
argv = self.split_args(argument)
try:
return self.function(*argv)
return self(*argv)
except TypeError:
if debug:
print(traceback.format_exc())
raise
def __call__(self, *args, **kwargs):
with pwndbg.stdio.stdio:
return self.function(*args, **kwargs)
try:
with pwndbg.stdio.stdio:
return self.function(*args, **kwargs)
except TypeError as te:
print(te)
print('%r: %s' % (self.function.__name__.strip(),
self.function.__doc__.strip()))
class _ParsedCommand(_Command):
@ -67,8 +72,14 @@ class _ParsedCommand(_Command):
def fix(self, arg):
return fix(arg, self.sloppy, self.quiet)
class _ParsedCommandPrefix(_ParsedCommand):
def __init__(self, function, inc=True, prefix=True):
super(_ParsedCommand, self).__init__(function, inc, prefix)
def fix(arg, sloppy=False, quiet=False):
if isinstance(arg, gdb.Value):
return arg
try:
parsed = gdb.parse_and_eval(arg)
return parsed

@ -27,7 +27,7 @@ shellcmds = [
# "kill",
# "killall",
"less",
"ln",
# "ln",
"ls",
"man",
"mkdir",

@ -14,8 +14,10 @@ import pwndbg.vmmap
@pwndbg.commands.QuietSloppyParsedCommand
def vmmap(map=None):
"""
Print the virtal memory map
Print the virtal memory map, or the specific mapping for the
provided address / module name.
"""
print(repr(map))
int_map = None
str_map = None

@ -12,6 +12,7 @@ import pwndbg.arch
import pwndbg.commands
import pwndbg.memory
import pwndbg.strings
import pwndbg.symbol
import pwndbg.typeinfo
@ -179,6 +180,14 @@ def dds(*a):
"""
return pwndbg.commands.telescope.telescope(*a)
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
def kd(*a):
"""
Dump pointers and symbols at the specified address.
"""
return pwndbg.commands.telescope.telescope(*a)
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
def dps(*a):
@ -251,9 +260,11 @@ def bc(which = '*'):
@pwndbg.commands.OnlyWhenRunning
def bp(where):
"""
Set a breakpoint
Set a breakpoint at the specified address.
"""
gdb.execute('break *%#x' % int(where))
result = pwndbg.commands.fix(where)
if result is not None:
gdb.execute('break *%#x' % int(result))
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
@ -274,3 +285,60 @@ def k():
Print a backtrace (alias 'bt')
"""
gdb.execute('bt')
@pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning
def ln(value=None):
"""
List the symbols nearest to the provided value.
"""
if value is None: value = pwndbg.regs.pc
x = pwndbg.symbol.get(value)
if x:
result = '(%#x) %s' % (value, x)
@pwndbg.commands.OnlyWhenRunning
@pwndbg.commands.QuietSloppyParsedCommand
def lm(map):
"""
Windbg compatibility alias for 'vmmap' command.
"""
return pwndbg.commands.vmmap.vmmap(map)
@pwndbg.commands.OnlyWhenRunning
@pwndbg.commands.QuietSloppyParsedCommand
def address(map):
"""
Windbg compatibility alias for 'vmmap' command.
"""
return pwndbg.commands.vmmap.vmmap(map)
@pwndbg.commands.OnlyWhenRunning
@pwndbg.commands.QuietSloppyParsedCommand
def vprot(map):
"""
Windbg compatibility alias for 'vmmap' command.
"""
return pwndbg.commands.vmmap.vmmap(map)
@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def peb(*a):
print("This isn't Windows!")
@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def go():
'''
Windbg compatibility alias for 'continue' command.
'''
gdb.execute('continue')
@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def pc():
'''
Windbg compatibility alias for 'nextcall' command.
'''
return pwndbg.commands.next.nextcall()

@ -115,7 +115,7 @@ def get(address, gdb_only=False):
Retrieve the textual name for a symbol
"""
# Fast path
if address < pwndbg.memory.MMAP_MIN_ADDR or address >= (1 << 64):
if address < pwndbg.memory.MMAP_MIN_ADDR or address >= ((1 << 64)-1):
return ''
# Don't look up stack addresses

Loading…
Cancel
Save