Vivisect

1.3.2 · active · verified Thu Apr 16

Vivisect is a pure Python disassembler, debugger, emulator, and static analysis framework. It is a comprehensive toolkit for reverse engineering, offering powerful APIs for analyzing various binary formats (PE, ELF, IHEX, SREC, or blob) across multiple architectures. The library is actively maintained, with regular releases providing new features and fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Vivisect workspace, load a binary file, perform auto-analysis, and then programmatically access discovered functions and code locations. It illustrates the fundamental steps for static analysis.

import vivisect
import os

# Create a dummy binary file for demonstration
dummy_bin_path = 'temp_dummy.bin'
with open(dummy_bin_path, 'wb') as f:
    f.write(b'\x90\x90\x90\xc3') # NOP NOP NOP RET

try:
    # Create a VivWorkspace instance
    vw = vivisect.VivWorkspace()

    # Load a binary file into the workspace
    # Replace 'path/to/your/binary.exe' with a real binary or use the dummy
    vw.loadFromFile(dummy_bin_path)

    # Perform auto-analysis on the loaded binary
    print("Starting analysis...")
    vw.analyze()
    print("Analysis complete.")

    # Example: Get functions discovered by analysis
    functions = vw.getFunctions()
    print(f"Found {len(functions)} functions:")
    for fva in functions:
        f_name = vw.getName(fva)
        print(f"  0x{fva:x}: {f_name}")

    # Example: Get locations (e.g., instructions)
    locations = vw.getLocations()
    print(f"Found {len(locations)} locations:")
    for va, size, ltype, tinfo in locations:
        op = vw.getOpcode(va)
        print(f"  0x{va:x}: {op.mnem} {op.opers_str}")

finally:
    # Clean up the dummy file
    if os.path.exists(dummy_bin_path):
        os.remove(dummy_bin_path)

view raw JSON →