Skip to content

Commit

Permalink
Add Verbose Output for Search Command Types (pwndbg#2460)
Browse files Browse the repository at this point in the history
* Improve verbosity in search command

* Fix: Avoid equality comparison to True in pointer check
  • Loading branch information
MY7H404 authored Oct 4, 2024
1 parent c373289 commit 686e93e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pwndbg/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ def search(
if not arch:
arch = pwnlib.context.context.arch

# Initialize is_pointer to track whether the search type is a pointer
is_pointer = None
# Adjust pointer sizes to the local architecture
if type == "pointer":
type = {4: "dword", 8: "qword"}[pwndbg.aglib.arch.ptrsize]
is_pointer = True

if save is None:
save = bool(pwndbg.config.auto_save_search)
Expand Down Expand Up @@ -285,11 +288,22 @@ def search(
print(message.error("Could not find mapping %r" % mapping_name))
return

# Output appropriate messages based on the detected search type for better clarity
if is_pointer:
print("Searching for a pointer-width integer: " + repr(value))
elif type == "word" or type == "short":
print("Searching for a 2-byte integer: " + repr(value))
elif type == "dword":
print("Searching for a 4-byte integer: " + repr(value))
elif type == "qword":
print("Searching for an 8-byte integer: " + repr(value))
elif type == "string":
print("Searching for string: " + repr(value))
# If next is passed, only perform a manual search over previously saved addresses
if type == "asm" or asmbp:
elif type == "asm" or asmbp:
print("Searching for instruction (assembled value): " + repr(value))
else:
print("Searching for value: " + repr(value))
print("Searching for byte: " + repr(value))

if next:
val_len = len(value)
Expand Down

0 comments on commit 686e93e

Please sign in to comment.