Add pwndbg.config module and examples

pull/45/head
Zach Riggle 10 years ago
parent c036b33d01
commit e9fe067a42

@ -3,17 +3,25 @@
from __future__ import print_function from __future__ import print_function
import pwndbg.arch import pwndbg.arch
import pwndbg.commands import pwndbg.commands
import pwndbg.config
import pwndbg.hexdump import pwndbg.hexdump
import pwndbg.memory import pwndbg.memory
import pwndbg.regs import pwndbg.regs
default_width = pwndbg.config.Parameter('hexdump-width',
16,
'line width of hexdump command')
default_bytes = pwndbg.config.Parameter('hexdump-bytes',
16,
'number of bytes printed by hexdump command')
@pwndbg.commands.ParsedCommand @pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning @pwndbg.commands.OnlyWhenRunning
def hexdump(address=None, count=64): def hexdump(address=None, count=default_bytes):
""" """
Hexdumps data at the specified address. Hexdumps data at the specified address.
Optionally provide the number of bytes to dump (default 64) Optionally provide the number of bytes to dump (default is controlled
by the 'hexdump-bytes' config.)
Note that repeating rows are collapsed. Note that repeating rows are collapsed.
""" """
@ -33,5 +41,5 @@ def hexdump(address=None, count=64):
data = pwndbg.memory.read(address, count, partial=True) data = pwndbg.memory.read(address, count, partial=True)
for line in pwndbg.hexdump.hexdump(data, address=address): for line in pwndbg.hexdump.hexdump(data, address=address, width=int(default_width)):
print(line) print(line)

@ -10,14 +10,19 @@ import collections
import pwndbg.arch import pwndbg.arch
import pwndbg.chain import pwndbg.chain
import pwndbg.commands import pwndbg.commands
import pwndbg.config
import pwndbg.memory import pwndbg.memory
import pwndbg.regs import pwndbg.regs
import pwndbg.typeinfo import pwndbg.typeinfo
telescope_lines = pwndbg.config.Parameter('telescope-lines',
8,
'number of lines to printed by the telescope command')
@pwndbg.commands.ParsedCommand @pwndbg.commands.ParsedCommand
@pwndbg.commands.OnlyWhenRunning @pwndbg.commands.OnlyWhenRunning
def telescope(address=None, count=8, to_string=False): def telescope(address=None, count=telescope_lines, to_string=False):
""" """
Recursively dereferences pointers starting at the specified address Recursively dereferences pointers starting at the specified address
($sp by default) ($sp by default)

@ -42,6 +42,7 @@ for c in bytearray((string.ascii_letters + string.digits + string.punctuation).e
printable[-1] = ' ' printable[-1] = ' '
def hexdump(data, address = 0, width = 16, skip = True): def hexdump(data, address = 0, width = 16, skip = True):
data = list(bytearray(data)) data = list(bytearray(data))
base = address base = address

Loading…
Cancel
Save