Print out commands

pull/10/head
Zach Riggle 11 years ago
parent d1743d7a87
commit 33aeb4c0a9

@ -96,3 +96,6 @@ def prompt_hook(*a):
pwndbg.commands.context.context() pwndbg.commands.context.context()
gdb.prompt_hook = prompt_hook gdb.prompt_hook = prompt_hook
msg = "Loaded %i commands. Type pwndbg for a list." % len(pwndbg.commands.Command.commands)
print pwndbg.color.red(msg)

@ -33,11 +33,16 @@ __all__ = [
debug = True debug = True
class Command(gdb.Command): class Command(gdb.Command):
count = 0
commands = []
def __init__(self, function): def __init__(self, function):
self.__doc__ = function.__doc__ self.__doc__ = function.__doc__
super(Command, self).__init__(function.__name__, gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION) super(Command, self).__init__(function.__name__, gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION)
self.function = function self.function = function
Command.commands.append(self)
def split_args(self, argument): def split_args(self, argument):
return gdb.string_to_argv(argument) return gdb.string_to_argv(argument)
@ -78,3 +83,12 @@ def fix(arg, sloppy=False):
return None return None
OnlyWhenRunning = pwndbg.proc.OnlyWhenRunning OnlyWhenRunning = pwndbg.proc.OnlyWhenRunning
@Command
def pwndbg():
"""
Prints out a list of all pwndbg commands.
"""
names = [C.function.__name__ for C in Command.commands]
for name in sorted(names):
print(name)

@ -1,3 +1,4 @@
from __future__ import print_function
import gdb import gdb
import pwndbg.auxv import pwndbg.auxv
import pwndbg.chain import pwndbg.chain

@ -62,14 +62,14 @@ shellcmds = [
"zsh", "zsh",
] ]
def register_shell_function(cmd): # def register_shell_function(cmd):
def handler(*a): # def handler(*a):
"""Invokes %s""" % cmd # """Invokes %s""" % cmd
if os.fork() == 0: # if os.fork() == 0:
os.execvp(cmd, (cmd,) + a) # os.execvp(cmd, (cmd,) + a)
os.wait() # os.wait()
handler.__name__ = cmd # handler.__name__ = cmd
pwndbg.commands.Command(handler) # pwndbg.commands.Command(handler)
for cmd in shellcmds: # for cmd in shellcmds:
register_shell_function(cmd) # register_shell_function(cmd)

Loading…
Cancel
Save