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()
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
class Command(gdb.Command):
count = 0
commands = []
def __init__(self, function):
self.__doc__ = function.__doc__
super(Command, self).__init__(function.__name__, gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION)
self.function = function
Command.commands.append(self)
def split_args(self, argument):
return gdb.string_to_argv(argument)
@ -77,4 +82,13 @@ def fix(arg, sloppy=False):
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 pwndbg.auxv
import pwndbg.chain

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

Loading…
Cancel
Save