#NEWLINE# def filter( self , call_target_state , jumpkind ) : #NEWLINE# #INDENT# '\n        The call will be skipped if it returns True.\n\n        :param call_target_state:   The new state of the call target.\n        :param jumpkind:            The Jumpkind of this call.\n        :returns:                   True if we want to skip this call, False otherwise.\n        ' #NEWLINE# ACCEPT = False #NEWLINE# REJECT = True #NEWLINE# l . debug ( 'Filtering calling target %s' , call_target_state . ip ) #NEWLINE# ip = call_target_state . ip #NEWLINE# if ( self . depth >= 5 ) : #NEWLINE# #INDENT# l . debug ( 'Rejecting target %s - too deep, depth is %d' , ip , self . depth ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# addr = call_target_state . se . exactly_int ( ip ) #NEWLINE# #UNINDENT# except ( SimValueError , SimSolverModeError ) : #NEWLINE# #INDENT# self . _skipped_targets . add ( ( - 1 ) ) #NEWLINE# l . debug ( 'Rejecting target %s - cannot be concretized' , ip ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# if ( addr in self . blacklist ) : #NEWLINE# #INDENT# self . _skipped_targets . add ( addr ) #NEWLINE# l . debug ( 'Rejecting target 0x%x - blacklisted' , addr ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# if ( self . project . is_hooked ( addr ) and ( type ( self . project . _sim_procedures [ addr ] [ 0 ] ) in CallTracingFilter . whitelist ) ) : #NEWLINE# #INDENT# l . debug ( 'Accepting target 0x%x, jumpkind %s' , addr , jumpkind ) #NEWLINE# return ACCEPT #NEWLINE# #UNINDENT# if jumpkind . startswith ( 'Ijk_Sys' ) : #NEWLINE# #INDENT# call_target_state . scratch . jumpkind = jumpkind #NEWLINE# tmp_path = self . project . factory . path ( call_target_state ) #NEWLINE# tmp_path . step ( ) #NEWLINE# next_run = tmp_path . next_run #NEWLINE# if isinstance ( next_run , handler . handler ) : #NEWLINE# #INDENT# syscall = next_run . syscall #NEWLINE# if ( type ( syscall ) in CallTracingFilter . whitelist ) : #NEWLINE# #INDENT# l . debug ( 'Accepting target 0x%x, jumpkind %s' , addr , jumpkind ) #NEWLINE# return ACCEPT #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# l . debug ( 'Rejecting target 0x%x - syscall %s not in whitelist' , addr , syscall ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# l . debug ( 'Rejecting target 0x%x - Unsupported syscall handler %s' , addr , next_run ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# #UNINDENT# cfg_key = ( addr , jumpkind ) #NEWLINE# if ( cfg_key not in self . cfg_cache ) : #NEWLINE# #INDENT# new_blacklist = self . blacklist [ : ] #NEWLINE# new_blacklist . append ( addr ) #NEWLINE# tracing_filter = CallTracingFilter ( self . project , depth = ( self . depth + 1 ) , blacklist = new_blacklist ) #NEWLINE# cfg = self . project . analyses . CFG ( starts = ( ( addr , jumpkind ) , ) , initial_state = call_target_state , context_sensitivity_level = 0 , call_depth = 0 , call_tracing_filter = tracing_filter . filter ) #NEWLINE# self . cfg_cache [ cfg_key ] = ( cfg , tracing_filter ) #NEWLINE# try : #NEWLINE# #INDENT# cfg . unroll_loops ( 1 ) #NEWLINE# #UNINDENT# except AngrCFGError : #NEWLINE# #INDENT# l . debug ( 'Rejecting target 0x%x - loop unrolling failed' , addr ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# l . debug ( 'Loading CFG from CFG cache' ) #NEWLINE# ( cfg , tracing_filter ) = self . cfg_cache [ cfg_key ] #NEWLINE# #UNINDENT# if cfg . _loop_back_edges : #NEWLINE# #INDENT# self . _skipped_targets . add ( addr ) #NEWLINE# l . debug ( 'Rejecting target 0x%x - it has loops' , addr ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# sim_procedures = [ n for n in cfg . graph . nodes ( ) if ( n . simprocedure_name is not None ) ] #NEWLINE# for sp_node in sim_procedures : #NEWLINE# #INDENT# if ( not self . project . is_hooked ( sp_node . addr ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( self . project . _sim_procedures [ sp_node . addr ] [ 0 ] not in CallTracingFilter . whitelist ) : #NEWLINE# #INDENT# self . _skipped_targets . add ( addr ) #NEWLINE# l . debug ( 'Rejecting target 0x%x - contains SimProcedures outside whitelist' , addr ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# #UNINDENT# if len ( tracing_filter . _skipped_targets ) : #NEWLINE# #INDENT# self . _skipped_targets . add ( addr ) #NEWLINE# l . debug ( 'Rejecting target 0x%x - should be skipped' , addr ) #NEWLINE# return REJECT #NEWLINE# #UNINDENT# l . debug ( 'Accepting target 0x%x, jumpkind %s' , addr , jumpkind ) #NEWLINE# return ACCEPT