Skip to main content
This quickstart guide will get you analyzing binaries in minutes using the Binary Ninja API.

Choose your language

Python quickstart

Python is the fastest way to get started with the Binary Ninja API.
1

Set up Python path

Add Binary Ninja’s Python API to your PYTHONPATH:
macOS
export PYTHONPATH="/Applications/Binary Ninja.app/Contents/Resources/python"
Linux
export PYTHONPATH="$HOME/binaryninja/python"
Windows
set PYTHONPATH=C:\Program Files\Vector35\BinaryNinja\python
2

Write your first script

Create analyze.py:
analyze.py
from binaryninja import BinaryViewType

# Load a binary
bv = BinaryViewType.get_view_of_file("/bin/ls")

print(f"Analyzing: {bv.file.filename}")
print(f"Architecture: {bv.arch.name}")
print(f"Entry point: {hex(bv.entry_point)}")

# List functions
print(f"\nFound {len(bv.functions)} functions:")
for func in list(bv.functions)[:5]:
    print(f"  {hex(func.start)}: {func.name}")

# Find strings
print(f"\nStrings ({len(bv.strings)} total):")
for string in list(bv.strings)[:5]:
    print(f"  {hex(string.start)}: {string.value!r}")
3

Run it

python analyze.py
Output:
Analyzing: ls
Architecture: x86_64
Entry point: 0x100001b40

Found 157 functions:
  0x100001b40: _start
  0x100001b68: entry
  0x100002f90: _main
  ...
For headless operation outside the GUI, you need a license with headless support.

Next steps

Core concepts

Learn about binary views, architectures, and IL

Examples

See complete examples and patterns

Plugin development

Create plugins to extend Binary Ninja

API reference

Explore the complete API documentation

Common patterns

for func in bv.functions:
    for block in func.basic_blocks:
        for instr in block:
            print(f"{hex(instr[0])}: {instr[1]}")
for func in bv.functions:
    for ref in func.call_sites:
        print(f"{hex(ref.address)}: calls {ref.function.name}")
func = bv.get_function_at(0x1000)
for block in func.hlil:
    for instr in block:
        print(instr)
for func in bv.functions:
    if func.hlil:
        print(f"// {func.name}")
        for line in func.hlil.root.lines:
            print(line)

Build docs developers (and LLMs) love