|
|
|
@ -9,8 +9,8 @@ import gdb
|
|
|
|
import pwndbg.commands
|
|
|
|
import pwndbg.commands
|
|
|
|
import pwndbg.which
|
|
|
|
import pwndbg.which
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pwncmds = ["asm", "constgrep", "cyclic", "disasm", "pwn", "unhex"]
|
|
|
|
shellcmds = [
|
|
|
|
shellcmds = [
|
|
|
|
"asm", # pwntools
|
|
|
|
|
|
|
|
"awk",
|
|
|
|
"awk",
|
|
|
|
"bash",
|
|
|
|
"bash",
|
|
|
|
"cat",
|
|
|
|
"cat",
|
|
|
|
@ -18,12 +18,9 @@ shellcmds = [
|
|
|
|
"chmod",
|
|
|
|
"chmod",
|
|
|
|
"chown",
|
|
|
|
"chown",
|
|
|
|
# "clear",
|
|
|
|
# "clear",
|
|
|
|
"constgrep", # pwntools
|
|
|
|
|
|
|
|
"cp",
|
|
|
|
"cp",
|
|
|
|
"cyclic", # pwntools
|
|
|
|
|
|
|
|
"date",
|
|
|
|
"date",
|
|
|
|
"diff",
|
|
|
|
"diff",
|
|
|
|
"disasm", # pwntools
|
|
|
|
|
|
|
|
"egrep",
|
|
|
|
"egrep",
|
|
|
|
# "find", don't expose find as its an internal gdb command
|
|
|
|
# "find", don't expose find as its an internal gdb command
|
|
|
|
"grep",
|
|
|
|
"grep",
|
|
|
|
@ -46,7 +43,6 @@ shellcmds = [
|
|
|
|
"ps",
|
|
|
|
"ps",
|
|
|
|
"pstree",
|
|
|
|
"pstree",
|
|
|
|
"pwd",
|
|
|
|
"pwd",
|
|
|
|
"pwn", # pwntools
|
|
|
|
|
|
|
|
"rm",
|
|
|
|
"rm",
|
|
|
|
"sed",
|
|
|
|
"sed",
|
|
|
|
"sh",
|
|
|
|
"sh",
|
|
|
|
@ -56,7 +52,6 @@ shellcmds = [
|
|
|
|
"tail",
|
|
|
|
"tail",
|
|
|
|
"top",
|
|
|
|
"top",
|
|
|
|
"touch",
|
|
|
|
"touch",
|
|
|
|
"unhex", # pwntools
|
|
|
|
|
|
|
|
"uniq",
|
|
|
|
"uniq",
|
|
|
|
"vi",
|
|
|
|
"vi",
|
|
|
|
"vim",
|
|
|
|
"vim",
|
|
|
|
@ -67,18 +62,29 @@ shellcmds = [
|
|
|
|
"zsh",
|
|
|
|
"zsh",
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pwncmds = filter(pwndbg.which.which, pwncmds)
|
|
|
|
shellcmds = filter(pwndbg.which.which, shellcmds)
|
|
|
|
shellcmds = filter(pwndbg.which.which, shellcmds)
|
|
|
|
|
|
|
|
|
|
|
|
def register_shell_function(cmd):
|
|
|
|
def register_shell_function(cmd, deprecated=False):
|
|
|
|
def handler(*a):
|
|
|
|
def handler(*a):
|
|
|
|
if os.fork() == 0:
|
|
|
|
if os.fork() == 0:
|
|
|
|
os.execvp(cmd, (cmd,) + a)
|
|
|
|
os.execvp(cmd, (cmd,) + a)
|
|
|
|
os.wait()
|
|
|
|
os.wait()
|
|
|
|
|
|
|
|
print("This command is deprecated in Pwndbg. Please use the GDB's built-in syntax for running shell commands instead: !%s <args>" % cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doc = 'Invokes `{}` shell command'.format(cmd)
|
|
|
|
|
|
|
|
if deprecated:
|
|
|
|
|
|
|
|
doc += ' (deprecated)'
|
|
|
|
|
|
|
|
|
|
|
|
handler.__name__ = str(cmd)
|
|
|
|
handler.__name__ = str(cmd)
|
|
|
|
handler.__doc__ = 'Invokes {}'.format(cmd)
|
|
|
|
handler.__doc__ = doc
|
|
|
|
|
|
|
|
|
|
|
|
pwndbg.commands.Command(handler, False)
|
|
|
|
pwndbg.commands.Command(handler, False)
|
|
|
|
|
|
|
|
|
|
|
|
for cmd in shellcmds:
|
|
|
|
|
|
|
|
|
|
|
|
for cmd in pwncmds:
|
|
|
|
register_shell_function(cmd)
|
|
|
|
register_shell_function(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for cmd in shellcmds:
|
|
|
|
|
|
|
|
register_shell_function(cmd, deprecated=True)
|
|
|
|
|