Add support for character search

Add support to search number (for example: `1234`) in character string as characters instead of integers. It also supports searching of characters directly in hex form for characters such as `\xff`.
pull/20/head
Rakholiya Jenish 10 years ago
parent 1bafd35211
commit ede2c4e99f

@ -13,17 +13,31 @@ import pwndbg.vmmap
@pwndbg.commands.Command @pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning @pwndbg.commands.OnlyWhenRunning
def search(value): def search(searchtype, value=None):
""" """
Search memory for the specified value, provided Search memory for the specified value, provided
either as a pointer-width integer, or a string. either as a pointer-width integer, or a string.
> search 0xdeadbeef > search 0xdeadbeef
> search "/bin/sh" > search "/bin/sh"
To search 1234 in a character string instead of integer
> search/c 1234
To search for characters using hex values in string
> search/xc f0f1f2f3
> search/xc \xf0\xf1\xf2\xf3
> search/xc \\xf0\\xf1\\xf2\\xf3
""" """
if value:
searchtype = searchtype[1:]
else:
value, searchtype = searchtype, value
hits = set() hits = set()
for address in pwndbg.search.search(value): for address in pwndbg.search.search(value, searchtype):
if not address: if not address:
continue continue
@ -47,12 +61,23 @@ def search(value):
@pwndbg.commands.Command @pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning @pwndbg.commands.OnlyWhenRunning
def searchmem(value): def searchmem(searchtype, value=None):
""" """
Search memory for the specified value, provided Search memory for the specified value, provided
either as a pointer-width integer, or a string. either as a pointer-width integer, or a string.
> search 0xdeadbeef > search 0xdeadbeef
> search "/bin/sh" > search "/bin/sh"
To search 1234 in a character string instead of integer
> search/c 1234
To search for characters using hex values in string
> search/xc f0f1f2f3
> search/xc \xf0\xf1\xf2\xf3
> search/xc \\xf0\\xf1\\xf2\\xf3
""" """
return search(value) if value:
return search(searchtype, value)
else:
return search(searchtype)

Loading…
Cancel
Save