Skip to content

Commit

Permalink
initial advanced binary search documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
psifertex committed Apr 23, 2024
1 parent aa4ad79 commit 98a5094
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ The normal find dialog also exists as a sidebar panel that allows persistent, ta

The search types are available from a drop-down next to the text input field and include:

- Advanced Binary Search: A new search type using the [bv.search](https://dev-api.binary.ninja/binaryninja.binaryview-module.html#binaryninja.binaryview.BinaryView.search) syntax (supporting regular expressions and wildcard hex strings)
- Escaped: Escaped strings such as `OneString\x09\Tabsx09Another`
- Hex: All values much be valid hex characters such as `ebfffc390` and the bytes will only be searched for in this particular order
- Raw: A simple string search that matches the exact string as specified
Expand Down
Binary file modified docs/img/find.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions python/binaryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8700,6 +8700,15 @@ def search(self, pattern: str, start: int = None, end: int = None, raw: bool = F
:return: A generator object that yields the offset and matched DataBuffer for each match found.
:rtype: QueueGenerator
:Example:
>>> from binaryninja import load
>>> bv = load('/bin/ls')
>>> print(bv)
<BinaryView: '/bin/ls', start 0x100000000, len 0x182f8>
>>> bytes(list(bv.search("50 ?4"))[0][1]).hex()
'5004'
>>> bytes(list(bv.search("[\\x20-\\x25][\\x60-\\x67]"))[0][1]).hex()
'2062'
"""
if start is None:
start = self.start
Expand Down

0 comments on commit 98a5094

Please sign in to comment.