From 686e93e0d0a26efc5a9f6a295fadba83d08b3875 Mon Sep 17 00:00:00 2001 From: MY7H <100413372+MY7H404@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:19:51 +0530 Subject: [PATCH] Add Verbose Output for Search Command Types (#2460) * Improve verbosity in search command * Fix: Avoid equality comparison to True in pointer check --- pwndbg/commands/search.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pwndbg/commands/search.py b/pwndbg/commands/search.py index d8bb0ab975f..b52f15c30f5 100644 --- a/pwndbg/commands/search.py +++ b/pwndbg/commands/search.py @@ -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) @@ -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)