Binary Ninja Python API Reference¶
Welcome to the Binary Ninja API documentation. The below methods are available from the root of the binaryninja package, but most of the API is organized into the modules shown in the left side-bar.
These pages are intended as an API Reference. For a deeper explanation of how different parts of Binary Ninja work, explanations of concepts, or if you’re new to Binary Ninja, you’ll want to check out our User Guide.
If you’re new to our API, we also have a Developer Guide which covers many of the concepts developers should know. There’s also a Cookbook which contains many examples to get you started using our API.
You can also scroll to the end to view a class list of all available classes.
The search bar on the side works both online and offline.
- exception UIPluginInHeadlessError(*args, **kwargs)[source]¶
Bases:
Exception
Error thrown when trying to load a UI plugin in a headless Binary Ninja installation.
- class CoreVersionInfo(major, minor=None, build=None, channel=None)[source]¶
Bases:
object
Structure representing the Binary Ninja Version.
Use
core_version_info
to look up the current version of Binary Ninja loaded.
- bundled_plugin_path() str | None [source]¶
bundled_plugin_path
returns a string containing the current plugin path inside the install path- Returns:
current bundled plugin path
- Return type:
str, or None on failure
- connect_pycharm_debugger(port=5678)[source]¶
Connect to PyCharm (Professional Edition) for debugging.
Note
See the user documentation for step-by-step instructions on how to set up Python debugging.
- Parameters:
port – Port number for connecting to the debugger.
- connect_vscode_debugger(port=5678)[source]¶
Connect to Visual Studio Code for debugging. This function blocks until the debugger is connected! Not recommended for use in startup.py
Note
See the user documentation for step-by-step instructions on how to set up Python debugging.
- Parameters:
port – Port number for connecting to the debugger.
- core_build_id() int [source]¶
core_build_id
returns a integer containing the current build id- Returns:
current build id
- Return type:
- core_expires() struct_time [source]¶
License Expiration
- Return type:
- core_serial() str | None [source]¶
core_serial
returns a string containing the current serial number- Returns:
current serial
- Return type:
str, or None on failure
- core_set_license(licenseData: str) None [source]¶
core_set_license
is used to initialize the core with a license file that doesn’t necessarily reside on a file system. This is especially useful for headless environments such as docker where loading the license file via an environment variable allows for greater security of the license file itself.- Parameters:
licenseData (str) – string containing the full contents of a license file
- Return type:
None
- Example:
>>> import os >>> core_set_license(os.environ['BNLICENSE']) #Do this before creating any BinaryViews >>> with load("/bin/ls") as bv: ... print(len(list(bv.functions))) 128
- core_ui_enabled() bool [source]¶
Indicates that a UI exists and the UI has invoked BNInitUI
- Return type:
- core_version() str | None [source]¶
core_version
returns a string containing the current version- Returns:
current version
- Return type:
str, or None on failure
- core_version_info() CoreVersionInfo [source]¶
core_version_info
returns a CoreVersionInfo containing the current version information- Returns:
current version information
- Return type:
- disable_default_log() None [source]¶
Disable default logging in headless mode for the current session. By default, logging in headless operation is controlled by the ‘python.log.minLevel’ settings.
- Return type:
None
- fuzzy_match_single(target, query) int | None [source]¶
Fuzzy match a string against a query string. Returns a score that is higher for a more confident match, or None if the query does not match the target string.
- Parameters:
target – Target (larger) string
query – Query (smaller) string
- Returns:
Confidence of match, or None if the string doesn’t match
- Return type:
int | None
- get_install_directory()[source]¶
get_install_directory
returns a string pointing to the installed binary currently runningWarning
ONLY for use within the Binary Ninja UI, behavior is undefined and unreliable if run headlessly
- get_memory_usage_info() Mapping[str, int] [source]¶
Get counts of various Binary Ninja objects in memory.
- load(*args, **kwargs) BinaryView [source]¶
Opens a BinaryView object.
- Parameters:
source (Union[str, bytes, bytearray, 'databuffer.DataBuffer', 'os.PathLike']) – a file or byte stream to load into a virtual memory space
update_analysis (bool) – whether or not to run
update_analysis_and_wait
after opening aBinaryView
, defaults toTrue
progress_func (callback) – optional function to be called with the current progress and total count for BNDB files only
options (dict) – a dictionary in the form {setting identifier string : object value}
- Returns:
returns a
BinaryView
object for the given filename- Return type:
BinaryView
- Raises:
Exception – When a BinaryView could not be created
Note
The progress_func callback must return True to continue the load operation, False will abort the load operation.
Warning
The progress_func will only be called for BNDB files, not for any other file format due to a design limitation.
- Example:
>>> from binaryninja import * >>> with load("/bin/ls") as bv: ... print(len(list(bv.functions))) ... 134
>>> with load(bytes.fromhex('5054ebfe'), options={'loader.platform' : 'x86'}) as bv: ... print(len(list(bv.functions))) ... 1
- Return type:
- shutdown()[source]¶
shutdown
cleanly shuts down the core, stopping all workers and closing all log files.Note
This will be called automatically on script exit if you import the binaryninja module.
- user_directory() str | None [source]¶
user_directory
returns a string containing the path to the user directory- Returns:
current user path
- Return type:
str, or None on failure
- user_plugin_path() str | None [source]¶
user_plugin_path
returns a string containing the current plugin path inside the user directory- Returns:
current user plugin path
- Return type:
str, or None on failure
Full Class List¶
- architecture
- basedetection
- basicblock
- binaryview
ActiveAnalysisInfo
AdvancedILFunctionList
AnalysisCompletionEvent
AnalysisInfo
AnalysisProgress
BinaryDataNotification
BinaryDataNotificationCallbacks
BinaryReader
BinaryView
BinaryViewEvent
BinaryViewType
BinaryWriter
CoreDataVariable
DataVariable
DataVariableAndName
FunctionList
MemoryMap
NotificationType
ReferenceSource
Section
Segment
StringReference
StructuredDataValue
SymbolMapping
Tag
TagType
TypeMapping
TypedDataAccessor
TypedDataReader
- bncompleter
- callingconvention
- collaboration
- commonil
AliasedVariableInstruction
Arithmetic
BaseILInstruction
BinaryOperation
Call
Carry
Comparison
Constant
ControlFlow
DoublePrecision
FloatingPoint
Intrinsic
Load
Localcall
Loop
Memory
Phi
RegisterStack
Return
SSA
SSAVariableInstruction
SetReg
SetVar
Signed
StackOperation
Store
Syscall
Tailcall
Terminal
UnaryOperation
VariableInstruction
- component
- database
- databuffer
- datarender
- debugger
- debuginfo
- decorators
- demangle
- deprecation
- downloadprovider
- enterprise
LicenseCheckout
authenticate_with_credentials
authenticate_with_method
authentication_methods
cancel_authentication
connect
deauthenticate
initialize
is_authenticated
is_connected
is_floating_license
is_initialized
is_license_still_activated
last_error
license_duration
license_expiration_time
release_license
reservation_time_limit
server_build_id
server_id
server_name
server_url
server_version
set_server_url
token
update_license
username
- enums
ActionType
AnalysisMode
AnalysisSkipReason
AnalysisState
AnalysisWarningActionType
BaseAddressDetectionConfidence
BaseAddressDetectionPOISetting
BaseAddressDetectionPOIType
BinaryViewEventType
BranchType
CallingConventionName
CollaborationPermissionLevel
DataFlowQueryOption
DeadStoreElimination
DisassemblyAddressMode
DisassemblyCallParameterHints
DisassemblyOption
EdgePenStyle
Endianness
FindFlag
FindRangeType
FindType
FlagRole
FlowGraphOption
FormInputFieldType
FunctionAnalysisSkipOverride
FunctionGraphType
FunctionUpdateType
HighLevelILOperation
HighlightColorStyle
HighlightStandardColor
ILBranchDependence
ILInstructionAttribute
ImplicitRegisterExtend
InstructionTextTokenContext
InstructionTextTokenType
IntegerDisplayType
IntrinsicClass
LinearDisassemblyLineType
LinearViewObjectIdentifierType
LogLevel
LowLevelILFlagCondition
LowLevelILOperation
MediumLevelILOperation
MemberAccess
MemberScope
MergeConflictDataType
MessageBoxButtonResult
MessageBoxButtonSet
MessageBoxIcon
MetadataType
ModificationStatus
NameType
NamedTypeReferenceClass
PluginCommandType
PluginLoadOrder
PluginLoadStatus
PluginOrigin
PluginStatus
PluginType
PointerBaseType
PointerSuffix
ReferenceType
RegisterValueType
RelocationType
RemoteFileType
ReportType
SaveOption
ScriptingProviderExecuteResult
ScriptingProviderInputReadyState
SectionSemantics
SegmentFlag
SettingsScope
StringType
StructureVariant
SymbolBinding
SymbolType
SyncStatus
TagReferenceType
TagTypeType
ThemeColor
TokenEscapingType
TransformType
TypeClass
TypeContainerType
TypeDefinitionLineType
TypeParserErrorSeverity
TypeParserOption
TypeReferenceType
UpdateResult
VariableSourceType
- exceptions
- externallibrary
- fileaccessor
- filemetadata
- flowgraph
- function
- functionrecognizer
- highlevelil
CoreHighLevelILInstruction
GotoLabel
HighLevelILAdc
HighLevelILAdd
HighLevelILAddOverflow
HighLevelILAddressOf
HighLevelILAnd
HighLevelILArrayIndex
HighLevelILArrayIndexSsa
HighLevelILAsr
HighLevelILAssign
HighLevelILAssignMemSsa
HighLevelILAssignUnpack
HighLevelILAssignUnpackMemSsa
HighLevelILBasicBlock
HighLevelILBinaryBase
HighLevelILBlock
HighLevelILBoolToInt
HighLevelILBp
HighLevelILBreak
HighLevelILCall
HighLevelILCallSsa
HighLevelILCarryBase
HighLevelILCase
HighLevelILCeil
HighLevelILCmpE
HighLevelILCmpNe
HighLevelILCmpSge
HighLevelILCmpSgt
HighLevelILCmpSle
HighLevelILCmpSlt
HighLevelILCmpUge
HighLevelILCmpUgt
HighLevelILCmpUle
HighLevelILCmpUlt
HighLevelILComparisonBase
HighLevelILConst
HighLevelILConstData
HighLevelILConstPtr
HighLevelILContinue
HighLevelILDeref
HighLevelILDerefField
HighLevelILDerefFieldSsa
HighLevelILDerefSsa
HighLevelILDivs
HighLevelILDivsDp
HighLevelILDivu
HighLevelILDivuDp
HighLevelILDoWhile
HighLevelILDoWhileSsa
HighLevelILExternPtr
HighLevelILFabs
HighLevelILFadd
HighLevelILFcmpE
HighLevelILFcmpGe
HighLevelILFcmpGt
HighLevelILFcmpLe
HighLevelILFcmpLt
HighLevelILFcmpNe
HighLevelILFcmpO
HighLevelILFcmpUo
HighLevelILFdiv
HighLevelILFloatConst
HighLevelILFloatConv
HighLevelILFloatToInt
HighLevelILFloor
HighLevelILFmul
HighLevelILFneg
HighLevelILFor
HighLevelILForSsa
HighLevelILFsqrt
HighLevelILFsub
HighLevelILFtrunc
HighLevelILFunction
HighLevelILGoto
HighLevelILIf
HighLevelILImport
HighLevelILInstruction
HighLevelILIntToFloat
HighLevelILIntrinsic
HighLevelILIntrinsicSsa
HighLevelILJump
HighLevelILLabel
HighLevelILLowPart
HighLevelILLsl
HighLevelILLsr
HighLevelILMemPhi
HighLevelILMods
HighLevelILModsDp
HighLevelILModu
HighLevelILModuDp
HighLevelILMul
HighLevelILMulsDp
HighLevelILMuluDp
HighLevelILNeg
HighLevelILNop
HighLevelILNoret
HighLevelILNot
HighLevelILOperationAndSize
HighLevelILOr
HighLevelILRet
HighLevelILRlc
HighLevelILRol
HighLevelILRor
HighLevelILRoundToInt
HighLevelILRrc
HighLevelILSbb
HighLevelILSplit
HighLevelILStructField
HighLevelILSub
HighLevelILSwitch
HighLevelILSx
HighLevelILSyscall
HighLevelILSyscallSsa
HighLevelILTailcall
HighLevelILTestBit
HighLevelILTrap
HighLevelILUnaryBase
HighLevelILUndef
HighLevelILUnimpl
HighLevelILUnimplMem
HighLevelILUnreachable
HighLevelILVar
HighLevelILVarDeclare
HighLevelILVarInit
HighLevelILVarInitSsa
HighLevelILVarPhi
HighLevelILVarSsa
HighLevelILWhile
HighLevelILWhileSsa
HighLevelILXor
HighLevelILZx
VariableReferenceType
- highlight
- interaction
AddressField
ChoiceField
DirectoryNameField
FlowGraphReport
HTMLReport
IntegerField
InteractionHandler
LabelField
MarkdownReport
MultilineTextField
OpenFileNameField
PlainTextReport
ReportCollection
SaveFileNameField
SeparatorField
TextLineField
get_address_input
get_choice_input
get_directory_name_input
get_form_input
get_int_input
get_large_choice_input
get_open_filename_input
get_save_filename_input
get_text_line_input
markdown_to_html
open_url
run_progress_dialog
show_graph_report
show_html_report
show_markdown_report
show_message_box
show_plain_text_report
show_report_collection
- lineardisassembly
- log
- lowlevelil
CoreLowLevelILInstruction
ILFlag
ILIntrinsic
ILRegister
ILRegisterStack
ILSemanticFlagClass
ILSemanticFlagGroup
LowLevelILAdc
LowLevelILAdd
LowLevelILAddOverflow
LowLevelILAnd
LowLevelILAsr
LowLevelILBasicBlock
LowLevelILBinaryBase
LowLevelILBoolToInt
LowLevelILBp
LowLevelILCall
LowLevelILCallOutputSsa
LowLevelILCallParam
LowLevelILCallSsa
LowLevelILCallStackAdjust
LowLevelILCallStackSsa
LowLevelILCarryBase
LowLevelILCeil
LowLevelILCmpE
LowLevelILCmpNe
LowLevelILCmpSge
LowLevelILCmpSgt
LowLevelILCmpSle
LowLevelILCmpSlt
LowLevelILCmpUge
LowLevelILCmpUgt
LowLevelILCmpUle
LowLevelILCmpUlt
LowLevelILComparisonBase
LowLevelILConst
LowLevelILConstPtr
LowLevelILConstantBase
LowLevelILDivs
LowLevelILDivsDp
LowLevelILDivu
LowLevelILDivuDp
LowLevelILExpr
LowLevelILExternPtr
LowLevelILFabs
LowLevelILFadd
LowLevelILFcmpE
LowLevelILFcmpGe
LowLevelILFcmpGt
LowLevelILFcmpLe
LowLevelILFcmpLt
LowLevelILFcmpNe
LowLevelILFcmpO
LowLevelILFcmpUo
LowLevelILFdiv
LowLevelILFlag
LowLevelILFlagBit
LowLevelILFlagBitSsa
LowLevelILFlagCond
LowLevelILFlagGroup
LowLevelILFlagPhi
LowLevelILFlagSsa
LowLevelILFloatConst
LowLevelILFloatConv
LowLevelILFloatToInt
LowLevelILFloor
LowLevelILFmul
LowLevelILFneg
LowLevelILFsqrt
LowLevelILFsub
LowLevelILFtrunc
LowLevelILFunction
LowLevelILGoto
LowLevelILIf
LowLevelILInstruction
LowLevelILIntToFloat
LowLevelILIntrinsic
LowLevelILIntrinsicSsa
LowLevelILJump
LowLevelILJumpTo
LowLevelILLabel
LowLevelILLoad
LowLevelILLoadSsa
LowLevelILLowPart
LowLevelILLsl
LowLevelILLsr
LowLevelILMemPhi
LowLevelILMemoryIntrinsicOutputSsa
LowLevelILMemoryIntrinsicSsa
LowLevelILMods
LowLevelILModsDp
LowLevelILModu
LowLevelILModuDp
LowLevelILMul
LowLevelILMulsDp
LowLevelILMuluDp
LowLevelILNeg
LowLevelILNop
LowLevelILNoret
LowLevelILNot
LowLevelILOperationAndSize
LowLevelILOr
LowLevelILPop
LowLevelILPush
LowLevelILReg
LowLevelILRegPhi
LowLevelILRegSplit
LowLevelILRegSplitDestSsa
LowLevelILRegSplitSsa
LowLevelILRegSsa
LowLevelILRegSsaPartial
LowLevelILRegStackAbsSsa
LowLevelILRegStackDestSsa
LowLevelILRegStackFreeAbsSsa
LowLevelILRegStackFreeReg
LowLevelILRegStackFreeRel
LowLevelILRegStackFreeRelSsa
LowLevelILRegStackPhi
LowLevelILRegStackPop
LowLevelILRegStackPush
LowLevelILRegStackRel
LowLevelILRegStackRelSsa
LowLevelILRet
LowLevelILRlc
LowLevelILRol
LowLevelILRor
LowLevelILRoundToInt
LowLevelILRrc
LowLevelILSbb
LowLevelILSeparateParamListSsa
LowLevelILSetFlag
LowLevelILSetFlagSsa
LowLevelILSetReg
LowLevelILSetRegSplit
LowLevelILSetRegSplitSsa
LowLevelILSetRegSsa
LowLevelILSetRegSsaPartial
LowLevelILSetRegStackAbsSsa
LowLevelILSetRegStackRel
LowLevelILSetRegStackRelSsa
LowLevelILSharedParamSlotSsa
LowLevelILStore
LowLevelILStoreSsa
LowLevelILSub
LowLevelILSx
LowLevelILSyscall
LowLevelILSyscallSsa
LowLevelILTailcall
LowLevelILTailcallSsa
LowLevelILTestBit
LowLevelILTrap
LowLevelILUnaryBase
LowLevelILUndef
LowLevelILUnimpl
LowLevelILUnimplMem
LowLevelILXor
LowLevelILZx
SSAFlag
SSARegister
SSARegisterOrFlag
SSARegisterStack
LLIL_GET_TEMP_REG_INDEX
LLIL_REG_IS_TEMP
LLIL_TEMP
- mainthread
- mediumlevelil
CoreMediumLevelILInstruction
MediumLevelILAdc
MediumLevelILAdd
MediumLevelILAddOverflow
MediumLevelILAddressOf
MediumLevelILAddressOfField
MediumLevelILAnd
MediumLevelILAsr
MediumLevelILBasicBlock
MediumLevelILBinaryBase
MediumLevelILBoolToInt
MediumLevelILBp
MediumLevelILCall
MediumLevelILCallBase
MediumLevelILCallOutput
MediumLevelILCallOutputSsa
MediumLevelILCallParam
MediumLevelILCallParamSsa
MediumLevelILCallSsa
MediumLevelILCallUntyped
MediumLevelILCallUntypedSsa
MediumLevelILCarryBase
MediumLevelILCeil
MediumLevelILCmpE
MediumLevelILCmpNe
MediumLevelILCmpSge
MediumLevelILCmpSgt
MediumLevelILCmpSle
MediumLevelILCmpSlt
MediumLevelILCmpUge
MediumLevelILCmpUgt
MediumLevelILCmpUle
MediumLevelILCmpUlt
MediumLevelILComparisonBase
MediumLevelILConst
MediumLevelILConstBase
MediumLevelILConstData
MediumLevelILConstPtr
MediumLevelILDivs
MediumLevelILDivsDp
MediumLevelILDivu
MediumLevelILDivuDp
MediumLevelILExpr
MediumLevelILExternPtr
MediumLevelILFabs
MediumLevelILFadd
MediumLevelILFcmpE
MediumLevelILFcmpGe
MediumLevelILFcmpGt
MediumLevelILFcmpLe
MediumLevelILFcmpLt
MediumLevelILFcmpNe
MediumLevelILFcmpO
MediumLevelILFcmpUo
MediumLevelILFdiv
MediumLevelILFloatConst
MediumLevelILFloatConv
MediumLevelILFloatToInt
MediumLevelILFloor
MediumLevelILFmul
MediumLevelILFneg
MediumLevelILFreeVarSlot
MediumLevelILFreeVarSlotSsa
MediumLevelILFsqrt
MediumLevelILFsub
MediumLevelILFtrunc
MediumLevelILFunction
MediumLevelILGoto
MediumLevelILIf
MediumLevelILImport
MediumLevelILInstruction
MediumLevelILIntToFloat
MediumLevelILIntrinsic
MediumLevelILIntrinsicSsa
MediumLevelILJump
MediumLevelILJumpTo
MediumLevelILLabel
MediumLevelILLoad
MediumLevelILLoadSsa
MediumLevelILLoadStruct
MediumLevelILLoadStructSsa
MediumLevelILLowPart
MediumLevelILLsl
MediumLevelILLsr
MediumLevelILMemPhi
MediumLevelILMemoryIntrinsicOutputSsa
MediumLevelILMemoryIntrinsicSsa
MediumLevelILMods
MediumLevelILModsDp
MediumLevelILModu
MediumLevelILModuDp
MediumLevelILMul
MediumLevelILMulsDp
MediumLevelILMuluDp
MediumLevelILNeg
MediumLevelILNop
MediumLevelILNoret
MediumLevelILNot
MediumLevelILOperationAndSize
MediumLevelILOr
MediumLevelILRet
MediumLevelILRetHint
MediumLevelILRlc
MediumLevelILRol
MediumLevelILRor
MediumLevelILRoundToInt
MediumLevelILRrc
MediumLevelILSbb
MediumLevelILSeparateParamList
MediumLevelILSetVar
MediumLevelILSetVarAliased
MediumLevelILSetVarAliasedField
MediumLevelILSetVarField
MediumLevelILSetVarSplit
MediumLevelILSetVarSplitSsa
MediumLevelILSetVarSsa
MediumLevelILSetVarSsaField
MediumLevelILSharedParamSlot
MediumLevelILStore
MediumLevelILStoreSsa
MediumLevelILStoreStruct
MediumLevelILStoreStructSsa
MediumLevelILSub
MediumLevelILSx
MediumLevelILSyscall
MediumLevelILSyscallSsa
MediumLevelILSyscallUntyped
MediumLevelILSyscallUntypedSsa
MediumLevelILTailcall
MediumLevelILTailcallSsa
MediumLevelILTailcallUntyped
MediumLevelILTailcallUntypedSsa
MediumLevelILTestBit
MediumLevelILTrap
MediumLevelILUnaryBase
MediumLevelILUndef
MediumLevelILUnimpl
MediumLevelILUnimplMem
MediumLevelILVar
MediumLevelILVarAliased
MediumLevelILVarAliasedField
MediumLevelILVarField
MediumLevelILVarPhi
MediumLevelILVarSplit
MediumLevelILVarSplitSsa
MediumLevelILVarSsa
MediumLevelILVarSsaField
MediumLevelILXor
MediumLevelILZx
SSAVariable
- metadata
- platform
- plugin
- pluginmanager
- project
- scriptingprovider
- secretsprovider
- settings
- transform
- typearchive
- typecontainer
- typelibrary
- typeparser
- typeprinter
- types
ArrayBuilder
ArrayType
BaseStructure
BoolBuilder
BoolType
BoolWithConfidence
CharBuilder
CharType
CoreSymbol
EnumerationBuilder
EnumerationMember
EnumerationType
FloatBuilder
FloatType
FunctionBuilder
FunctionParameter
FunctionType
InheritedStructureMember
IntegerBuilder
IntegerType
MutableTypeBuilder
NameSpace
NamedTypeReferenceBuilder
NamedTypeReferenceType
OffsetWithConfidence
PointerBuilder
PointerType
QualifiedName
RegisterSet
RegisterStackAdjustmentWithConfidence
StructureBuilder
StructureMember
StructureType
Symbol
Type
TypeBuilder
TypeDefinitionLine
TypeFieldReference
TypeReferenceSource
VoidBuilder
VoidType
WideCharBuilder
WideCharType
convert_integer
- undo
- update
- variable
AddressRange
ConstantData
ConstantDataRegisterValue
ConstantPointerRegisterValue
ConstantReference
ConstantRegisterValue
CoreVariable
EntryRegisterValue
ExternalPointerRegisterValue
ImportedAddressRegisterValue
IndirectBranchInfo
LookupTableEntry
ParameterVariables
PossibleValueSet
RegisterValue
ReturnAddressRegisterValue
StackFrameOffsetRegisterValue
StackVariableReference
Undetermined
ValueRange
Variable
VariableNameAndType
- websocketprovider
- workflow