From 33aeb4c0a98b313f0302d2a337539bc1e6fa8ff9 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Sat, 18 Apr 2015 18:12:52 -0400 Subject: [PATCH] Print out commands --- pwndbg/__init__.py | 3 +++ pwndbg/commands/__init__.py | 16 +++++++++++++++- pwndbg/commands/auxv.py | 1 + pwndbg/commands/shell.py | 20 ++++++++++---------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/pwndbg/__init__.py b/pwndbg/__init__.py index 67e0abaf4..8c97061fb 100644 --- a/pwndbg/__init__.py +++ b/pwndbg/__init__.py @@ -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) \ No newline at end of file diff --git a/pwndbg/commands/__init__.py b/pwndbg/commands/__init__.py index 2d73d1da5..c4cc50510 100644 --- a/pwndbg/commands/__init__.py +++ b/pwndbg/commands/__init__.py @@ -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 \ No newline at end of file +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) diff --git a/pwndbg/commands/auxv.py b/pwndbg/commands/auxv.py index 26cfe60e4..5d5f0a764 100644 --- a/pwndbg/commands/auxv.py +++ b/pwndbg/commands/auxv.py @@ -1,3 +1,4 @@ +from __future__ import print_function import gdb import pwndbg.auxv import pwndbg.chain diff --git a/pwndbg/commands/shell.py b/pwndbg/commands/shell.py index b3d7cd797..59f1b286f 100644 --- a/pwndbg/commands/shell.py +++ b/pwndbg/commands/shell.py @@ -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)