workflow module¶
Class | Description |
|---|---|
| |
| |
| |
A simple framework for writing line-oriented command interpreters. |
Activity¶
- classActivity[source]¶
Bases:
objectActivityin Binary Ninja represents an individual analysis or action to be performed on aBinaryVieworFunctionobject.Activities are the fundamental units of execution within a
Workflow. Each Activity encapsulatesa specific task and defines its own behavior, dependencies, and eligibility criteria. Activities areexecuted in the context of anAnalysisContext, which provides access to binary data, analysisstate, and utility functions.
AnalysisContext¶
- classAnalysisContext[source]¶
Bases:
objectAnalysisContextis a proxy object that provides access to the current analysis context,including the associatedBinaryView,Function, and intermediate language (IL)representations. It provides APIs to retrieve and modify the in-progress analysis state and allowsusers to notify the analysis system of any changes or updates.- set_mlil_function(new_func:MediumLevelILFunction,llil_ssa_to_mlil_instr_map:mediumlevelil.LLILSSAToMLILInstructionMapping|None=None,llil_ssa_to_mlil_expr_map:mediumlevelil.LLILSSAToMLILExpressionMapping|None=None)→None[source]¶
Set the Medium Level IL function in the current analysis, giving updatedLow Level IL (SSA) to Medium Level IL instruction and expression mappings.:param new_func: New MLIL function:param llil_ssa_to_mlil_instr_map: Mapping from every LLIL SSA instruction to every MLIL instruction:param llil_ssa_to_mlil_expr_map: Mapping from every LLIL SSA expression to one or more MLIL expressions (first expression will be the primary)
- Parameters:
new_func (MediumLevelILFunction) –
llil_ssa_to_mlil_instr_map (mediumlevelil.LLILSSAToMLILInstructionMapping |None) –
llil_ssa_to_mlil_expr_map (mediumlevelil.LLILSSAToMLILExpressionMapping |None) –
- Return type:
None
- propertybasic_blocks:BasicBlockList¶
function.BasicBlockList of BasicBlocks in the current function (writable)
- propertyhlil:HighLevelILFunction|None¶
HighLevelILFunction used to represent High Level IL (writable)
- propertylifted_il:LowLevelILFunction|None¶
LowLevelILFunction used to represent lifted IL (writable)
- propertyllil:LowLevelILFunction|None¶
LowLevelILFunction used to represent Low Level IL (writable)
- propertymlil:MediumLevelILFunction|None¶
MediumLevelILFunction used to represent Medium Level IL (writable)
- propertyview:BinaryView|None¶
BinaryView for the current AnalysisContext (writable)
Workflow¶
- classWorkflow[source]¶
Bases:
objectclassWorkflowin Binary Ninja defines the set of analyses to perform on a binary,including their dependencies and execution order.Workflows are represented as Directed Acyclic Graphs (DAGs), where each node corresponds toan
Activity(an individual analysis or action). Workflows are used to tailor theanalysis process forBinaryVieworFunctionobjects, providing granularcontrol over analysis tasks at module or function levels.A Workflow starts in an unregistered state, either by creating a new empty Workflow or bycloning an existing one. While unregistered, it is possible to add and remove
Activityobjects, as well as modify the execution strategy. To apply a Workflow to a binary, it must beregistered. Once registered, the Workflow becomes immutable and is available for use.- Example:
# Define the custom activity configurationconfiguration=json.dumps({"name":"analysis.plugins.xorStringDecoder","title":"XOR String Decoder","description":"This analysis step transforms XOR-encoded strings within the current function.","eligibility":{"auto":{"default":False}}})# Clone the meta function workflow for customizationworkflow=Workflow("core.function.metaAnalysis").clone()# Register a new activityworkflow.register_activity(Activity(configuration,action=lambdaanalysis_context:log_warn(f"Decoder running for function:{hex(analysis_context.function.start)}"# Insert decoder logic here :P)))# Insert the new activity before the "generateHighLevelIL" stepworkflow.insert("core.function.generateHighLevelIL",["analysis.plugins.xorStringDecoder"])# Register the modified meta function workflowworkflow.register()
- __init__(name:str='',handle:LP_BNWorkflow|None=None,query_registry:bool=True,object_handle:LP_BNFunction|LP_BNBinaryView|None=None)[source]¶
- activity_roots(activity:Activity|str='')→List[str][source]¶
activity_rootsRetrieve the list of activity roots for the Workflow, or if specified just for the givenactivity.
- assign_subactivities(activity:Activity,activities:List[str]|str)→bool[source]¶
assign_subactivitiesAssign the list ofactivitiesas the new set of children for the specifiedactivity.
- clear()→bool[source]¶
clearRemove all Activity nodes from this Workflow.- Returns:
True on success, False otherwise
- Return type:
- clone(name:str|None=None,activity:Activity|str='')→Workflow[source]¶
cloneClone a new Workflow, copying all Activities and the execution strategy.
- configuration(activity:Activity|str='')→str[source]¶
configurationRetrieve the configuration as an adjacency list in JSON for the Workflow, or if specified just for the givenactivity.- Parameters:
activity (ActivityType) – if specified, return the configuration for the
activity- Returns:
an adjacency list representation of the configuration in JSON
- Return type:
- contains(activity:Activity|str)→bool[source]¶
containsDetermine if an Activity exists in this Workflow.- Parameters:
activity (ActivityType) – the Activity name
- Returns:
True if the Activity exists, False otherwise
- Return type:
- eligibility_settings()→List[str][source]¶
eligibility_settingsRetrieve the list of eligibility settings for the Workflow.
- get_activity(activity:Activity|str)→Activity|None[source]¶
get_activityRetrieve the Activity object for the specifiedactivity.
- graph(activity:Activity|str='',sequential:bool=False,show:bool=True)→FlowGraph|None[source]¶
graphGenerate a FlowGraph object for the current Workflow and optionally show it in the UI.
- insert(activity:Activity|str,activities:List[str]|str)→bool[source]¶
insertInsert the list ofactivitiesbefore the specifiedactivityand at the same level.
- insert_after(activity:Activity|str,activities:List[str]|str)→bool[source]¶
insert_afterInsert the list ofactivitiesafter the specifiedactivityand at the same level.
- register(configuration:str='')→bool[source]¶
registerRegister this Workflow, making it immutable and available for use.
- register_activity(activity:Activity,subactivities:List[Activity|str]=[])→Activity|None[source]¶
register_activityRegister an Activity with this Workflow.
- subactivities(activity:Activity|str='',immediate:bool=True)→List[str][source]¶
subactivitiesRetrieve the list of all activities, or optionally a filtered list.
- propertymachine¶
WorkflowMachine¶
- classWorkflowMachine[source]¶
Bases:
object- __init__(handle:LP_BNFunction|LP_BNBinaryView|None=None)[source]¶
- Parameters:
handle (LP_BNFunction |LP_BNBinaryView |None) –
WorkflowMachineCLI¶
- classWorkflowMachineCLI[source]¶
Bases:
Cmd- __init__(machine:WorkflowMachine)[source]¶
Instantiate a line-oriented interpreter framework.
The optional argument ‘completekey’ is the readline name of acompletion key; it defaults to the Tab key. If completekey isnot None and the readline module is available, command completionis done automatically. The optional arguments stdin and stdoutspecify alternate input and output file objects; if not specified,sys.stdin and sys.stdout are used.
- Parameters:
machine (WorkflowMachine) –
- do_run(line)[source]¶
Run the workflow machine and generate a default configuration if the workflow is not configured.
- precmd(line)[source]¶
Hook method executed just before the command line isinterpreted, but after the input prompt is generated and issued.
- aliases={'b':'breakpoint','c':'resume','d':'dump','h':'halt','l':'log','m':'metrics','o':'override','q':'quit','r':'run','s':'step'}¶
- intro="WelcometotheWorkflowOrchestrator.Type'help'tolistavailablecommands."¶
- prompt='(dechora)'¶