workflow module

binaryninja.workflow.Activity([name, ...])

Activity

binaryninja.workflow.CoreFlowGraph(handle)

binaryninja.workflow.FlowGraph([handle])

class FlowGraph implements a directed flow graph to be shown in the UI.

binaryninja.workflow.Workflow([name, ...])

Workflow A Binary Ninja Workflow is an abstraction of a computational binary analysis pipeline and it provides the extensibility mechanism needed for tailored binary analysis and decompilation.

class Activity(name: str = '', handle: Optional[binaryninja._binaryninjacore.LP_BNActivity] = None, action: Optional[Callable[[Any], None]] = None)[source]

Bases: object

Activity

Parameters
property name

Activity name (read-only)

class Workflow(name: str = '', handle: Optional[binaryninja._binaryninjacore.LP_BNWorkflow] = None, query_registry: bool = True)[source]

Bases: object

Workflow A Binary Ninja Workflow is an abstraction of a computational binary analysis pipeline and it provides the extensibility mechanism needed for tailored binary analysis and decompilation. More specifically, a Workflow is a repository of activities along with a unique strategy to execute them. Binary Ninja provides two Workflows named core.module.defaultAnalysis and core.function.defaultAnalysis which expose the core analysis.

A Workflow starts in the unregistered state from either creating a new empty Workflow, or cloning an existing Workflow. While unregistered it’s possible to add and remove activities, as well as change the execution strategy. In order to use the Workflow on a binary it must be registered. Once registered the Workflow is immutable and available for use.

Currently, Workflows is disabled by default and can be enabled via Settings:

>>> Settings().set_bool('workflows.enable', True)

Retrieve the default Workflow by creating a Workflow object:

>>> Workflow()
<Workflow: core.module.defaultAnalysis>

Retrieve any registered Workflow by name:

>>> list(Workflow)
[<Workflow: core.function.defaultAnalysis>, <Workflow: core.module.defaultAnalysis>]
>>> Workflow('core.module.defaultAnalysis')
<Workflow: core.module.defaultAnalysis>
>>> Workflow('core.function.defaultAnalysis')
<Workflow: core.function.defaultAnalysis>

Create a new Workflow, show it in the UI, modify and then register it. Try it via Open with Options and selecting the new Workflow:

>>> pwf = Workflow().clone("PythonLogWarnWorkflow")
>>> pwf.show_topology()
>>> pwf.register_activity(Activity("PythonLogWarn", action=lambda analysis_context: log_warn("PythonLogWarn Called!")))
>>> pwf.insert("core.function.basicBlockAnalysis", ["PythonLogWarn"])
>>> pwf.register()

Note

Binary Ninja Workflows is currently under development and available as an early feature preview. For additional documentation:

>>> Workflow().show_documentation()
Parameters
  • name (str) –

  • handle (binaryninja._binaryninjacore.LP_BNWorkflow) –

  • query_registry (bool) –

activity_roots(activity: Union[binaryninja.workflow.Activity, str] = '') List[str][source]

activity_roots Retrieve the list of activity roots for the Workflow, or if specified just for the given activity.

Parameters

activity (str) – if specified, return the roots for the activity

Returns

list of root activity names

Return type

list[str]

assign_subactivities(activity: binaryninja.workflow.Activity, activities: List[str]) bool[source]

assign_subactivities Assign the list of activities as the new set of children for the specified activity.

Parameters
  • activity (str) – the Activity node to assign children

  • activities (list[str]) – the list of Activities to assign

Returns

True on success, False otherwise

Return type

bool

clear() bool[source]

clear Remove all Activity nodes from this Workflow.

Returns

True on success, False otherwise

Return type

bool

clone(name: str, activity: Union[binaryninja.workflow.Activity, str] = '') binaryninja.workflow.Workflow[source]

clone Clone a new Workflow, copying all Activities and the execution strategy.

Parameters
  • name (str) – the name for the new Workflow

  • activity (str) – if specified, perform the clone operation using activity as the root

Returns

a new Workflow

Return type

Workflow

configuration(activity: Union[binaryninja.workflow.Activity, str] = '') str[source]

configuration Retrieve the configuration as an adjacency list in JSON for the Workflow, or if specified just for the given activity.

Parameters

activity (ActivityType) – if specified, return the configuration for the activity

Returns

an adjacency list representation of the configuration in JSON

Return type

str

contains(activity: Union[binaryninja.workflow.Activity, str]) bool[source]

contains Determine if an Activity exists in this Workflow.

Parameters

activity (ActivityType) – the Activity name

Returns

True if the Activity exists, False otherwise

Return type

bool

get_activity(activity: Union[binaryninja.workflow.Activity, str]) Optional[binaryninja.workflow.Activity][source]

get_activity Retrieve the Activity object for the specified activity.

Parameters

activity (str) – the Activity name

Returns

the Activity object

Return type

Activity

graph(activity: Union[binaryninja.workflow.Activity, str] = '', sequential: bool = False, show: bool = True) Optional[binaryninja.flowgraph.FlowGraph][source]

graph Generate a FlowGraph object for the current Workflow and optionally show it in the UI.

Parameters
  • activity (str) – if specified, generate the Flowgraph using activity as the root

  • sequential (bool) – whether to generate a Composite or Sequential style graph

  • show (bool) – whether to show the graph in the UI or not

Returns

FlowGraph object on success, None on failure

Return type

FlowGraph

insert(activity: Union[binaryninja.workflow.Activity, str], activities: List[str]) bool[source]

insert Insert the list of activities before the specified activity and at the same level.

Parameters
  • activity (str) – the Activity node for which to insert activities before

  • activities (list[str]) – the list of Activities to insert

Returns

True on success, False otherwise

Return type

bool

register(description: str = '') bool[source]

register Register this Workflow, making it immutable and available for use.

Parameters

description (str) – a JSON description of the Workflow

Returns

True on Success, False otherwise

Return type

bool

register_activity(activity: binaryninja.workflow.Activity, subactivities: List[Union[binaryninja.workflow.Activity, str]] = [], description: str = '') Optional[bool][source]

register_activity Register an Activity with this Workflow.

Parameters
  • activity (Activity) – the Activity to register

  • subactivities (list[str]) – the list of Activities to assign

  • description (str) – a JSON description of the Activity

Returns

True on Success, False otherwise

Return type

bool

remove(activity: Union[binaryninja.workflow.Activity, str]) bool[source]

remove Remove the specified activity.

Parameters

activity (str) – the Activity to remove

Returns

True on success, False otherwise

Return type

bool

replace(activity: Union[binaryninja.workflow.Activity, str], new_activity: List[str]) bool[source]

replace Replace the specified activity.

Parameters
  • activity (str) – the Activity to replace

  • new_activity (list[str]) – the replacement Activity

Returns

True on success, False otherwise

Return type

bool

show_documentation() None[source]

show_documentation Show the Workflows documentation in the UI.

Return type

None

show_metrics() None[source]

show_metrics Not yet implemented.

Return type

None

show_topology() None[source]

show_topology Show the Workflow topology in the UI.

Return type

None

show_trace() None[source]

show_trace Not yet implemented.

Return type

None

subactivities(activity: Union[binaryninja.workflow.Activity, str] = '', immediate: bool = True) List[str][source]

subactivities Retrieve the list of all activities, or optionally a filtered list.

Parameters
  • activity (str) – if specified, return the direct children and optionally the descendants of the activity (includes activity)

  • immediate (bool) – whether to include only direct children of activity or all descendants

Returns

list of activity names

Return type

list[str]

property name: str
property registered: bool

registered Whether this Workflow is registered or not. A Workflow becomes immutable once it is registered.

Type

bool