INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Return the result of invoking the atoi simprocedure on str_addr. | def _sim_atoi_inner(self, str_addr, region, base=10, read_length=None):
"""
Return the result of invoking the atoi simprocedure on `str_addr`.
"""
from .. import SIM_PROCEDURES
strtol = SIM_PROCEDURES['libc']['strtol']
return strtol.strtol_inner(str_addr, self.state, re... |
Return the result of invoking the strlen simprocedure on str_addr. | def _sim_strlen(self, str_addr):
"""
Return the result of invoking the strlen simprocedure on `str_addr`.
"""
from .. import SIM_PROCEDURES
strlen = SIM_PROCEDURES['libc']['strlen']
return self.inline_call(strlen, str_addr).ret_expr |
Parse format strings. | def _parse(self, fmt_idx):
"""
Parse format strings.
:param fmt_idx: The index of the (pointer to the) format string in the arguments list.
:returns: A FormatString object which can be used for replacing the format specifiers with arguments or
for scanning ... |
Pre - process an AST for insertion into unicorn. | def _process_value(self, d, from_where):
"""
Pre-process an AST for insertion into unicorn.
:param d: the AST
:param from_where: the ID of the memory region it comes from ('mem' or 'reg')
:returns: the value to be inserted into Unicorn, or None
"""
if len(d.annot... |
This callback is called when unicorn needs to access data that s not yet present in memory. | def _hook_mem_unmapped(self, uc, access, address, size, value, user_data, size_extension=True): #pylint:disable=unused-argument
"""
This callback is called when unicorn needs to access data that's not yet present in memory.
"""
# FIXME check angr hooks at `address`
if size_exten... |
setting unicorn registers | def set_regs(self):
''' setting unicorn registers '''
uc = self.uc
if self.state.arch.qemu_name == 'x86_64':
fs = self.state.solver.eval(self.state.regs.fs)
gs = self.state.solver.eval(self.state.regs.gs)
self.write_msr(fs, 0xC0000100)
self.write_... |
loading registers from unicorn | def get_regs(self):
''' loading registers from unicorn '''
# first, get the ignore list (in case of symbolic registers)
if options.UNICORN_SYM_REGS_SUPPORT in self.state.options:
highest_reg_offset, reg_size = max(self.state.arch.registers.values())
symbolic_list = (ctyp... |
check if this state might be used in unicorn ( has no concrete register ) | def _check_registers(self, report=True):
''' check if this state might be used in unicorn (has no concrete register)'''
for r in self.state.arch.uc_regs.keys():
v = getattr(self.state.regs, r)
processed_v = self._process_value(v, 'reg')
if processed_v is None or proce... |
For each instruction track its stack pointer offset and stack base pointer offset. | def _track_stack_pointers(self):
"""
For each instruction, track its stack pointer offset and stack base pointer offset.
:return: None
"""
regs = {self.project.arch.sp_offset}
if hasattr(self.project.arch, 'bp_offset') and self.project.arch.bp_offset is not None:
... |
Convert a VEX block to an AIL block. | def _convert(self, block_node):
"""
Convert a VEX block to an AIL block.
:param block_node: A BlockNode instance.
:return: An converted AIL block.
:rtype: ailment.Block
"""
if not type(block_node) is BlockNode:
return block_no... |
Simplify all blocks in self. _blocks. | def _simplify_blocks(self, stack_pointer_tracker=None):
"""
Simplify all blocks in self._blocks.
:param stack_pointer_tracker: The RegisterDeltaTracker analysis instance.
:return: None
"""
# First of all, let's simplify blocks one by one
... |
Simplify a single AIL block. | def _simplify_block(self, ail_block, stack_pointer_tracker=None):
"""
Simplify a single AIL block.
:param ailment.Block ail_block: The AIL block to simplify.
:param stack_pointer_tracker: The RegisterDeltaTracker analysis instance.
:return: A simplified ... |
Simplify the entire function. | def _simplify_function(self):
"""
Simplify the entire function.
:return: None
"""
# Computing reaching definitions
rd = self.project.analyses.ReachingDefinitions(func=self.function, func_graph=self.graph, observe_all=True)
simp = self.project.analyses.AILSim... |
Simplify all function call statements. | def _make_callsites(self, stack_pointer_tracker=None):
"""
Simplify all function call statements.
:return: None
"""
# Computing reaching definitions
rd = self.project.analyses.ReachingDefinitions(func=self.function, func_graph=self.graph, observe_all=True)
f... |
Link atoms ( AIL expressions ) in the given block to corresponding variables identified previously. | def _link_variables_on_block(self, block, kb):
"""
Link atoms (AIL expressions) in the given block to corresponding variables identified previously.
:param ailment.Block block: The AIL block to work on.
:return: None
"""
variable_manager = kb.variable... |
Link atoms ( AIL expressions ) in the given expression to corresponding variables identified previously. | def _link_variables_on_expr(self, variable_manager, block, stmt_idx, stmt, expr):
"""
Link atoms (AIL expressions) in the given expression to corresponding variables identified previously.
:param variable_manager: Variable manager of the function.
:param ailment.Block block: AIL bloc... |
Get a class descriptor for the class. | def get_class(self, class_name, init_class=False, step_func=None):
"""
Get a class descriptor for the class.
:param str class_name: Name of class.
:param bool init_class: Whether the class initializer <clinit> should be
executed.
:param func step... |
Get the superclass of the class. | def get_superclass(self, class_):
"""
Get the superclass of the class.
"""
if not class_.is_loaded or class_.superclass_name is None:
return None
return self.get_class(class_.superclass_name) |
Walks up the class hierarchy and returns a list of all classes between base class ( inclusive ) and java. lang. Object ( exclusive ). | def get_class_hierarchy(self, base_class):
"""
Walks up the class hierarchy and returns a list of all classes between
base class (inclusive) and java.lang.Object (exclusive).
"""
classes = [base_class]
while classes[-1] is not None and classes[-1] != "java.lang.Object":
... |
This method simulates the loading of a class by the JVM during which parts of the class ( e. g. static fields ) are initialized. For this we run the class initializer method <clinit > ( if available ) and update the state accordingly. | def init_class(self, class_, step_func=None):
"""
This method simulates the loading of a class by the JVM, during which
parts of the class (e.g. static fields) are initialized. For this, we
run the class initializer method <clinit> (if available) and update
the state accordingly.... |
Get the IRSB object from an address a SimRun or a CFGNode.: param v: Can be one of the following: an address or a CFGNode.: return: The IRSB instance.: rtype: pyvex. IRSB | def _get_irsb(self, v):
"""
Get the IRSB object from an address, a SimRun, or a CFGNode.
:param v: Can be one of the following: an address, or a CFGNode.
:return: The IRSB instance.
:rtype: pyvex.IRSB
"""
if isinstance(v, CFGNode):
v = v.addr
... |
Get address of the basic block or CFG node specified by v.: param v: Can be one of the following: a CFGNode or an address.: return: The address.: rtype: int | def _get_addr(self, v):
"""
Get address of the basic block or CFG node specified by v.
:param v: Can be one of the following: a CFGNode, or an address.
:return: The address.
:rtype: int
"""
if isinstance(v, CFGNode):
return v.addr
elif type(v)... |
Backward slicing. | def _backward_slice(self):
"""
Backward slicing.
We support the following IRStmts:
# WrTmp
# Put
We support the following IRExprs:
# Get
# RdTmp
# Const
:return:
"""
temps = set()
regs = set()
# Retrieve... |
A simplified version of pc_calculate_condition (). Please refer to the documentation of Simplified CCalls above. | def pc_calculate_condition_simple(state, cond, cc_op, cc_dep1, cc_dep2, cc_ndep, platform=None):
"""
A simplified version of pc_calculate_condition(). Please refer to the documentation of Simplified CCalls above.
Limitation: symbolic flags are not supported for now.
"""
if state.solver.symbolic(co... |
Concatenate different flag BVs to a single BV. Currently used for ARM X86 and AMD64.: param nbits: platform size in bits.: param flags_vec: vector of flag BVs and their offset in the resulting BV. | def _concat_flags(nbits, flags_vec):
"""
Concatenate different flag BVs to a single BV. Currently used for ARM, X86
and AMD64.
:param nbits : platform size in bits.
:param flags_vec: vector of flag BVs and their offset in the resulting BV.
:type nbits : int
:type flags_vec : list
... |
RegionSimplifier performs the following simplifications: - Remove redundant Gotos - Remove redundant If/ If - else statements | def _simplify(self):
"""
RegionSimplifier performs the following simplifications:
- Remove redundant Gotos
- Remove redundant If/If-else statements
"""
r = self.region
r = self._simplify_gotos(r)
r = self._simplify_ifs(r)
self.result = r |
Parse a bytes object and create a class object. | def parse(cls, s, **kwargs):
"""
Parse a bytes object and create a class object.
:param bytes s: A bytes object.
:return: A class object.
:rtype: cls
"""
pb2_obj = cls._get_cmsg()
pb2_obj.ParseFromString(s)
return cls.parse_from_c... |
Stores either a single element or a range of elements in the array. | def store_array_elements(self, array, start_idx, data):
"""
Stores either a single element or a range of elements in the array.
:param array: Reference to the array.
:param start_idx: Starting index for the store.
:param data: Either a single value or a list of values.
... |
Loads either a single element or a range of elements from the array. | def load_array_elements(self, array, start_idx, no_of_elements):
"""
Loads either a single element or a range of elements from the array.
:param array: Reference to the array.
:param start_idx: Starting index for the load.
:param no_of_elements: Number of elemen... |
Applies concretization strategies on the index until one of them succeeds. | def _apply_concretization_strategies(self, idx, strategies, action): # pylint: disable=unused-argument
"""
Applies concretization strategies on the index, until one of them succeeds.
"""
for s in strategies:
try:
idxes = s.concretize(self, idx)
ex... |
Concretizes a store index. | def concretize_store_idx(self, idx, strategies=None):
"""
Concretizes a store index.
:param idx: An expression for the index.
:param strategies: A list of concretization strategies (to override the default).
:param min_idx: Minimum value for a concretize... |
Concretizes a load index. | def concretize_load_idx(self, idx, strategies=None):
"""
Concretizes a load index.
:param idx: An expression for the index.
:param strategies: A list of concretization strategies (to override the default).
:param min_idx: Minimum value for a concretized ... |
Make a copy of the CFG. | def copy(self):
"""
Make a copy of the CFG.
:return: A copy of the CFG instance.
:rtype: angr.analyses.CFG
"""
new_cfg = CFGEmulated.__new__(CFGEmulated)
super(CFGEmulated, self).make_copy(new_cfg)
new_cfg._indirect_jump_target_limit = self._indirect_jum... |
Resume a paused or terminated control flow graph recovery. | def resume(self, starts=None, max_steps=None):
"""
Resume a paused or terminated control flow graph recovery.
:param iterable starts: A collection of new starts to resume from. If `starts` is None, we will resume CFG
recovery from where it was paused before.
... |
Forces graph to become acyclic removes all loop back edges and edges between overlapped loop headers and their successors. | def remove_cycles(self):
"""
Forces graph to become acyclic, removes all loop back edges and edges between overlapped loop headers and their
successors.
"""
# loop detection
# only detect loops after potential graph normalization
if not self._loop_back_edges:
... |
Unroll loops for each function. The resulting CFG may still contain loops due to recursion function calls etc. | def unroll_loops(self, max_loop_unrolling_times):
"""
Unroll loops for each function. The resulting CFG may still contain loops due to recursion, function calls, etc.
:param int max_loop_unrolling_times: The maximum iterations of unrolling.
:return: None
"""
if not isin... |
Unroll loops globally. The resulting CFG does not contain any loop but this method is slow on large graphs. | def force_unroll_loops(self, max_loop_unrolling_times):
"""
Unroll loops globally. The resulting CFG does not contain any loop, but this method is slow on large graphs.
:param int max_loop_unrolling_times: The maximum iterations of unrolling.
:return: None
"""
if not is... |
Get all immediate dominators of sub graph from given node upwards. | def immediate_dominators(self, start, target_graph=None):
"""
Get all immediate dominators of sub graph from given node upwards.
:param str start: id of the node to navigate forwards from.
:param networkx.classes.digraph.DiGraph target_graph: graph to analyse, default is self.graph.
... |
Get all immediate postdominators of sub graph from given node upwards. | def immediate_postdominators(self, end, target_graph=None):
"""
Get all immediate postdominators of sub graph from given node upwards.
:param str start: id of the node to navigate forwards from.
:param networkx.classes.digraph.DiGraph target_graph: graph to analyse, default is self.grap... |
Get rid of fake returns ( i. e. Ijk_FakeRet edges ) from this CFG | def remove_fakerets(self):
"""
Get rid of fake returns (i.e., Ijk_FakeRet edges) from this CFG
:return: None
"""
fakeret_edges = [ (src, dst) for src, dst, data in self.graph.edges(data=True)
if data['jumpkind'] == 'Ijk_FakeRet' ]
self.graph.remo... |
Get the topological order of a CFG Node. | def get_topological_order(self, cfg_node):
"""
Get the topological order of a CFG Node.
:param cfg_node: A CFGNode instance.
:return: An integer representing its order, or None if the CFGNode does not exist in the graph.
"""
if not self._quasi_topological_order:
... |
Get a sub - graph out of a bunch of basic block addresses. | def get_subgraph(self, starting_node, block_addresses):
"""
Get a sub-graph out of a bunch of basic block addresses.
:param CFGNode starting_node: The beginning of the subgraph
:param iterable block_addresses: A collection of block addresses that should be included in the subgraph if
... |
Get a sub - graph of a certain function. | def get_function_subgraph(self, start, max_call_depth=None):
"""
Get a sub-graph of a certain function.
:param start: The function start. Currently it should be an integer.
:param max_call_depth: Call depth limit. None indicates no limit.
:return: A CFG instance which is a sub-g... |
Get all CFGNodes that has an out - degree of 0 | def deadends(self):
"""
Get all CFGNodes that has an out-degree of 0
:return: A list of CFGNode instances
:rtype: list
"""
if self.graph is None:
raise AngrCFGError('CFG hasn\'t been generated yet.')
deadends = [i for i in self.graph if self.graph.o... |
Perform a sanity check on parameters passed in to CFG. __init__ (). An AngrCFGError is raised if any parameter fails the sanity check. | def _sanitize_parameters(self):
"""
Perform a sanity check on parameters passed in to CFG.__init__().
An AngrCFGError is raised if any parameter fails the sanity check.
:return: None
"""
# Check additional_edges
if isinstance(self._additional_edges, (list, set, ... |
Get the sorting key of a CFGJob instance. | def _job_sorting_key(self, job):
"""
Get the sorting key of a CFGJob instance.
:param CFGJob job: the CFGJob object.
:return: An integer that determines the order of this job in the queue.
:rtype: int
"""
if self._base_graph is None:
# we don't do so... |
Initialization work. Executed prior to the analysis. | def _pre_analysis(self):
"""
Initialization work. Executed prior to the analysis.
:return: None
"""
# Fill up self._starts
for item in self._starts:
callstack = None
if isinstance(item, tuple):
# (addr, jumpkind)
i... |
A callback method called when the job queue is empty. | def _job_queue_empty(self):
"""
A callback method called when the job queue is empty.
:return: None
"""
self._iteratively_clean_pending_exits()
while self._pending_jobs:
# We don't have any exits remaining. Let's pop out a pending exit
pending_j... |
Obtain a SimState object for a specific address | def _create_initial_state(self, ip, jumpkind):
"""
Obtain a SimState object for a specific address
Fastpath means the CFG generation will work in an IDA-like way, in which it will not try to execute every
single statement in the emulator, but will just do the decoding job. This is much ... |
Retrieve a pending job. | def _get_one_pending_job(self):
"""
Retrieve a pending job.
:return: A CFGJob instance or None
"""
pending_job_key, pending_job = self._pending_jobs.popitem()
pending_job_state = pending_job.state
pending_job_call_stack = pending_job.call_stack
pending_j... |
Process function hints in the binary. | def _process_hints(self, analyzed_addrs):
"""
Process function hints in the binary.
:return: None
"""
# Function hints!
# Now let's see how many new functions we can get here...
while self._pending_function_hints:
f = self._pending_function_hints.pop... |
Post - CFG - construction. | def _post_analysis(self):
"""
Post-CFG-construction.
:return: None
"""
self._make_completed_functions()
new_changes = self._iteratively_analyze_function_features()
functions_do_not_return = new_changes['functions_do_not_return']
self._update_function_cal... |
Before processing a CFGJob. Right now each block is traced at most once. If it is traced more than once we will mark it as should_skip before tracing it. An AngrForwardAnalysisSkipJob exception is raised in order to skip analyzing the job. | def _pre_job_handling(self, job): # pylint:disable=arguments-differ
"""
Before processing a CFGJob.
Right now each block is traced at most once. If it is traced more than once, we will mark it as "should_skip"
before tracing it.
An AngrForwardAnalysisSkipJob exception is raised ... |
Get a collection of successors out of the current job. | def _get_successors(self, job):
"""
Get a collection of successors out of the current job.
:param CFGJob job: The CFGJob instance.
:return: A collection of successors.
:rtype: list
"""
addr = job.addr
sim_successors = job.sim_succ... |
Filter the list of successors | def _post_process_successors(self, input_state, sim_successors, successors):
"""
Filter the list of successors
:param SimState input_state: Input state.
:param SimSuccessors sim_successors: The SimSuccessors instance.
:param list successors: ... |
Post job handling: print debugging information regarding the current job. | def _post_handle_job_debug(self, job, successors):
"""
Post job handling: print debugging information regarding the current job.
:param CFGJob job: The current CFGJob instance.
:param list successors: All successors of the analysis job.
:return: None
"""
si... |
Iteratively update the completed functions set analyze whether each function returns or not and remove pending exits if the callee function does not return. We do this iteratively so that we come to a fixed point in the end. In most cases the number of outer iteration equals to the maximum levels of wrapped functions w... | def _iteratively_clean_pending_exits(self):
"""
Iteratively update the completed functions set, analyze whether each function returns or not, and remove
pending exits if the callee function does not return. We do this iteratively so that we come to a fixed point
in the end. In most cases... |
Remove those pending exits if: a ) they are the return exits of non - returning SimProcedures b ) they are the return exits of non - returning syscalls c ) they are the return exits of non - returning functions | def _clean_pending_exits(self):
"""
Remove those pending exits if:
a) they are the return exits of non-returning SimProcedures
b) they are the return exits of non-returning syscalls
c) they are the return exits of non-returning functions
:return: True if any pending exit... |
Returns a new CFGJob instance for further analysis or None if there is no immediate state to perform the analysis on. | def _handle_successor(self, job, successor, successors):
"""
Returns a new CFGJob instance for further analysis, or None if there is no immediate state to perform the
analysis on.
:param CFGJob job: The current job.
"""
state = successor
all_successor_states = s... |
A block without successors should still be handled so it can be added to the function graph correctly. | def _handle_job_without_successors(self, job, irsb, insn_addrs):
"""
A block without successors should still be handled so it can be added to the function graph correctly.
:param CFGJob job: The current job that do not have any successor.
:param IRSB irsb: The related IRSB.
:... |
For a given state and current location of of execution will update a function by adding the offets of appropriate actions to the stack variable or argument registers for the fnc. | def _handle_actions(self, state, current_run, func, sp_addr, accessed_registers):
"""
For a given state and current location of of execution, will update a function by adding the offets of
appropriate actions to the stack variable or argument registers for the fnc.
:param SimState state... |
Update transition graphs of functions in function manager based on information passed in. | def _update_function_transition_graph(self, src_node_key, dst_node_key, jumpkind='Ijk_Boring', ins_addr=None,
stmt_idx=None, confirmed=None):
"""
Update transition graphs of functions in function manager based on information passed in.
:param str jumpki... |
Update the callsites of functions ( remove return targets ) that are calling functions that are just deemed not returning. | def _update_function_callsites(self, noreturns):
"""
Update the callsites of functions (remove return targets) that are calling functions that are just deemed not
returning.
:param iterable func_addrs: A collection of functions for newly-recovered non-returning functions.
:retur... |
Throw away all successors whose target doesn t make sense | def _filter_insane_successors(self, successors):
"""
Throw away all successors whose target doesn't make sense
This method is called after we resolve an indirect jump using an unreliable method (like, not through one of
the indirect jump resolvers, but through either pure concrete execu... |
Remove those return_from_call edges that actually do not return due to calling some not - returning functions.: return: None | def _remove_non_return_edges(self):
"""
Remove those return_from_call edges that actually do not return due to
calling some not-returning functions.
:return: None
"""
for func in self.kb.functions.values():
graph = func.transition_graph
all_return_... |
Convert each concrete indirect jump target into a SimState. | def _convert_indirect_jump_targets_to_states(job, indirect_jump_targets):
"""
Convert each concrete indirect jump target into a SimState.
:param job: The CFGJob instance.
:param indirect_jump_targets: A collection of concrete jump targets resolved from a indirect j... |
Resolve indirect jumps specified by sim_successors. addr. | def _try_resolving_indirect_jumps(self, sim_successors, cfg_node, func_addr, successors, exception_info, artifacts):
"""
Resolve indirect jumps specified by sim_successors.addr.
:param SimSuccessors sim_successors: The SimSuccessors instance.
:param CFGNode cfg_node: ... |
Try to resolve an indirect jump by slicing backwards | def _backward_slice_indirect(self, cfgnode, sim_successors, current_function_addr):
"""
Try to resolve an indirect jump by slicing backwards
"""
# TODO: make this a real indirect jump resolver under the new paradigm
irsb = sim_successors.artifacts['irsb'] # shorthand
l... |
Symbolically executes from ancestor nodes ( 2 - 5 times removed ) finding paths of execution through the given CFGNode. | def _symbolically_back_traverse(self, current_block, block_artifacts, cfg_node):
"""
Symbolically executes from ancestor nodes (2-5 times removed) finding paths of execution through the given
CFGNode.
:param SimSuccessors current_block: SimSuccessor with address to attempt to navigate t... |
Symbolically execute the first basic block of the specified function then returns it. We prepares the state using the already existing state in fastpath mode ( if avaiable ).: param function_addr: The function address: return: A symbolic state if succeeded None otherwise | def _get_symbolic_function_initial_state(self, function_addr, fastpath_mode_state=None):
"""
Symbolically execute the first basic block of the specified function,
then returns it. We prepares the state using the already existing
state in fastpath mode (if avaiable).
:param functi... |
Scan for constants that might be used as exit targets later and add them into pending_exits. | def _search_for_function_hints(self, successor_state):
"""
Scan for constants that might be used as exit targets later, and add them into pending_exits.
:param SimState successor_state: A successing state.
:return: A list of discovered code addresses.
... |
Create the SimSuccessors instance for a block. | def _get_simsuccessors(self, addr, job, current_function_addr=None):
"""
Create the SimSuccessors instance for a block.
:param int addr: Address of the block.
:param CFGJob job: The CFG job instance with an input state inside.
:param int current_f... |
Creates a new call stack and according to the jumpkind performs appropriate actions. | def _create_new_call_stack(self, addr, all_jobs, job, exit_target, jumpkind):
"""
Creates a new call stack, and according to the jumpkind performs appropriate actions.
:param int addr: Address to create at.
:param Simsuccessors all_jobs: Jobs to get s... |
Create a context - sensitive CFGNode instance for a specific block. | def _create_cfgnode(self, sim_successors, call_stack, func_addr, block_id=None, depth=None, exception_info=None):
"""
Create a context-sensitive CFGNode instance for a specific block.
:param SimSuccessors sim_successors: The SimSuccessors object.
:param CallStack call_stack_suff... |
Loop detection. | def _detect_loops(self, loop_callback=None):
"""
Loop detection.
:param func loop_callback: A callback function for each detected loop backedge.
:return: None
"""
loop_finder = self.project.analyses.LoopFinder(kb=self.kb, normalize=False, fail_fast=self._fail_fast)
... |
Get all immediate dominators of sub graph from given node upwards. | def _immediate_dominators(self, node, target_graph=None, reverse_graph=False):
"""
Get all immediate dominators of sub graph from given node upwards.
:param str node: id of the node to navigate forwards from.
:param networkx.classes.digraph.DiGraph target_graph: graph to analyse, defaul... |
Determine if this SimIRSB has an indirect jump as its exit | def _is_indirect_jump(_, sim_successors):
"""
Determine if this SimIRSB has an indirect jump as its exit
"""
if sim_successors.artifacts['irsb_direct_next']:
# It's a direct jump
return False
default_jumpkind = sim_successors.artifacts['irsb_default_jump... |
Check if the specific address is in one of the executable ranges. | def _is_address_executable(self, address):
"""
Check if the specific address is in one of the executable ranges.
:param int address: The address
:return: True if it's in an executable range, False otherwise
"""
for r in self._executable_address_ranges:
if r[... |
Get where a specific function is called.: param function_address: Address of the target function: return: A list of CFGNodes whose exits include a call/ jump to the given function | def _get_callsites(self, function_address):
"""
Get where a specific function is called.
:param function_address: Address of the target function
:return: A list of CFGNodes whose exits include a call/jump to the given function
"""
all_predecessors =... |
Get the possible ( networkx ) simple paths between two nodes or addresses corresponding to nodes. Input: addresses or node instances Return: a list of lists of nodes representing paths. | def _get_nx_paths(self, begin, end):
"""
Get the possible (networkx) simple paths between two nodes or addresses
corresponding to nodes.
Input: addresses or node instances
Return: a list of lists of nodes representing paths.
"""
if isinstance(begin, int) and isins... |
Perform a quasi - topological sort on an already constructed CFG graph ( a networkx DiGraph ) | def _quasi_topological_sort(self):
"""
Perform a quasi-topological sort on an already constructed CFG graph (a networkx DiGraph)
:return: None
"""
# Clear the existing sorting result
self._quasi_topological_order = {}
ctr = self._graph.number_of_nodes()
... |
Reset the state mode to the given mode and apply the custom state options specified with this analysis. | def _reset_state_mode(self, state, mode):
"""
Reset the state mode to the given mode, and apply the custom state options specified with this analysis.
:param state: The state to work with.
:param str mode: The state mode.
:return: None
"""
state.set_m... |
Mark a certain label as assigned ( to an instruction or a block of data ). | def label_got(self, addr, label):
"""
Mark a certain label as assigned (to an instruction or a block of data).
:param int addr: The address of the label.
:param angr.analyses.reassembler.Label label:
The label that is just assigned.
:return: None
... |
Try to classify an immediate as a pointer. | def _imm_to_ptr(self, imm, operand_type, mnemonic): # pylint:disable=no-self-use,unused-argument
"""
Try to classify an immediate as a pointer.
:param int imm: The immediate to test.
:param int operand_type: Operand type of this operand, can either be IMM or MEM.
:param str mne... |
Get function name from the labels of the very first block.: return: Function name if there is any None otherwise: rtype: string | def name(self):
"""
Get function name from the labels of the very first block.
:return: Function name if there is any, None otherwise
:rtype: string
"""
if self._name is not None:
return self._name
if not self.blocks:
return None
... |
If this function is a PLT entry or not.: return: True if this function is a PLT entry False otherwise: rtype: bool | def is_plt(self):
"""
If this function is a PLT entry or not.
:return: True if this function is a PLT entry, False otherwise
:rtype: bool
"""
if self.section == ".plt":
return True
if not self.blocks:
return False
initial_block =... |
Get the assembly manifest of the procedure. | def assembly(self, comments=False, symbolized=True):
"""
Get the assembly manifest of the procedure.
:param comments:
:param symbolized:
:return: A list of tuples (address, basic block assembly), ordered by basic block addresses
:rtype: list
"""
assembly... |
Get all instruction addresses in the binary. | def instruction_addresses(self):
"""
Get all instruction addresses in the binary.
:return: A list of sorted instruction addresses.
:rtype: list
"""
addrs = [ ]
for b in sorted(self.blocks, key=lambda x: x.addr): # type: BasicBlock
addrs.extend(b.ins... |
Determines if we want to output the function label in assembly. We output the function label only when the original instruction does not output the function label. | def _output_function_label(self):
"""
Determines if we want to output the function label in assembly. We output the function label only when the
original instruction does not output the function label.
:return: True if we should output the function label, False otherwise.
:rtype... |
Reduce the size of this block | def shrink(self, new_size):
"""
Reduce the size of this block
:param int new_size: The new size
:return: None
"""
self.size = new_size
if self.sort == 'string':
self.null_terminated = False # string without the null byte terminator
self._... |
We believe this was a pointer and symbolized it before. Now we want to desymbolize it. | def desymbolize(self):
"""
We believe this was a pointer and symbolized it before. Now we want to desymbolize it.
The following actions are performed:
- Reload content from memory
- Mark the sort as 'unknown'
:return: None
"""
self.sort = 'unknown'
... |
Sometimes there exists a pointer that points to a few bytes before the beginning of a section or a few bytes after the beginning of the section. We take care of that here. | def main_executable_region_limbos_contain(self, addr):
"""
Sometimes there exists a pointer that points to a few bytes before the beginning of a section, or a few bytes
after the beginning of the section. We take care of that here.
:param int addr: The address to check.
:return:... |
Sometimes there exists a pointer that points to a few bytes before the beginning of a section or a few bytes after the beginning of the section. We take care of that here. | def main_nonexecutable_region_limbos_contain(self, addr, tolerance_before=64, tolerance_after=64):
"""
Sometimes there exists a pointer that points to a few bytes before the beginning of a section, or a few bytes
after the beginning of the section. We take care of that here.
:param int ... |
Add a new label to the symbol manager. | def add_label(self, name, addr):
"""
Add a new label to the symbol manager.
:param str name: Name of the label.
:param int addr: Address of the label.
:return: None
"""
# set the label
self._symbolization_needed = True
self.symbol_manager.new_la... |
Insert some assembly code at the specific address. There must be an instruction starting at that address. | def insert_asm(self, addr, asm_code, before_label=False):
"""
Insert some assembly code at the specific address. There must be an instruction starting at that address.
:param int addr: Address of insertion
:param str asm_code: The assembly code to insert
:return: None
""... |
Add a new procedure with specific name and assembly code. | def append_procedure(self, name, asm_code):
"""
Add a new procedure with specific name and assembly code.
:param str name: The name of the new procedure.
:param str asm_code: The assembly code of the procedure
:return: None
"""
proc = Procedure(self, name=name, ... |
Append a new data entry into the binary with specific name content and size. | def append_data(self, name, initial_content, size, readonly=False, sort="unknown"): # pylint:disable=unused-argument
"""
Append a new data entry into the binary with specific name, content, and size.
:param str name: Name of the data entry. Will be used as the label.
:param bytes initi... |
Remove CGC attachments. | def remove_cgc_attachments(self):
"""
Remove CGC attachments.
:return: True if CGC attachments are found and removed, False otherwise
:rtype: bool
"""
cgc_package_list = None
cgc_extended_application = None
for data in self.data:
if data.sor... |
Remove unnecessary functions and data | def remove_unnecessary_stuff(self):
"""
Remove unnecessary functions and data
:return: None
"""
glibc_functions_blacklist = {
'_start',
'_init',
'_fini',
'__gmon_start__',
'__do_global_dtors_aux',
'frame_du... |
Initialize the binary. | def _initialize(self):
"""
Initialize the binary.
:return: None
"""
# figure out section alignments
for section in self.project.loader.main_object.sections:
in_segment = False
for segment in self.project.loader.main_object.segments:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.