Vivisect
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
-
Exception: Address (xxxx) not in maps!
cause This error typically indicates that Vivisect's analysis tried to access a memory address that is not part of the loaded binary's memory map. This can happen with malformed binaries, incomplete file loading, or issues during auto-analysis.fixVerify the integrity of the binary file. Ensure the `vw.loadFromFile()` or `vw.loadFromFd()` call is successful before `vw.analyze()`. For unusual binary types, you might need to manually configure memory maps or use a custom loader if the standard parsers (PE, Elf) are insufficient. -
Python 2 workspace not loading in Python 3 Vivisect.
cause Workspaces saved with Python 2 versions of Vivisect (especially using the default 'basicfile' storage, which relies on Python's `pickle`) are not compatible with Python 3 due to fundamental differences in object serialization.fixBefore upgrading to Python 3 Vivisect, use a Python 2 Vivisect installation (v0.2.1) to convert old workspaces to the `msgpack` format. For example, `python2 -m vivisect.storage.tools.convert <old_workspace.viv> --name <new_workspace.mpviv>`. The `msgpack` format is cross-version compatible. -
GUI console not showing typing or interactive shell issues.
cause When running the Vivisect GUI (`vivbin`) from a console, the interactive Python shell or function emulator can sometimes interfere with terminal settings.fixIf the command line stops responding or showing input, try typing `stty sane` and pressing Enter (blindly if necessary) to reset the terminal settings. If multiple emulators/CLIs are active, you may need to reset the console state via `Plugins -> Ion -> Reset Console In Use` if using the VivisectION extension.
Warnings
- breaking Vivisect underwent a significant, backwards-incompatible transition from Python 2 (v0.x.x) to Python 3 (v1.0.0 and above). Old workspaces saved in Python 2's 'basicfile' format are not directly compatible with Python 3 versions.
- breaking Some API signatures changed during the Python 2 to Python 3 migration, notably for memory read/write operations. Scripts written for older Python 2 versions may require adjustments.
- gotcha When installing Vivisect with GUI support on Ubuntu, installing `PyQt5` via `pip install "vivisect[gui]"` might lead to issues.
Install
-
pip install vivisect -
pip install "vivisect[gui]"
Imports
- vivisect
import vivisect
- vivisect.const
import vivisect.const as v_const
- PE
import PE
- Elf
import Elf
Quickstart
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)