diff --git a/README b/README index 7283708..b8c493a 100644 --- a/README +++ b/README @@ -105,6 +105,7 @@ Features: +Requires Python 2.7 or Python 3 +Less code +Search in files of unlimited size ++See the matched pattern when you use wildcard "??" keywords: hex hexidecimal binary like grep search seek find fast Please report bugs & feature requests to sepero 111 @ gmx . com diff --git a/searchbin.py b/searchbin.py index be96f0b..62e2c36 100755 --- a/searchbin.py +++ b/searchbin.py @@ -313,7 +313,7 @@ def _debug_search(pattern, fh_name, fh_read): buffer += fh_read(read_size) match = regex.search(buffer) else: - STDOUT.write("Match at offset: %14d %12X in %s\n" % ( + STDOUT.write("Match at offset: %14d decimal %12X hex in %s\n" % ( offset+match.start(), offset+match.start(), fh_name)) match = regex.search(buffer, match.start()+1) @@ -374,8 +374,11 @@ def _search_loop(start, end, bsize, pattern, max_matches, # Print matched offset. find_offset = offset + match - STDOUT.write("Match at offset: %14d %12X in %s\n" % ( - find_offset, find_offset, fh_name)) + if bytes(".", 'utf-8') in pattern: # see the matched pattern when you use wildcard ?? ("?" -> ".") + mstr = ' '.join(format(x, "02X") for x in buffer[match:match+len_pattern]) + STDOUT.write("Match (%s) at offset: %14d decimal %12X hex in %s\n" % ( mstr, find_offset, find_offset, fh_name )) + else: + STDOUT.write("Match at offset: %14d decimal %12X hex in %s\n" % ( find_offset, find_offset, fh_name)) if max_matches: max_matches -= 1