SearchBin
SearchBin copied to clipboard
Output match content when pattern contains wildcards.
I want to iteratively build patterns, and having to use a second tool (a hex editor/viewer) to see what was found shouldn't be needed.
Here's a code snippet that worked for me:
# Print matched offset.
find_offset = offset + match
if len(pattern) > 1: # Also print match string when pattern contains wildcards
mstr = ' '.join("%02x" % ord(x) for x in buffer[match:match+len_pattern])
STDOUT.write("Match (%s) at offset: %14d %12X in %s\n" % ( mstr, find_offset, find_offset, fh_name ))
else:
STDOUT.write("Match at offset: %14d %12X in %s\n" % ( find_offset, find_offset, fh_name ))
Yes, I should do a branch and a pull request, but we can't work on public repos without permission (due to IP concerns).
Apologies for the late reply. I will review it. Thank you for your contribution. :)