angr 9.2.192__cp311-cp311-macosx_10_12_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- angr/__init__.py +366 -0
- angr/__main__.py +182 -0
- angr/ail_callable.py +79 -0
- angr/ailment/__init__.py +83 -0
- angr/ailment/block.py +88 -0
- angr/ailment/block_walker.py +856 -0
- angr/ailment/constant.py +3 -0
- angr/ailment/converter_common.py +11 -0
- angr/ailment/converter_pcode.py +648 -0
- angr/ailment/converter_vex.py +829 -0
- angr/ailment/expression.py +1655 -0
- angr/ailment/manager.py +34 -0
- angr/ailment/statement.py +973 -0
- angr/ailment/tagged_object.py +58 -0
- angr/ailment/utils.py +114 -0
- angr/analyses/__init__.py +117 -0
- angr/analyses/analysis.py +429 -0
- angr/analyses/backward_slice.py +686 -0
- angr/analyses/binary_optimizer.py +670 -0
- angr/analyses/bindiff.py +1512 -0
- angr/analyses/boyscout.py +76 -0
- angr/analyses/callee_cleanup_finder.py +74 -0
- angr/analyses/calling_convention/__init__.py +6 -0
- angr/analyses/calling_convention/calling_convention.py +1113 -0
- angr/analyses/calling_convention/fact_collector.py +647 -0
- angr/analyses/calling_convention/utils.py +60 -0
- angr/analyses/cdg.py +189 -0
- angr/analyses/cfg/__init__.py +23 -0
- angr/analyses/cfg/cfb.py +451 -0
- angr/analyses/cfg/cfg.py +74 -0
- angr/analyses/cfg/cfg_arch_options.py +95 -0
- angr/analyses/cfg/cfg_base.py +2954 -0
- angr/analyses/cfg/cfg_emulated.py +3451 -0
- angr/analyses/cfg/cfg_fast.py +5431 -0
- angr/analyses/cfg/cfg_fast_soot.py +662 -0
- angr/analyses/cfg/cfg_job_base.py +203 -0
- angr/analyses/cfg/indirect_jump_resolvers/__init__.py +30 -0
- angr/analyses/cfg/indirect_jump_resolvers/aarch64_macho_got.py +77 -0
- angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +62 -0
- angr/analyses/cfg/indirect_jump_resolvers/amd64_pe_iat.py +51 -0
- angr/analyses/cfg/indirect_jump_resolvers/arm_elf_fast.py +159 -0
- angr/analyses/cfg/indirect_jump_resolvers/const_resolver.py +339 -0
- angr/analyses/cfg/indirect_jump_resolvers/constant_value_manager.py +107 -0
- angr/analyses/cfg/indirect_jump_resolvers/default_resolvers.py +82 -0
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +2490 -0
- angr/analyses/cfg/indirect_jump_resolvers/memload_resolver.py +81 -0
- angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +286 -0
- angr/analyses/cfg/indirect_jump_resolvers/mips_elf_got.py +148 -0
- angr/analyses/cfg/indirect_jump_resolvers/propagator_utils.py +46 -0
- angr/analyses/cfg/indirect_jump_resolvers/resolver.py +74 -0
- angr/analyses/cfg/indirect_jump_resolvers/syscall_resolver.py +92 -0
- angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +88 -0
- angr/analyses/cfg/indirect_jump_resolvers/x86_pe_iat.py +47 -0
- angr/analyses/cfg_slice_to_sink/__init__.py +11 -0
- angr/analyses/cfg_slice_to_sink/cfg_slice_to_sink.py +117 -0
- angr/analyses/cfg_slice_to_sink/graph.py +87 -0
- angr/analyses/cfg_slice_to_sink/transitions.py +27 -0
- angr/analyses/class_identifier.py +63 -0
- angr/analyses/code_tagging.py +123 -0
- angr/analyses/codecave.py +77 -0
- angr/analyses/complete_calling_conventions.py +475 -0
- angr/analyses/congruency_check.py +377 -0
- angr/analyses/data_dep/__init__.py +16 -0
- angr/analyses/data_dep/data_dependency_analysis.py +595 -0
- angr/analyses/data_dep/dep_nodes.py +171 -0
- angr/analyses/data_dep/sim_act_location.py +49 -0
- angr/analyses/datagraph_meta.py +105 -0
- angr/analyses/ddg.py +1670 -0
- angr/analyses/decompiler/__init__.py +41 -0
- angr/analyses/decompiler/ail_simplifier.py +2246 -0
- angr/analyses/decompiler/ailgraph_walker.py +49 -0
- angr/analyses/decompiler/block_io_finder.py +302 -0
- angr/analyses/decompiler/block_similarity.py +199 -0
- angr/analyses/decompiler/block_simplifier.py +397 -0
- angr/analyses/decompiler/callsite_maker.py +579 -0
- angr/analyses/decompiler/ccall_rewriters/__init__.py +9 -0
- angr/analyses/decompiler/ccall_rewriters/amd64_ccalls.py +618 -0
- angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +24 -0
- angr/analyses/decompiler/ccall_rewriters/x86_ccalls.py +354 -0
- angr/analyses/decompiler/clinic.py +3662 -0
- angr/analyses/decompiler/condition_processor.py +1323 -0
- angr/analyses/decompiler/counters/__init__.py +16 -0
- angr/analyses/decompiler/counters/boolean_counter.py +27 -0
- angr/analyses/decompiler/counters/call_counter.py +77 -0
- angr/analyses/decompiler/counters/expression_counters.py +77 -0
- angr/analyses/decompiler/counters/seq_cf_structure_counter.py +63 -0
- angr/analyses/decompiler/decompilation_cache.py +54 -0
- angr/analyses/decompiler/decompilation_options.py +317 -0
- angr/analyses/decompiler/decompiler.py +796 -0
- angr/analyses/decompiler/dephication/__init__.py +6 -0
- angr/analyses/decompiler/dephication/dephication_base.py +100 -0
- angr/analyses/decompiler/dephication/graph_dephication.py +70 -0
- angr/analyses/decompiler/dephication/graph_rewriting.py +112 -0
- angr/analyses/decompiler/dephication/graph_vvar_mapping.py +357 -0
- angr/analyses/decompiler/dephication/rewriting_engine.py +528 -0
- angr/analyses/decompiler/dephication/seqnode_dephication.py +156 -0
- angr/analyses/decompiler/dirty_rewriters/__init__.py +7 -0
- angr/analyses/decompiler/dirty_rewriters/amd64_dirty.py +74 -0
- angr/analyses/decompiler/dirty_rewriters/rewriter_base.py +27 -0
- angr/analyses/decompiler/empty_node_remover.py +212 -0
- angr/analyses/decompiler/expression_narrower.py +290 -0
- angr/analyses/decompiler/goto_manager.py +112 -0
- angr/analyses/decompiler/graph_region.py +441 -0
- angr/analyses/decompiler/jump_target_collector.py +37 -0
- angr/analyses/decompiler/jumptable_entry_condition_rewriter.py +67 -0
- angr/analyses/decompiler/label_collector.py +32 -0
- angr/analyses/decompiler/node_replacer.py +42 -0
- angr/analyses/decompiler/notes/__init__.py +9 -0
- angr/analyses/decompiler/notes/decompilation_note.py +48 -0
- angr/analyses/decompiler/notes/deobfuscated_strings.py +56 -0
- angr/analyses/decompiler/optimization_passes/__init__.py +164 -0
- angr/analyses/decompiler/optimization_passes/base_ptr_save_simplifier.py +157 -0
- angr/analyses/decompiler/optimization_passes/call_stmt_rewriter.py +46 -0
- angr/analyses/decompiler/optimization_passes/code_motion.py +362 -0
- angr/analyses/decompiler/optimization_passes/condition_constprop.py +211 -0
- angr/analyses/decompiler/optimization_passes/const_derefs.py +127 -0
- angr/analyses/decompiler/optimization_passes/const_prop_reverter.py +365 -0
- angr/analyses/decompiler/optimization_passes/cross_jump_reverter.py +106 -0
- angr/analyses/decompiler/optimization_passes/deadblock_remover.py +82 -0
- angr/analyses/decompiler/optimization_passes/determine_load_sizes.py +64 -0
- angr/analyses/decompiler/optimization_passes/div_simplifier.py +425 -0
- angr/analyses/decompiler/optimization_passes/duplication_reverter/__init__.py +5 -0
- angr/analyses/decompiler/optimization_passes/duplication_reverter/ail_merge_graph.py +503 -0
- angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +1221 -0
- angr/analyses/decompiler/optimization_passes/duplication_reverter/errors.py +16 -0
- angr/analyses/decompiler/optimization_passes/duplication_reverter/similarity.py +126 -0
- angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +167 -0
- angr/analyses/decompiler/optimization_passes/eager_std_string_concatenation.py +236 -0
- angr/analyses/decompiler/optimization_passes/eager_std_string_eval.py +186 -0
- angr/analyses/decompiler/optimization_passes/engine_base.py +502 -0
- angr/analyses/decompiler/optimization_passes/expr_op_swapper.py +138 -0
- angr/analyses/decompiler/optimization_passes/flip_boolean_cmp.py +113 -0
- angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +618 -0
- angr/analyses/decompiler/optimization_passes/inlined_strlen_simplifier.py +274 -0
- angr/analyses/decompiler/optimization_passes/ite_expr_converter.py +224 -0
- angr/analyses/decompiler/optimization_passes/ite_region_converter.py +337 -0
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +939 -0
- angr/analyses/decompiler/optimization_passes/mod_simplifier.py +99 -0
- angr/analyses/decompiler/optimization_passes/optimization_pass.py +710 -0
- angr/analyses/decompiler/optimization_passes/peephole_simplifier.py +75 -0
- angr/analyses/decompiler/optimization_passes/register_save_area_simplifier.py +263 -0
- angr/analyses/decompiler/optimization_passes/register_save_area_simplifier_adv.py +198 -0
- angr/analyses/decompiler/optimization_passes/ret_addr_save_simplifier.py +171 -0
- angr/analyses/decompiler/optimization_passes/ret_deduplicator.py +222 -0
- angr/analyses/decompiler/optimization_passes/return_duplicator_base.py +632 -0
- angr/analyses/decompiler/optimization_passes/return_duplicator_high.py +61 -0
- angr/analyses/decompiler/optimization_passes/return_duplicator_low.py +166 -0
- angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +333 -0
- angr/analyses/decompiler/optimization_passes/static_vvar_rewriter.py +336 -0
- angr/analyses/decompiler/optimization_passes/switch_default_case_duplicator.py +166 -0
- angr/analyses/decompiler/optimization_passes/switch_reused_entry_rewriter.py +102 -0
- angr/analyses/decompiler/optimization_passes/tag_slicer.py +41 -0
- angr/analyses/decompiler/optimization_passes/win_stack_canary_simplifier.py +477 -0
- angr/analyses/decompiler/optimization_passes/x86_gcc_getpc_simplifier.py +88 -0
- angr/analyses/decompiler/peephole_optimizations/__init__.py +136 -0
- angr/analyses/decompiler/peephole_optimizations/a_div_const_add_a_mul_n_div_const.py +42 -0
- angr/analyses/decompiler/peephole_optimizations/a_mul_const_div_shr_const.py +38 -0
- angr/analyses/decompiler/peephole_optimizations/a_mul_const_sub_a.py +34 -0
- angr/analyses/decompiler/peephole_optimizations/a_shl_const_sub_a.py +34 -0
- angr/analyses/decompiler/peephole_optimizations/a_sub_a_div.py +25 -0
- angr/analyses/decompiler/peephole_optimizations/a_sub_a_shr_const_shr_const.py +37 -0
- angr/analyses/decompiler/peephole_optimizations/a_sub_a_sub_n.py +23 -0
- angr/analyses/decompiler/peephole_optimizations/arm_cmpf.py +236 -0
- angr/analyses/decompiler/peephole_optimizations/base.py +157 -0
- angr/analyses/decompiler/peephole_optimizations/basepointeroffset_add_n.py +34 -0
- angr/analyses/decompiler/peephole_optimizations/basepointeroffset_and_mask.py +36 -0
- angr/analyses/decompiler/peephole_optimizations/bitwise_or_to_logical_or.py +34 -0
- angr/analyses/decompiler/peephole_optimizations/bool_expr_xor_1.py +27 -0
- angr/analyses/decompiler/peephole_optimizations/bswap.py +142 -0
- angr/analyses/decompiler/peephole_optimizations/cas_intrinsics.py +182 -0
- angr/analyses/decompiler/peephole_optimizations/cmpord_rewriter.py +71 -0
- angr/analyses/decompiler/peephole_optimizations/coalesce_adjacent_shrs.py +39 -0
- angr/analyses/decompiler/peephole_optimizations/coalesce_same_cascading_ifs.py +28 -0
- angr/analyses/decompiler/peephole_optimizations/constant_derefs.py +44 -0
- angr/analyses/decompiler/peephole_optimizations/conv_a_sub0_shr_and.py +69 -0
- angr/analyses/decompiler/peephole_optimizations/conv_shl_shr.py +52 -0
- angr/analyses/decompiler/peephole_optimizations/eager_eval.py +436 -0
- angr/analyses/decompiler/peephole_optimizations/extended_byte_and_mask.py +56 -0
- angr/analyses/decompiler/peephole_optimizations/inlined_memcpy.py +78 -0
- angr/analyses/decompiler/peephole_optimizations/inlined_memset.py +262 -0
- angr/analyses/decompiler/peephole_optimizations/inlined_strcpy.py +217 -0
- angr/analyses/decompiler/peephole_optimizations/inlined_strcpy_consolidation.py +106 -0
- angr/analyses/decompiler/peephole_optimizations/inlined_wcscpy.py +256 -0
- angr/analyses/decompiler/peephole_optimizations/inlined_wcscpy_consolidation.py +296 -0
- angr/analyses/decompiler/peephole_optimizations/invert_negated_logical_conjuction_disjunction.py +50 -0
- angr/analyses/decompiler/peephole_optimizations/modulo_simplifier.py +89 -0
- angr/analyses/decompiler/peephole_optimizations/one_sub_bool.py +33 -0
- angr/analyses/decompiler/peephole_optimizations/optimized_div_simplifier.py +356 -0
- angr/analyses/decompiler/peephole_optimizations/remove_cascading_conversions.py +45 -0
- angr/analyses/decompiler/peephole_optimizations/remove_cxx_destructor_calls.py +32 -0
- angr/analyses/decompiler/peephole_optimizations/remove_empty_if_body.py +46 -0
- angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +47 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_bitmasks.py +125 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_conversions.py +273 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_derefs.py +21 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_ite_branch.py +30 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_ite_comparisons.py +54 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_nots.py +36 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_reinterprets.py +44 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_shifts.py +95 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_shifts_around_comparators.py +115 -0
- angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +85 -0
- angr/analyses/decompiler/peephole_optimizations/rewrite_conv_mul.py +40 -0
- angr/analyses/decompiler/peephole_optimizations/rewrite_cxx_operator_calls.py +90 -0
- angr/analyses/decompiler/peephole_optimizations/rewrite_mips_gp_loads.py +49 -0
- angr/analyses/decompiler/peephole_optimizations/rol_ror.py +130 -0
- angr/analyses/decompiler/peephole_optimizations/sar_to_signed_div.py +143 -0
- angr/analyses/decompiler/peephole_optimizations/shl_to_mul.py +25 -0
- angr/analyses/decompiler/peephole_optimizations/simplify_pc_relative_loads.py +51 -0
- angr/analyses/decompiler/peephole_optimizations/single_bit_cond_to_boolexpr.py +28 -0
- angr/analyses/decompiler/peephole_optimizations/single_bit_xor.py +29 -0
- angr/analyses/decompiler/peephole_optimizations/tidy_stack_addr.py +131 -0
- angr/analyses/decompiler/peephole_optimizations/utils.py +18 -0
- angr/analyses/decompiler/presets/__init__.py +22 -0
- angr/analyses/decompiler/presets/basic.py +36 -0
- angr/analyses/decompiler/presets/fast.py +66 -0
- angr/analyses/decompiler/presets/full.py +76 -0
- angr/analyses/decompiler/presets/malware.py +70 -0
- angr/analyses/decompiler/presets/preset.py +37 -0
- angr/analyses/decompiler/redundant_label_remover.py +141 -0
- angr/analyses/decompiler/region_identifier.py +1319 -0
- angr/analyses/decompiler/region_simplifiers/__init__.py +5 -0
- angr/analyses/decompiler/region_simplifiers/cascading_cond_transformer.py +95 -0
- angr/analyses/decompiler/region_simplifiers/cascading_ifs.py +82 -0
- angr/analyses/decompiler/region_simplifiers/expr_folding.py +838 -0
- angr/analyses/decompiler/region_simplifiers/goto.py +178 -0
- angr/analyses/decompiler/region_simplifiers/if_.py +135 -0
- angr/analyses/decompiler/region_simplifiers/ifelse.py +91 -0
- angr/analyses/decompiler/region_simplifiers/loop.py +143 -0
- angr/analyses/decompiler/region_simplifiers/node_address_finder.py +24 -0
- angr/analyses/decompiler/region_simplifiers/region_simplifier.py +270 -0
- angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +654 -0
- angr/analyses/decompiler/region_simplifiers/switch_expr_simplifier.py +87 -0
- angr/analyses/decompiler/region_walker.py +24 -0
- angr/analyses/decompiler/return_maker.py +72 -0
- angr/analyses/decompiler/semantic_naming/__init__.py +37 -0
- angr/analyses/decompiler/semantic_naming/array_index_naming.py +196 -0
- angr/analyses/decompiler/semantic_naming/boolean_naming.py +264 -0
- angr/analyses/decompiler/semantic_naming/call_result_naming.py +220 -0
- angr/analyses/decompiler/semantic_naming/naming_base.py +166 -0
- angr/analyses/decompiler/semantic_naming/orchestrator.py +107 -0
- angr/analyses/decompiler/semantic_naming/pointer_naming.py +334 -0
- angr/analyses/decompiler/semantic_naming/region_loop_counter_naming.py +246 -0
- angr/analyses/decompiler/semantic_naming/size_naming.py +137 -0
- angr/analyses/decompiler/seq_to_blocks.py +20 -0
- angr/analyses/decompiler/sequence_walker.py +261 -0
- angr/analyses/decompiler/ssailification/__init__.py +4 -0
- angr/analyses/decompiler/ssailification/rewriting.py +451 -0
- angr/analyses/decompiler/ssailification/rewriting_engine.py +1091 -0
- angr/analyses/decompiler/ssailification/rewriting_state.py +61 -0
- angr/analyses/decompiler/ssailification/ssailification.py +283 -0
- angr/analyses/decompiler/ssailification/traversal.py +127 -0
- angr/analyses/decompiler/ssailification/traversal_engine.py +323 -0
- angr/analyses/decompiler/ssailification/traversal_state.py +48 -0
- angr/analyses/decompiler/stack_item.py +36 -0
- angr/analyses/decompiler/structured_codegen/__init__.py +25 -0
- angr/analyses/decompiler/structured_codegen/base.py +193 -0
- angr/analyses/decompiler/structured_codegen/c.py +4257 -0
- angr/analyses/decompiler/structured_codegen/dummy.py +15 -0
- angr/analyses/decompiler/structured_codegen/dwarf_import.py +190 -0
- angr/analyses/decompiler/structuring/__init__.py +30 -0
- angr/analyses/decompiler/structuring/dream.py +1217 -0
- angr/analyses/decompiler/structuring/phoenix.py +3636 -0
- angr/analyses/decompiler/structuring/recursive_structurer.py +187 -0
- angr/analyses/decompiler/structuring/sailr.py +120 -0
- angr/analyses/decompiler/structuring/structurer_base.py +1140 -0
- angr/analyses/decompiler/structuring/structurer_nodes.py +442 -0
- angr/analyses/decompiler/utils.py +1224 -0
- angr/analyses/deobfuscator/__init__.py +23 -0
- angr/analyses/deobfuscator/api_obf_finder.py +333 -0
- angr/analyses/deobfuscator/api_obf_peephole_optimizer.py +80 -0
- angr/analyses/deobfuscator/api_obf_type2_finder.py +166 -0
- angr/analyses/deobfuscator/data_transformation_embedder.py +633 -0
- angr/analyses/deobfuscator/hash_lookup_api_deobfuscator.py +156 -0
- angr/analyses/deobfuscator/irsb_reg_collector.py +54 -0
- angr/analyses/deobfuscator/scope_ops_analyzer.py +68 -0
- angr/analyses/deobfuscator/string_obf_finder.py +983 -0
- angr/analyses/deobfuscator/string_obf_opt_passes.py +136 -0
- angr/analyses/deobfuscator/string_obf_peephole_optimizer.py +47 -0
- angr/analyses/disassembly.py +1351 -0
- angr/analyses/disassembly_utils.py +101 -0
- angr/analyses/dominance_frontier.py +57 -0
- angr/analyses/fcp/__init__.py +4 -0
- angr/analyses/fcp/fcp.py +427 -0
- angr/analyses/find_objects_static.py +205 -0
- angr/analyses/flirt/__init__.py +47 -0
- angr/analyses/flirt/consts.py +160 -0
- angr/analyses/flirt/flirt.py +249 -0
- angr/analyses/flirt/flirt_function.py +20 -0
- angr/analyses/flirt/flirt_matcher.py +352 -0
- angr/analyses/flirt/flirt_module.py +32 -0
- angr/analyses/flirt/flirt_node.py +23 -0
- angr/analyses/flirt/flirt_sig.py +359 -0
- angr/analyses/flirt/flirt_utils.py +31 -0
- angr/analyses/forward_analysis/__init__.py +12 -0
- angr/analyses/forward_analysis/forward_analysis.py +619 -0
- angr/analyses/forward_analysis/job_info.py +64 -0
- angr/analyses/forward_analysis/visitors/__init__.py +14 -0
- angr/analyses/forward_analysis/visitors/call_graph.py +29 -0
- angr/analyses/forward_analysis/visitors/function_graph.py +86 -0
- angr/analyses/forward_analysis/visitors/graph.py +242 -0
- angr/analyses/forward_analysis/visitors/loop.py +29 -0
- angr/analyses/forward_analysis/visitors/single_node_graph.py +38 -0
- angr/analyses/identifier/__init__.py +5 -0
- angr/analyses/identifier/custom_callable.py +137 -0
- angr/analyses/identifier/errors.py +10 -0
- angr/analyses/identifier/func.py +60 -0
- angr/analyses/identifier/functions/__init__.py +37 -0
- angr/analyses/identifier/functions/atoi.py +73 -0
- angr/analyses/identifier/functions/based_atoi.py +125 -0
- angr/analyses/identifier/functions/fdprintf.py +123 -0
- angr/analyses/identifier/functions/free.py +64 -0
- angr/analyses/identifier/functions/int2str.py +287 -0
- angr/analyses/identifier/functions/malloc.py +111 -0
- angr/analyses/identifier/functions/memcmp.py +67 -0
- angr/analyses/identifier/functions/memcpy.py +89 -0
- angr/analyses/identifier/functions/memset.py +43 -0
- angr/analyses/identifier/functions/printf.py +123 -0
- angr/analyses/identifier/functions/recv_until.py +312 -0
- angr/analyses/identifier/functions/skip_calloc.py +73 -0
- angr/analyses/identifier/functions/skip_realloc.py +97 -0
- angr/analyses/identifier/functions/skip_recv_n.py +105 -0
- angr/analyses/identifier/functions/snprintf.py +112 -0
- angr/analyses/identifier/functions/sprintf.py +116 -0
- angr/analyses/identifier/functions/strcasecmp.py +33 -0
- angr/analyses/identifier/functions/strcmp.py +113 -0
- angr/analyses/identifier/functions/strcpy.py +43 -0
- angr/analyses/identifier/functions/strlen.py +27 -0
- angr/analyses/identifier/functions/strncmp.py +104 -0
- angr/analyses/identifier/functions/strncpy.py +65 -0
- angr/analyses/identifier/functions/strtol.py +89 -0
- angr/analyses/identifier/identify.py +825 -0
- angr/analyses/identifier/runner.py +360 -0
- angr/analyses/init_finder.py +289 -0
- angr/analyses/loop_analysis/__init__.py +4 -0
- angr/analyses/loop_analysis/loop_analysis.py +464 -0
- angr/analyses/loop_analysis.py +349 -0
- angr/analyses/loop_unroller/__init__.py +4 -0
- angr/analyses/loop_unroller/loop_unroller.py +222 -0
- angr/analyses/loopfinder.py +171 -0
- angr/analyses/outliner/__init__.py +7 -0
- angr/analyses/outliner/outliner.py +402 -0
- angr/analyses/patchfinder.py +137 -0
- angr/analyses/pathfinder.py +282 -0
- angr/analyses/propagator/__init__.py +5 -0
- angr/analyses/propagator/engine_base.py +62 -0
- angr/analyses/propagator/engine_vex.py +297 -0
- angr/analyses/propagator/propagator.py +361 -0
- angr/analyses/propagator/top_checker_mixin.py +218 -0
- angr/analyses/propagator/values.py +117 -0
- angr/analyses/propagator/vex_vars.py +68 -0
- angr/analyses/proximity_graph.py +444 -0
- angr/analyses/purity/__init__.py +15 -0
- angr/analyses/purity/analysis.py +78 -0
- angr/analyses/purity/engine.py +593 -0
- angr/analyses/reaching_definitions/__init__.py +67 -0
- angr/analyses/reaching_definitions/call_trace.py +73 -0
- angr/analyses/reaching_definitions/dep_graph.py +433 -0
- angr/analyses/reaching_definitions/engine_ail.py +1128 -0
- angr/analyses/reaching_definitions/engine_vex.py +1128 -0
- angr/analyses/reaching_definitions/external_codeloc.py +0 -0
- angr/analyses/reaching_definitions/function_handler.py +639 -0
- angr/analyses/reaching_definitions/function_handler_library/__init__.py +12 -0
- angr/analyses/reaching_definitions/function_handler_library/stdio.py +269 -0
- angr/analyses/reaching_definitions/function_handler_library/stdlib.py +195 -0
- angr/analyses/reaching_definitions/function_handler_library/string.py +158 -0
- angr/analyses/reaching_definitions/function_handler_library/unistd.py +51 -0
- angr/analyses/reaching_definitions/heap_allocator.py +70 -0
- angr/analyses/reaching_definitions/rd_initializer.py +237 -0
- angr/analyses/reaching_definitions/rd_state.py +579 -0
- angr/analyses/reaching_definitions/reaching_definitions.py +581 -0
- angr/analyses/reaching_definitions/subject.py +65 -0
- angr/analyses/reassembler.py +2900 -0
- angr/analyses/s_liveness.py +254 -0
- angr/analyses/s_propagator.py +575 -0
- angr/analyses/s_reaching_definitions/__init__.py +12 -0
- angr/analyses/s_reaching_definitions/s_rda_model.py +145 -0
- angr/analyses/s_reaching_definitions/s_rda_view.py +344 -0
- angr/analyses/s_reaching_definitions/s_reaching_definitions.py +230 -0
- angr/analyses/smc.py +160 -0
- angr/analyses/soot_class_hierarchy.py +273 -0
- angr/analyses/stack_pointer_tracker.py +954 -0
- angr/analyses/static_hooker.py +53 -0
- angr/analyses/typehoon/__init__.py +5 -0
- angr/analyses/typehoon/dfa.py +118 -0
- angr/analyses/typehoon/lifter.py +133 -0
- angr/analyses/typehoon/simple_solver.py +2009 -0
- angr/analyses/typehoon/translator.py +283 -0
- angr/analyses/typehoon/typeconsts.py +439 -0
- angr/analyses/typehoon/typehoon.py +338 -0
- angr/analyses/typehoon/typevars.py +633 -0
- angr/analyses/typehoon/variance.py +11 -0
- angr/analyses/unpacker/__init__.py +6 -0
- angr/analyses/unpacker/obfuscation_detector.py +103 -0
- angr/analyses/unpacker/packing_detector.py +138 -0
- angr/analyses/variable_recovery/__init__.py +9 -0
- angr/analyses/variable_recovery/annotations.py +58 -0
- angr/analyses/variable_recovery/engine_ail.py +978 -0
- angr/analyses/variable_recovery/engine_base.py +1256 -0
- angr/analyses/variable_recovery/engine_vex.py +594 -0
- angr/analyses/variable_recovery/irsb_scanner.py +143 -0
- angr/analyses/variable_recovery/variable_recovery.py +574 -0
- angr/analyses/variable_recovery/variable_recovery_base.py +489 -0
- angr/analyses/variable_recovery/variable_recovery_fast.py +669 -0
- angr/analyses/veritesting.py +626 -0
- angr/analyses/vfg.py +1898 -0
- angr/analyses/vsa_ddg.py +420 -0
- angr/analyses/vtable.py +92 -0
- angr/analyses/xrefs.py +286 -0
- angr/angrdb/__init__.py +14 -0
- angr/angrdb/db.py +215 -0
- angr/angrdb/models.py +184 -0
- angr/angrdb/serializers/__init__.py +10 -0
- angr/angrdb/serializers/cfg_model.py +41 -0
- angr/angrdb/serializers/comments.py +60 -0
- angr/angrdb/serializers/funcs.py +61 -0
- angr/angrdb/serializers/kb.py +111 -0
- angr/angrdb/serializers/labels.py +59 -0
- angr/angrdb/serializers/loader.py +165 -0
- angr/angrdb/serializers/structured_code.py +167 -0
- angr/angrdb/serializers/variables.py +58 -0
- angr/angrdb/serializers/xrefs.py +48 -0
- angr/annocfg.py +317 -0
- angr/blade.py +431 -0
- angr/block.py +509 -0
- angr/callable.py +176 -0
- angr/calling_conventions.py +2613 -0
- angr/code_location.py +249 -0
- angr/codenode.py +145 -0
- angr/concretization_strategies/__init__.py +32 -0
- angr/concretization_strategies/any.py +17 -0
- angr/concretization_strategies/any_named.py +35 -0
- angr/concretization_strategies/base.py +81 -0
- angr/concretization_strategies/controlled_data.py +58 -0
- angr/concretization_strategies/eval.py +19 -0
- angr/concretization_strategies/logging.py +35 -0
- angr/concretization_strategies/max.py +25 -0
- angr/concretization_strategies/nonzero.py +16 -0
- angr/concretization_strategies/nonzero_range.py +22 -0
- angr/concretization_strategies/norepeats.py +37 -0
- angr/concretization_strategies/norepeats_range.py +37 -0
- angr/concretization_strategies/range.py +19 -0
- angr/concretization_strategies/signed_add.py +31 -0
- angr/concretization_strategies/single.py +15 -0
- angr/concretization_strategies/solutions.py +20 -0
- angr/concretization_strategies/unlimited_range.py +17 -0
- angr/distributed/__init__.py +9 -0
- angr/distributed/server.py +197 -0
- angr/distributed/worker.py +185 -0
- angr/emulator.py +144 -0
- angr/engines/__init__.py +69 -0
- angr/engines/ail/__init__.py +16 -0
- angr/engines/ail/callstack.py +58 -0
- angr/engines/ail/engine_light.py +903 -0
- angr/engines/ail/engine_successors.py +24 -0
- angr/engines/ail/setup.py +57 -0
- angr/engines/concrete.py +66 -0
- angr/engines/engine.py +29 -0
- angr/engines/failure.py +27 -0
- angr/engines/hook.py +93 -0
- angr/engines/icicle.py +294 -0
- angr/engines/light/__init__.py +23 -0
- angr/engines/light/data.py +681 -0
- angr/engines/light/engine.py +1297 -0
- angr/engines/pcode/__init__.py +9 -0
- angr/engines/pcode/behavior.py +998 -0
- angr/engines/pcode/cc.py +148 -0
- angr/engines/pcode/emulate.py +440 -0
- angr/engines/pcode/engine.py +242 -0
- angr/engines/pcode/lifter.py +1428 -0
- angr/engines/procedure.py +70 -0
- angr/engines/soot/__init__.py +5 -0
- angr/engines/soot/engine.py +410 -0
- angr/engines/soot/exceptions.py +17 -0
- angr/engines/soot/expressions/__init__.py +87 -0
- angr/engines/soot/expressions/arrayref.py +22 -0
- angr/engines/soot/expressions/base.py +21 -0
- angr/engines/soot/expressions/binop.py +28 -0
- angr/engines/soot/expressions/cast.py +22 -0
- angr/engines/soot/expressions/condition.py +35 -0
- angr/engines/soot/expressions/constants.py +47 -0
- angr/engines/soot/expressions/instanceOf.py +15 -0
- angr/engines/soot/expressions/instancefieldref.py +8 -0
- angr/engines/soot/expressions/invoke.py +114 -0
- angr/engines/soot/expressions/length.py +8 -0
- angr/engines/soot/expressions/local.py +8 -0
- angr/engines/soot/expressions/new.py +16 -0
- angr/engines/soot/expressions/newArray.py +54 -0
- angr/engines/soot/expressions/newMultiArray.py +86 -0
- angr/engines/soot/expressions/paramref.py +8 -0
- angr/engines/soot/expressions/phi.py +30 -0
- angr/engines/soot/expressions/staticfieldref.py +8 -0
- angr/engines/soot/expressions/thisref.py +7 -0
- angr/engines/soot/expressions/unsupported.py +7 -0
- angr/engines/soot/field_dispatcher.py +46 -0
- angr/engines/soot/method_dispatcher.py +46 -0
- angr/engines/soot/statements/__init__.py +44 -0
- angr/engines/soot/statements/assign.py +30 -0
- angr/engines/soot/statements/base.py +79 -0
- angr/engines/soot/statements/goto.py +14 -0
- angr/engines/soot/statements/identity.py +15 -0
- angr/engines/soot/statements/if_.py +19 -0
- angr/engines/soot/statements/invoke.py +12 -0
- angr/engines/soot/statements/return_.py +20 -0
- angr/engines/soot/statements/switch.py +41 -0
- angr/engines/soot/statements/throw.py +15 -0
- angr/engines/soot/values/__init__.py +38 -0
- angr/engines/soot/values/arrayref.py +122 -0
- angr/engines/soot/values/base.py +7 -0
- angr/engines/soot/values/constants.py +18 -0
- angr/engines/soot/values/instancefieldref.py +44 -0
- angr/engines/soot/values/local.py +18 -0
- angr/engines/soot/values/paramref.py +18 -0
- angr/engines/soot/values/staticfieldref.py +38 -0
- angr/engines/soot/values/strref.py +38 -0
- angr/engines/soot/values/thisref.py +149 -0
- angr/engines/successors.py +608 -0
- angr/engines/syscall.py +51 -0
- angr/engines/unicorn.py +490 -0
- angr/engines/vex/__init__.py +20 -0
- angr/engines/vex/claripy/__init__.py +5 -0
- angr/engines/vex/claripy/ccall.py +2097 -0
- angr/engines/vex/claripy/datalayer.py +141 -0
- angr/engines/vex/claripy/irop.py +1276 -0
- angr/engines/vex/heavy/__init__.py +16 -0
- angr/engines/vex/heavy/actions.py +231 -0
- angr/engines/vex/heavy/concretizers.py +403 -0
- angr/engines/vex/heavy/dirty.py +466 -0
- angr/engines/vex/heavy/heavy.py +370 -0
- angr/engines/vex/heavy/inspect.py +52 -0
- angr/engines/vex/heavy/resilience.py +85 -0
- angr/engines/vex/heavy/super_fastpath.py +34 -0
- angr/engines/vex/lifter.py +420 -0
- angr/engines/vex/light/__init__.py +11 -0
- angr/engines/vex/light/light.py +551 -0
- angr/engines/vex/light/resilience.py +74 -0
- angr/engines/vex/light/slicing.py +52 -0
- angr/errors.py +611 -0
- angr/exploration_techniques/__init__.py +53 -0
- angr/exploration_techniques/base.py +126 -0
- angr/exploration_techniques/bucketizer.py +94 -0
- angr/exploration_techniques/common.py +56 -0
- angr/exploration_techniques/dfs.py +37 -0
- angr/exploration_techniques/director.py +520 -0
- angr/exploration_techniques/driller_core.py +100 -0
- angr/exploration_techniques/explorer.py +152 -0
- angr/exploration_techniques/lengthlimiter.py +22 -0
- angr/exploration_techniques/local_loop_seer.py +65 -0
- angr/exploration_techniques/loop_seer.py +236 -0
- angr/exploration_techniques/manual_mergepoint.py +82 -0
- angr/exploration_techniques/memory_watcher.py +43 -0
- angr/exploration_techniques/oppologist.py +92 -0
- angr/exploration_techniques/slicecutor.py +118 -0
- angr/exploration_techniques/spiller.py +280 -0
- angr/exploration_techniques/spiller_db.py +27 -0
- angr/exploration_techniques/stochastic.py +56 -0
- angr/exploration_techniques/stub_stasher.py +19 -0
- angr/exploration_techniques/suggestions.py +159 -0
- angr/exploration_techniques/tech_builder.py +49 -0
- angr/exploration_techniques/threading.py +69 -0
- angr/exploration_techniques/timeout.py +34 -0
- angr/exploration_techniques/tracer.py +1098 -0
- angr/exploration_techniques/unique.py +106 -0
- angr/exploration_techniques/veritesting.py +37 -0
- angr/factory.py +413 -0
- angr/flirt/__init__.py +124 -0
- angr/flirt/build_sig.py +305 -0
- angr/graph_utils.py +0 -0
- angr/keyed_region.py +525 -0
- angr/knowledge_base.py +146 -0
- angr/knowledge_plugins/__init__.py +43 -0
- angr/knowledge_plugins/callsite_prototypes.py +95 -0
- angr/knowledge_plugins/cfg/__init__.py +18 -0
- angr/knowledge_plugins/cfg/cfg_manager.py +95 -0
- angr/knowledge_plugins/cfg/cfg_model.py +1043 -0
- angr/knowledge_plugins/cfg/cfg_node.py +536 -0
- angr/knowledge_plugins/cfg/indirect_jump.py +131 -0
- angr/knowledge_plugins/cfg/memory_data.py +156 -0
- angr/knowledge_plugins/comments.py +16 -0
- angr/knowledge_plugins/custom_strings.py +38 -0
- angr/knowledge_plugins/data.py +22 -0
- angr/knowledge_plugins/debug_variables.py +216 -0
- angr/knowledge_plugins/functions/__init__.py +9 -0
- angr/knowledge_plugins/functions/function.py +1830 -0
- angr/knowledge_plugins/functions/function_manager.py +621 -0
- angr/knowledge_plugins/functions/function_parser.py +360 -0
- angr/knowledge_plugins/functions/soot_function.py +128 -0
- angr/knowledge_plugins/indirect_jumps.py +35 -0
- angr/knowledge_plugins/key_definitions/__init__.py +17 -0
- angr/knowledge_plugins/key_definitions/atoms.py +374 -0
- angr/knowledge_plugins/key_definitions/constants.py +29 -0
- angr/knowledge_plugins/key_definitions/definition.py +216 -0
- angr/knowledge_plugins/key_definitions/environment.py +96 -0
- angr/knowledge_plugins/key_definitions/heap_address.py +33 -0
- angr/knowledge_plugins/key_definitions/key_definition_manager.py +82 -0
- angr/knowledge_plugins/key_definitions/live_definitions.py +1020 -0
- angr/knowledge_plugins/key_definitions/liveness.py +165 -0
- angr/knowledge_plugins/key_definitions/rd_model.py +171 -0
- angr/knowledge_plugins/key_definitions/tag.py +78 -0
- angr/knowledge_plugins/key_definitions/undefined.py +70 -0
- angr/knowledge_plugins/key_definitions/unknown_size.py +86 -0
- angr/knowledge_plugins/key_definitions/uses.py +178 -0
- angr/knowledge_plugins/labels.py +110 -0
- angr/knowledge_plugins/obfuscations.py +40 -0
- angr/knowledge_plugins/patches.py +126 -0
- angr/knowledge_plugins/plugin.py +24 -0
- angr/knowledge_plugins/propagations/__init__.py +10 -0
- angr/knowledge_plugins/propagations/prop_value.py +191 -0
- angr/knowledge_plugins/propagations/propagation_manager.py +60 -0
- angr/knowledge_plugins/propagations/propagation_model.py +80 -0
- angr/knowledge_plugins/propagations/states.py +552 -0
- angr/knowledge_plugins/structured_code.py +63 -0
- angr/knowledge_plugins/types.py +95 -0
- angr/knowledge_plugins/variables/__init__.py +8 -0
- angr/knowledge_plugins/variables/variable_access.py +113 -0
- angr/knowledge_plugins/variables/variable_manager.py +1375 -0
- angr/knowledge_plugins/xrefs/__init__.py +12 -0
- angr/knowledge_plugins/xrefs/xref.py +150 -0
- angr/knowledge_plugins/xrefs/xref_manager.py +127 -0
- angr/knowledge_plugins/xrefs/xref_types.py +16 -0
- angr/misc/__init__.py +19 -0
- angr/misc/ansi.py +47 -0
- angr/misc/autoimport.py +90 -0
- angr/misc/bug_report.py +126 -0
- angr/misc/hookset.py +106 -0
- angr/misc/loggers.py +130 -0
- angr/misc/picklable_lock.py +46 -0
- angr/misc/plugins.py +289 -0
- angr/misc/telemetry.py +54 -0
- angr/misc/testing.py +24 -0
- angr/misc/ux.py +31 -0
- angr/procedures/__init__.py +12 -0
- angr/procedures/advapi32/__init__.py +0 -0
- angr/procedures/cgc/__init__.py +3 -0
- angr/procedures/cgc/_terminate.py +11 -0
- angr/procedures/cgc/allocate.py +75 -0
- angr/procedures/cgc/deallocate.py +67 -0
- angr/procedures/cgc/fdwait.py +65 -0
- angr/procedures/cgc/random.py +67 -0
- angr/procedures/cgc/receive.py +93 -0
- angr/procedures/cgc/transmit.py +65 -0
- angr/procedures/definitions/__init__.py +1043 -0
- angr/procedures/definitions/cgc.py +23 -0
- angr/procedures/definitions/common/glibc.json +3516 -0
- angr/procedures/definitions/gnulib.py +41 -0
- angr/procedures/definitions/libstdcpp.py +25 -0
- angr/procedures/definitions/linux_kernel.py +8382 -0
- angr/procedures/definitions/linux_loader.py +7 -0
- angr/procedures/definitions/macho_libsystem.py +18 -0
- angr/procedures/definitions/msvcr.py +25 -0
- angr/procedures/definitions/parse_glibc.py +77 -0
- angr/procedures/definitions/parse_syscalls_from_local_system.py +54 -0
- angr/procedures/definitions/parse_win32json.py +2540 -0
- angr/procedures/definitions/types_stl.py +22 -0
- angr/procedures/definitions/wdk/api-ms-win-dx-d3dkmt-l1-1-4.json +24 -0
- angr/procedures/definitions/wdk/api-ms-win-dx-d3dkmt-l1-1-6.json +18 -0
- angr/procedures/definitions/wdk/clfs.json +189 -0
- angr/procedures/definitions/wdk/fltmgr.json +813 -0
- angr/procedures/definitions/wdk/fwpkclnt.json +24 -0
- angr/procedures/definitions/wdk/fwpuclnt.json +453 -0
- angr/procedures/definitions/wdk/gdi32.json +528 -0
- angr/procedures/definitions/wdk/hal.json +96 -0
- angr/procedures/definitions/wdk/ksecdd.json +72 -0
- angr/procedures/definitions/wdk/ndis.json +336 -0
- angr/procedures/definitions/wdk/ntoskrnl.json +5158 -0
- angr/procedures/definitions/wdk/offreg.json +87 -0
- angr/procedures/definitions/wdk/pshed.json +33 -0
- angr/procedures/definitions/wdk/secur32.json +39 -0
- angr/procedures/definitions/wdk/vhfum.json +30 -0
- angr/procedures/definitions/win32/_types_win32.json +34480 -0
- angr/procedures/definitions/win32/aclui.json +24 -0
- angr/procedures/definitions/win32/activeds.json +81 -0
- angr/procedures/definitions/win32/advapi32.json +2505 -0
- angr/procedures/definitions/win32/advpack.json +165 -0
- angr/procedures/definitions/win32/amsi.json +36 -0
- angr/procedures/definitions/win32/api-ms-win-appmodel-runtime-l1-1-1.json +45 -0
- angr/procedures/definitions/win32/api-ms-win-appmodel-runtime-l1-1-3.json +30 -0
- angr/procedures/definitions/win32/api-ms-win-appmodel-runtime-l1-1-6.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-apiquery-l2-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-backgroundtask-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-comm-l1-1-1.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-comm-l1-1-2.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-enclave-l1-1-1.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-core-errorhandling-l1-1-3.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-featurestaging-l1-1-0.json +30 -0
- angr/procedures/definitions/win32/api-ms-win-core-featurestaging-l1-1-1.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-file-fromapp-l1-1-0.json +48 -0
- angr/procedures/definitions/win32/api-ms-win-core-handle-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-ioring-l1-1-0.json +51 -0
- angr/procedures/definitions/win32/api-ms-win-core-marshal-l1-1-0.json +27 -0
- angr/procedures/definitions/win32/api-ms-win-core-memory-l1-1-3.json +27 -0
- angr/procedures/definitions/win32/api-ms-win-core-memory-l1-1-4.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-memory-l1-1-5.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-core-memory-l1-1-6.json +27 -0
- angr/procedures/definitions/win32/api-ms-win-core-memory-l1-1-7.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-core-memory-l1-1-8.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-core-path-l1-1-0.json +81 -0
- angr/procedures/definitions/win32/api-ms-win-core-psm-appnotify-l1-1-0.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-core-psm-appnotify-l1-1-1.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-core-realtime-l1-1-1.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-core-realtime-l1-1-2.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-core-slapi-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-state-helpers-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-synch-l1-2-0.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-core-sysinfo-l1-2-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-sysinfo-l1-2-3.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-core-sysinfo-l1-2-4.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-core-sysinfo-l1-2-6.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-core-util-l1-1-1.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-core-wow64-l1-1-1.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-devices-query-l1-1-0.json +42 -0
- angr/procedures/definitions/win32/api-ms-win-devices-query-l1-1-1.json +30 -0
- angr/procedures/definitions/win32/api-ms-win-dx-d3dkmt-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-deviceinformation-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-expandedresources-l1-1-0.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-tcui-l1-1-0.json +36 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-tcui-l1-1-1.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-tcui-l1-1-2.json +36 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-tcui-l1-1-3.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-gaming-tcui-l1-1-4.json +39 -0
- angr/procedures/definitions/win32/api-ms-win-mm-misc-l1-1-1.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-net-isolation-l1-1-0.json +39 -0
- angr/procedures/definitions/win32/api-ms-win-security-base-l1-2-2.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-security-isolatedcontainer-l1-1-0.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-security-isolatedcontainer-l1-1-1.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-service-core-l1-1-3.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-service-core-l1-1-4.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-service-core-l1-1-5.json +21 -0
- angr/procedures/definitions/win32/api-ms-win-shcore-scaling-l1-1-0.json +24 -0
- angr/procedures/definitions/win32/api-ms-win-shcore-scaling-l1-1-1.json +33 -0
- angr/procedures/definitions/win32/api-ms-win-shcore-scaling-l1-1-2.json +18 -0
- angr/procedures/definitions/win32/api-ms-win-wsl-api-l1-1-0.json +36 -0
- angr/procedures/definitions/win32/apphelp.json +18 -0
- angr/procedures/definitions/win32/authz.json +114 -0
- angr/procedures/definitions/win32/avicap32.json +27 -0
- angr/procedures/definitions/win32/avifil32.json +195 -0
- angr/procedures/definitions/win32/avrt.json +57 -0
- angr/procedures/definitions/win32/bcp47mrm.json +21 -0
- angr/procedures/definitions/win32/bcrypt.json +174 -0
- angr/procedures/definitions/win32/bcryptprimitives.json +21 -0
- angr/procedures/definitions/win32/bluetoothapis.json +138 -0
- angr/procedures/definitions/win32/bthprops_cpl.json +33 -0
- angr/procedures/definitions/win32/cabinet.json +81 -0
- angr/procedures/definitions/win32/certadm.json +69 -0
- angr/procedures/definitions/win32/certpoleng.json +39 -0
- angr/procedures/definitions/win32/cfgmgr32.json +732 -0
- angr/procedures/definitions/win32/chakra.json +270 -0
- angr/procedures/definitions/win32/cldapi.json +123 -0
- angr/procedures/definitions/win32/clfsw32.json +192 -0
- angr/procedures/definitions/win32/clusapi.json +855 -0
- angr/procedures/definitions/win32/comctl32.json +360 -0
- angr/procedures/definitions/win32/comdlg32.json +78 -0
- angr/procedures/definitions/win32/compstui.json +27 -0
- angr/procedures/definitions/win32/computecore.json +177 -0
- angr/procedures/definitions/win32/computenetwork.json +144 -0
- angr/procedures/definitions/win32/computestorage.json +51 -0
- angr/procedures/definitions/win32/comsvcs.json +36 -0
- angr/procedures/definitions/win32/credui.json +72 -0
- angr/procedures/definitions/win32/crypt32.json +702 -0
- angr/procedures/definitions/win32/cryptnet.json +30 -0
- angr/procedures/definitions/win32/cryptui.json +45 -0
- angr/procedures/definitions/win32/cryptxml.json +72 -0
- angr/procedures/definitions/win32/cscapi.json +27 -0
- angr/procedures/definitions/win32/d2d1.json +54 -0
- angr/procedures/definitions/win32/d3d10.json +96 -0
- angr/procedures/definitions/win32/d3d10_1.json +21 -0
- angr/procedures/definitions/win32/d3d11.json +24 -0
- angr/procedures/definitions/win32/d3d12.json +39 -0
- angr/procedures/definitions/win32/d3d9.json +48 -0
- angr/procedures/definitions/win32/d3dcompiler_47.json +93 -0
- angr/procedures/definitions/win32/d3dcsx.json +42 -0
- angr/procedures/definitions/win32/davclnt.json +69 -0
- angr/procedures/definitions/win32/dbgeng.json +27 -0
- angr/procedures/definitions/win32/dbghelp.json +663 -0
- angr/procedures/definitions/win32/dbgmodel.json +18 -0
- angr/procedures/definitions/win32/dciman32.json +75 -0
- angr/procedures/definitions/win32/dcomp.json +51 -0
- angr/procedures/definitions/win32/ddraw.json +36 -0
- angr/procedures/definitions/win32/deviceaccess.json +18 -0
- angr/procedures/definitions/win32/dflayout.json +18 -0
- angr/procedures/definitions/win32/dhcpcsvc.json +60 -0
- angr/procedures/definitions/win32/dhcpcsvc6.json +33 -0
- angr/procedures/definitions/win32/dhcpsapi.json +603 -0
- angr/procedures/definitions/win32/diagnosticdataquery.json +120 -0
- angr/procedures/definitions/win32/dinput8.json +18 -0
- angr/procedures/definitions/win32/directml.json +21 -0
- angr/procedures/definitions/win32/dmprocessxmlfiltered.json +18 -0
- angr/procedures/definitions/win32/dnsapi.json +207 -0
- angr/procedures/definitions/win32/drt.json +63 -0
- angr/procedures/definitions/win32/drtprov.json +42 -0
- angr/procedures/definitions/win32/drttransport.json +21 -0
- angr/procedures/definitions/win32/dsound.json +45 -0
- angr/procedures/definitions/win32/dsparse.json +72 -0
- angr/procedures/definitions/win32/dsprop.json +36 -0
- angr/procedures/definitions/win32/dssec.json +27 -0
- angr/procedures/definitions/win32/dsuiext.json +27 -0
- angr/procedures/definitions/win32/dwmapi.json +108 -0
- angr/procedures/definitions/win32/dwrite.json +18 -0
- angr/procedures/definitions/win32/dxcompiler.json +21 -0
- angr/procedures/definitions/win32/dxcore.json +18 -0
- angr/procedures/definitions/win32/dxgi.json +33 -0
- angr/procedures/definitions/win32/dxva2.json +129 -0
- angr/procedures/definitions/win32/eappcfg.json +57 -0
- angr/procedures/definitions/win32/eappprxy.json +69 -0
- angr/procedures/definitions/win32/efswrt.json +21 -0
- angr/procedures/definitions/win32/elscore.json +30 -0
- angr/procedures/definitions/win32/esent.json +702 -0
- angr/procedures/definitions/win32/evr.json +36 -0
- angr/procedures/definitions/win32/faultrep.json +27 -0
- angr/procedures/definitions/win32/fhsvcctl.json +36 -0
- angr/procedures/definitions/win32/firewallapi.json +24 -0
- angr/procedures/definitions/win32/fltlib.json +99 -0
- angr/procedures/definitions/win32/fontsub.json +21 -0
- angr/procedures/definitions/win32/forceinline.json +24 -0
- angr/procedures/definitions/win32/fwpuclnt.json +591 -0
- angr/procedures/definitions/win32/fxsutility.json +21 -0
- angr/procedures/definitions/win32/gdi32.json +1308 -0
- angr/procedures/definitions/win32/gdiplus.json +1902 -0
- angr/procedures/definitions/win32/glu32.json +171 -0
- angr/procedures/definitions/win32/gpedit.json +33 -0
- angr/procedures/definitions/win32/hhctrl_ocx.json +21 -0
- angr/procedures/definitions/win32/hid.json +150 -0
- angr/procedures/definitions/win32/hlink.json +99 -0
- angr/procedures/definitions/win32/hrtfapo.json +18 -0
- angr/procedures/definitions/win32/httpapi.json +144 -0
- angr/procedures/definitions/win32/icm32.json +78 -0
- angr/procedures/definitions/win32/icmui.json +21 -0
- angr/procedures/definitions/win32/icu.json +3090 -0
- angr/procedures/definitions/win32/ieframe.json +102 -0
- angr/procedures/definitions/win32/imagehlp.json +84 -0
- angr/procedures/definitions/win32/imgutil.json +42 -0
- angr/procedures/definitions/win32/imm32.json +261 -0
- angr/procedures/definitions/win32/infocardapi.json +66 -0
- angr/procedures/definitions/win32/inkobjcore.json +96 -0
- angr/procedures/definitions/win32/iphlpapi.json +618 -0
- angr/procedures/definitions/win32/iscsidsc.json +252 -0
- angr/procedures/definitions/win32/isolatedwindowsenvironmentutils.json +21 -0
- angr/procedures/definitions/win32/kernel32.json +4566 -0
- angr/procedures/definitions/win32/kernelbase.json +33 -0
- angr/procedures/definitions/win32/keycredmgr.json +27 -0
- angr/procedures/definitions/win32/ksproxy_ax.json +33 -0
- angr/procedures/definitions/win32/ksuser.json +39 -0
- angr/procedures/definitions/win32/ktmw32.json +132 -0
- angr/procedures/definitions/win32/licenseprotection.json +21 -0
- angr/procedures/definitions/win32/loadperf.json +51 -0
- angr/procedures/definitions/win32/magnification.json +72 -0
- angr/procedures/definitions/win32/mapi32.json +213 -0
- angr/procedures/definitions/win32/mdmlocalmanagement.json +24 -0
- angr/procedures/definitions/win32/mdmregistration.json +60 -0
- angr/procedures/definitions/win32/mf.json +201 -0
- angr/procedures/definitions/win32/mfcore.json +21 -0
- angr/procedures/definitions/win32/mfplat.json +450 -0
- angr/procedures/definitions/win32/mfplay.json +18 -0
- angr/procedures/definitions/win32/mfreadwrite.json +30 -0
- angr/procedures/definitions/win32/mfsensorgroup.json +45 -0
- angr/procedures/definitions/win32/mfsrcsnk.json +21 -0
- angr/procedures/definitions/win32/mgmtapi.json +42 -0
- angr/procedures/definitions/win32/mi.json +18 -0
- angr/procedures/definitions/win32/mmdevapi.json +18 -0
- angr/procedures/definitions/win32/mpr.json +156 -0
- angr/procedures/definitions/win32/mprapi.json +351 -0
- angr/procedures/definitions/win32/mqrt.json +117 -0
- angr/procedures/definitions/win32/mrmsupport.json +96 -0
- angr/procedures/definitions/win32/msacm32.json +141 -0
- angr/procedures/definitions/win32/msajapi.json +1656 -0
- angr/procedures/definitions/win32/mscms.json +252 -0
- angr/procedures/definitions/win32/mscoree.json +96 -0
- angr/procedures/definitions/win32/msctfmonitor.json +24 -0
- angr/procedures/definitions/win32/msdelta.json +63 -0
- angr/procedures/definitions/win32/msdmo.json +48 -0
- angr/procedures/definitions/win32/msdrm.json +267 -0
- angr/procedures/definitions/win32/msi.json +807 -0
- angr/procedures/definitions/win32/msimg32.json +24 -0
- angr/procedures/definitions/win32/mspatcha.json +63 -0
- angr/procedures/definitions/win32/mspatchc.json +42 -0
- angr/procedures/definitions/win32/msports.json +36 -0
- angr/procedures/definitions/win32/msrating.json +72 -0
- angr/procedures/definitions/win32/mssign32.json +45 -0
- angr/procedures/definitions/win32/mstask.json +21 -0
- angr/procedures/definitions/win32/msvfw32.json +144 -0
- angr/procedures/definitions/win32/mswsock.json +63 -0
- angr/procedures/definitions/win32/mtxdm.json +18 -0
- angr/procedures/definitions/win32/ncrypt.json +132 -0
- angr/procedures/definitions/win32/ndfapi.json +63 -0
- angr/procedures/definitions/win32/netapi32.json +633 -0
- angr/procedures/definitions/win32/netsh.json +39 -0
- angr/procedures/definitions/win32/netshell.json +21 -0
- angr/procedures/definitions/win32/newdev.json +48 -0
- angr/procedures/definitions/win32/ninput.json +105 -0
- angr/procedures/definitions/win32/normaliz.json +21 -0
- angr/procedures/definitions/win32/ntdll.json +234 -0
- angr/procedures/definitions/win32/ntdllk.json +18 -0
- angr/procedures/definitions/win32/ntdsapi.json +258 -0
- angr/procedures/definitions/win32/ntlanman.json +45 -0
- angr/procedures/definitions/win32/odbc32.json +477 -0
- angr/procedures/definitions/win32/odbcbcp.json +96 -0
- angr/procedures/definitions/win32/ole32.json +966 -0
- angr/procedures/definitions/win32/oleacc.json +66 -0
- angr/procedures/definitions/win32/oleaut32.json +1230 -0
- angr/procedures/definitions/win32/oledlg.json +84 -0
- angr/procedures/definitions/win32/ondemandconnroutehelper.json +30 -0
- angr/procedures/definitions/win32/opengl32.json +1080 -0
- angr/procedures/definitions/win32/opmxbox.json +24 -0
- angr/procedures/definitions/win32/p2p.json +339 -0
- angr/procedures/definitions/win32/p2pgraph.json +126 -0
- angr/procedures/definitions/win32/pdh.json +309 -0
- angr/procedures/definitions/win32/peerdist.json +99 -0
- angr/procedures/definitions/win32/powrprof.json +267 -0
- angr/procedures/definitions/win32/prntvpt.json +48 -0
- angr/procedures/definitions/win32/projectedfslib.json +72 -0
- angr/procedures/definitions/win32/propsys.json +669 -0
- angr/procedures/definitions/win32/psapi.json +96 -0
- angr/procedures/definitions/win32/quartz.json +21 -0
- angr/procedures/definitions/win32/query.json +27 -0
- angr/procedures/definitions/win32/qwave.json +48 -0
- angr/procedures/definitions/win32/rasapi32.json +267 -0
- angr/procedures/definitions/win32/rasdlg.json +33 -0
- angr/procedures/definitions/win32/resutils.json +375 -0
- angr/procedures/definitions/win32/rpcns4.json +198 -0
- angr/procedures/definitions/win32/rpcproxy.json +27 -0
- angr/procedures/definitions/win32/rpcrt4.json +1356 -0
- angr/procedures/definitions/win32/rstrtmgr.json +48 -0
- angr/procedures/definitions/win32/rtm.json +243 -0
- angr/procedures/definitions/win32/rtutils.json +138 -0
- angr/procedures/definitions/win32/rtworkq.json +114 -0
- angr/procedures/definitions/win32/sas.json +18 -0
- angr/procedures/definitions/win32/scarddlg.json +30 -0
- angr/procedures/definitions/win32/schannel.json +42 -0
- angr/procedures/definitions/win32/sechost.json +21 -0
- angr/procedures/definitions/win32/secur32.json +282 -0
- angr/procedures/definitions/win32/sensapi.json +24 -0
- angr/procedures/definitions/win32/sensorsutilsv2.json +135 -0
- angr/procedures/definitions/win32/setupapi.json +1017 -0
- angr/procedures/definitions/win32/sfc.json +33 -0
- angr/procedures/definitions/win32/shdocvw.json +24 -0
- angr/procedures/definitions/win32/shell32.json +747 -0
- angr/procedures/definitions/win32/shlwapi.json +1095 -0
- angr/procedures/definitions/win32/slc.json +111 -0
- angr/procedures/definitions/win32/slcext.json +27 -0
- angr/procedures/definitions/win32/slwga.json +18 -0
- angr/procedures/definitions/win32/snmpapi.json +93 -0
- angr/procedures/definitions/win32/spoolss.json +93 -0
- angr/procedures/definitions/win32/srclient.json +18 -0
- angr/procedures/definitions/win32/srpapi.json +48 -0
- angr/procedures/definitions/win32/sspicli.json +36 -0
- angr/procedures/definitions/win32/sti.json +18 -0
- angr/procedures/definitions/win32/t2embed.json +57 -0
- angr/procedures/definitions/win32/tapi32.json +762 -0
- angr/procedures/definitions/win32/tbs.json +57 -0
- angr/procedures/definitions/win32/tdh.json +96 -0
- angr/procedures/definitions/win32/tokenbinding.json +45 -0
- angr/procedures/definitions/win32/traffic.json +75 -0
- angr/procedures/definitions/win32/txfw32.json +42 -0
- angr/procedures/definitions/win32/ualapi.json +27 -0
- angr/procedures/definitions/win32/uiautomationcore.json +309 -0
- angr/procedures/definitions/win32/urlmon.json +246 -0
- angr/procedures/definitions/win32/user32.json +2298 -0
- angr/procedures/definitions/win32/userenv.json +147 -0
- angr/procedures/definitions/win32/usp10.json +135 -0
- angr/procedures/definitions/win32/uxtheme.json +246 -0
- angr/procedures/definitions/win32/verifier.json +18 -0
- angr/procedures/definitions/win32/version.json +57 -0
- angr/procedures/definitions/win32/vertdll.json +36 -0
- angr/procedures/definitions/win32/virtdisk.json +102 -0
- angr/procedures/definitions/win32/vmdevicehost.json +54 -0
- angr/procedures/definitions/win32/vmsavedstatedumpprovider.json +144 -0
- angr/procedures/definitions/win32/vssapi.json +18 -0
- angr/procedures/definitions/win32/wcmapi.json +30 -0
- angr/procedures/definitions/win32/wdsbp.json +36 -0
- angr/procedures/definitions/win32/wdsclientapi.json +126 -0
- angr/procedures/definitions/win32/wdsmc.json +33 -0
- angr/procedures/definitions/win32/wdspxe.json +108 -0
- angr/procedures/definitions/win32/wdstptc.json +54 -0
- angr/procedures/definitions/win32/webauthn.json +54 -0
- angr/procedures/definitions/win32/webservices.json +594 -0
- angr/procedures/definitions/win32/websocket.json +54 -0
- angr/procedures/definitions/win32/wecapi.json +60 -0
- angr/procedures/definitions/win32/wer.json +78 -0
- angr/procedures/definitions/win32/wevtapi.json +120 -0
- angr/procedures/definitions/win32/winbio.json +177 -0
- angr/procedures/definitions/win32/windows_ai_machinelearning.json +18 -0
- angr/procedures/definitions/win32/windows_media_mediacontrol.json +39 -0
- angr/procedures/definitions/win32/windows_networking.json +18 -0
- angr/procedures/definitions/win32/windows_ui_xaml.json +21 -0
- angr/procedures/definitions/win32/windowscodecs.json +42 -0
- angr/procedures/definitions/win32/winfax.json +183 -0
- angr/procedures/definitions/win32/winhttp.json +183 -0
- angr/procedures/definitions/win32/winhvemulation.json +27 -0
- angr/procedures/definitions/win32/winhvplatform.json +213 -0
- angr/procedures/definitions/win32/wininet.json +903 -0
- angr/procedures/definitions/win32/winml.json +18 -0
- angr/procedures/definitions/win32/winmm.json +543 -0
- angr/procedures/definitions/win32/winscard.json +225 -0
- angr/procedures/definitions/win32/winspool_drv.json +531 -0
- angr/procedures/definitions/win32/wintrust.json +195 -0
- angr/procedures/definitions/win32/winusb.json +117 -0
- angr/procedures/definitions/win32/wlanapi.json +195 -0
- angr/procedures/definitions/win32/wlanui.json +18 -0
- angr/procedures/definitions/win32/wldap32.json +744 -0
- angr/procedures/definitions/win32/wldp.json +42 -0
- angr/procedures/definitions/win32/wmvcore.json +48 -0
- angr/procedures/definitions/win32/wnvapi.json +21 -0
- angr/procedures/definitions/win32/wofutil.json +48 -0
- angr/procedures/definitions/win32/ws2_32.json +495 -0
- angr/procedures/definitions/win32/wscapi.json +33 -0
- angr/procedures/definitions/win32/wsclient.json +24 -0
- angr/procedures/definitions/win32/wsdapi.json +111 -0
- angr/procedures/definitions/win32/wsmsvc.json +114 -0
- angr/procedures/definitions/win32/wsnmp32.json +162 -0
- angr/procedures/definitions/win32/wtsapi32.json +204 -0
- angr/procedures/definitions/win32/xaudio2_8.json +27 -0
- angr/procedures/definitions/win32/xinput1_4.json +36 -0
- angr/procedures/definitions/win32/xmllite.json +33 -0
- angr/procedures/definitions/win32/xolehlp.json +27 -0
- angr/procedures/definitions/win32/xpsprint.json +21 -0
- angr/procedures/glibc/__ctype_b_loc.py +21 -0
- angr/procedures/glibc/__ctype_tolower_loc.py +21 -0
- angr/procedures/glibc/__ctype_toupper_loc.py +21 -0
- angr/procedures/glibc/__errno_location.py +7 -0
- angr/procedures/glibc/__init__.py +3 -0
- angr/procedures/glibc/__libc_init.py +37 -0
- angr/procedures/glibc/__libc_start_main.py +301 -0
- angr/procedures/glibc/dynamic_loading.py +20 -0
- angr/procedures/glibc/scanf.py +19 -0
- angr/procedures/glibc/sscanf.py +10 -0
- angr/procedures/gnulib/__init__.py +3 -0
- angr/procedures/gnulib/xalloc_die.py +14 -0
- angr/procedures/gnulib/xstrtol_fatal.py +14 -0
- angr/procedures/java/__init__.py +42 -0
- angr/procedures/java/unconstrained.py +65 -0
- angr/procedures/java_io/__init__.py +0 -0
- angr/procedures/java_io/read.py +12 -0
- angr/procedures/java_io/write.py +17 -0
- angr/procedures/java_jni/__init__.py +482 -0
- angr/procedures/java_jni/array_operations.py +312 -0
- angr/procedures/java_jni/class_and_interface_operations.py +31 -0
- angr/procedures/java_jni/field_access.py +173 -0
- angr/procedures/java_jni/global_and_local_refs.py +57 -0
- angr/procedures/java_jni/method_calls.py +365 -0
- angr/procedures/java_jni/not_implemented.py +26 -0
- angr/procedures/java_jni/object_operations.py +94 -0
- angr/procedures/java_jni/string_operations.py +87 -0
- angr/procedures/java_jni/version_information.py +12 -0
- angr/procedures/java_lang/__init__.py +0 -0
- angr/procedures/java_lang/character.py +30 -0
- angr/procedures/java_lang/double.py +24 -0
- angr/procedures/java_lang/exit.py +13 -0
- angr/procedures/java_lang/getsimplename.py +18 -0
- angr/procedures/java_lang/integer.py +43 -0
- angr/procedures/java_lang/load_library.py +9 -0
- angr/procedures/java_lang/math.py +15 -0
- angr/procedures/java_lang/string.py +78 -0
- angr/procedures/java_lang/stringbuilder.py +44 -0
- angr/procedures/java_lang/system.py +18 -0
- angr/procedures/java_util/__init__.py +0 -0
- angr/procedures/java_util/collection.py +35 -0
- angr/procedures/java_util/iterator.py +46 -0
- angr/procedures/java_util/list.py +99 -0
- angr/procedures/java_util/map.py +131 -0
- angr/procedures/java_util/random.py +14 -0
- angr/procedures/java_util/scanner_nextline.py +23 -0
- angr/procedures/libc/__init__.py +3 -0
- angr/procedures/libc/abort.py +9 -0
- angr/procedures/libc/access.py +13 -0
- angr/procedures/libc/atoi.py +14 -0
- angr/procedures/libc/atol.py +13 -0
- angr/procedures/libc/calloc.py +8 -0
- angr/procedures/libc/closelog.py +10 -0
- angr/procedures/libc/err.py +14 -0
- angr/procedures/libc/error.py +54 -0
- angr/procedures/libc/exit.py +11 -0
- angr/procedures/libc/fclose.py +19 -0
- angr/procedures/libc/feof.py +21 -0
- angr/procedures/libc/fflush.py +16 -0
- angr/procedures/libc/fgetc.py +27 -0
- angr/procedures/libc/fgets.py +69 -0
- angr/procedures/libc/fopen.py +63 -0
- angr/procedures/libc/fprintf.py +25 -0
- angr/procedures/libc/fputc.py +23 -0
- angr/procedures/libc/fputs.py +24 -0
- angr/procedures/libc/fread.py +24 -0
- angr/procedures/libc/free.py +9 -0
- angr/procedures/libc/fscanf.py +20 -0
- angr/procedures/libc/fseek.py +34 -0
- angr/procedures/libc/ftell.py +22 -0
- angr/procedures/libc/fwrite.py +19 -0
- angr/procedures/libc/getchar.py +13 -0
- angr/procedures/libc/getdelim.py +99 -0
- angr/procedures/libc/getegid.py +8 -0
- angr/procedures/libc/geteuid.py +8 -0
- angr/procedures/libc/getgid.py +8 -0
- angr/procedures/libc/gets.py +68 -0
- angr/procedures/libc/getuid.py +8 -0
- angr/procedures/libc/malloc.py +12 -0
- angr/procedures/libc/memcmp.py +69 -0
- angr/procedures/libc/memcpy.py +45 -0
- angr/procedures/libc/memset.py +72 -0
- angr/procedures/libc/openlog.py +10 -0
- angr/procedures/libc/perror.py +13 -0
- angr/procedures/libc/printf.py +34 -0
- angr/procedures/libc/putchar.py +13 -0
- angr/procedures/libc/puts.py +19 -0
- angr/procedures/libc/rand.py +8 -0
- angr/procedures/libc/realloc.py +8 -0
- angr/procedures/libc/rewind.py +12 -0
- angr/procedures/libc/scanf.py +20 -0
- angr/procedures/libc/setbuf.py +9 -0
- angr/procedures/libc/setvbuf.py +7 -0
- angr/procedures/libc/snprintf.py +36 -0
- angr/procedures/libc/sprintf.py +25 -0
- angr/procedures/libc/srand.py +7 -0
- angr/procedures/libc/sscanf.py +13 -0
- angr/procedures/libc/stpcpy.py +18 -0
- angr/procedures/libc/strcat.py +14 -0
- angr/procedures/libc/strchr.py +48 -0
- angr/procedures/libc/strcmp.py +31 -0
- angr/procedures/libc/strcpy.py +13 -0
- angr/procedures/libc/strlen.py +114 -0
- angr/procedures/libc/strncat.py +19 -0
- angr/procedures/libc/strncmp.py +183 -0
- angr/procedures/libc/strncpy.py +22 -0
- angr/procedures/libc/strnlen.py +13 -0
- angr/procedures/libc/strstr.py +101 -0
- angr/procedures/libc/strtol.py +261 -0
- angr/procedures/libc/strtoul.py +9 -0
- angr/procedures/libc/system.py +13 -0
- angr/procedures/libc/time.py +9 -0
- angr/procedures/libc/tmpnam.py +20 -0
- angr/procedures/libc/tolower.py +10 -0
- angr/procedures/libc/toupper.py +10 -0
- angr/procedures/libc/ungetc.py +20 -0
- angr/procedures/libc/vsnprintf.py +17 -0
- angr/procedures/libc/wchar.py +16 -0
- angr/procedures/libstdcpp/__init__.py +0 -0
- angr/procedures/libstdcpp/_unwind_resume.py +11 -0
- angr/procedures/libstdcpp/std____throw_bad_alloc.py +13 -0
- angr/procedures/libstdcpp/std____throw_bad_cast.py +13 -0
- angr/procedures/libstdcpp/std____throw_length_error.py +13 -0
- angr/procedures/libstdcpp/std____throw_logic_error.py +13 -0
- angr/procedures/libstdcpp/std__terminate.py +13 -0
- angr/procedures/linux_kernel/__init__.py +3 -0
- angr/procedures/linux_kernel/access.py +18 -0
- angr/procedures/linux_kernel/arch_prctl.py +34 -0
- angr/procedures/linux_kernel/arm_user_helpers.py +59 -0
- angr/procedures/linux_kernel/brk.py +18 -0
- angr/procedures/linux_kernel/cwd.py +28 -0
- angr/procedures/linux_kernel/fstat.py +138 -0
- angr/procedures/linux_kernel/fstat64.py +170 -0
- angr/procedures/linux_kernel/futex.py +17 -0
- angr/procedures/linux_kernel/getegid.py +17 -0
- angr/procedures/linux_kernel/geteuid.py +17 -0
- angr/procedures/linux_kernel/getgid.py +17 -0
- angr/procedures/linux_kernel/getpid.py +14 -0
- angr/procedures/linux_kernel/getrlimit.py +24 -0
- angr/procedures/linux_kernel/gettid.py +9 -0
- angr/procedures/linux_kernel/getuid.py +17 -0
- angr/procedures/linux_kernel/iovec.py +47 -0
- angr/procedures/linux_kernel/lseek.py +42 -0
- angr/procedures/linux_kernel/mmap.py +16 -0
- angr/procedures/linux_kernel/mprotect.py +42 -0
- angr/procedures/linux_kernel/munmap.py +8 -0
- angr/procedures/linux_kernel/openat.py +26 -0
- angr/procedures/linux_kernel/set_tid_address.py +8 -0
- angr/procedures/linux_kernel/sigaction.py +19 -0
- angr/procedures/linux_kernel/sigprocmask.py +23 -0
- angr/procedures/linux_kernel/stat.py +23 -0
- angr/procedures/linux_kernel/sysinfo.py +59 -0
- angr/procedures/linux_kernel/tgkill.py +10 -0
- angr/procedures/linux_kernel/time.py +34 -0
- angr/procedures/linux_kernel/uid.py +30 -0
- angr/procedures/linux_kernel/uname.py +29 -0
- angr/procedures/linux_kernel/unlink.py +22 -0
- angr/procedures/linux_kernel/vsyscall.py +16 -0
- angr/procedures/linux_loader/__init__.py +3 -0
- angr/procedures/linux_loader/_dl_initial_error_catch_tsd.py +7 -0
- angr/procedures/linux_loader/_dl_rtld_lock.py +15 -0
- angr/procedures/linux_loader/sim_loader.py +54 -0
- angr/procedures/linux_loader/tls.py +40 -0
- angr/procedures/msvcr/__getmainargs.py +16 -0
- angr/procedures/msvcr/__init__.py +4 -0
- angr/procedures/msvcr/_initterm.py +38 -0
- angr/procedures/msvcr/fmode.py +31 -0
- angr/procedures/ntdll/__init__.py +0 -0
- angr/procedures/ntdll/exceptions.py +60 -0
- angr/procedures/posix/__init__.py +3 -0
- angr/procedures/posix/accept.py +29 -0
- angr/procedures/posix/bind.py +13 -0
- angr/procedures/posix/bzero.py +9 -0
- angr/procedures/posix/chroot.py +27 -0
- angr/procedures/posix/close.py +9 -0
- angr/procedures/posix/closedir.py +7 -0
- angr/procedures/posix/dup.py +56 -0
- angr/procedures/posix/fcntl.py +10 -0
- angr/procedures/posix/fdopen.py +76 -0
- angr/procedures/posix/fileno.py +18 -0
- angr/procedures/posix/fork.py +13 -0
- angr/procedures/posix/getenv.py +35 -0
- angr/procedures/posix/gethostbyname.py +43 -0
- angr/procedures/posix/getpass.py +19 -0
- angr/procedures/posix/getsockopt.py +11 -0
- angr/procedures/posix/htonl.py +11 -0
- angr/procedures/posix/htons.py +11 -0
- angr/procedures/posix/inet_ntoa.py +59 -0
- angr/procedures/posix/listen.py +13 -0
- angr/procedures/posix/mmap.py +144 -0
- angr/procedures/posix/open.py +18 -0
- angr/procedures/posix/opendir.py +10 -0
- angr/procedures/posix/poll.py +55 -0
- angr/procedures/posix/pread64.py +46 -0
- angr/procedures/posix/pthread.py +87 -0
- angr/procedures/posix/pwrite64.py +46 -0
- angr/procedures/posix/read.py +13 -0
- angr/procedures/posix/readdir.py +62 -0
- angr/procedures/posix/recv.py +13 -0
- angr/procedures/posix/recvfrom.py +13 -0
- angr/procedures/posix/select.py +48 -0
- angr/procedures/posix/send.py +23 -0
- angr/procedures/posix/setsockopt.py +9 -0
- angr/procedures/posix/sigaction.py +23 -0
- angr/procedures/posix/sim_time.py +48 -0
- angr/procedures/posix/sleep.py +8 -0
- angr/procedures/posix/socket.py +18 -0
- angr/procedures/posix/strcasecmp.py +26 -0
- angr/procedures/posix/strdup.py +18 -0
- angr/procedures/posix/strtok_r.py +64 -0
- angr/procedures/posix/syslog.py +15 -0
- angr/procedures/posix/tz.py +9 -0
- angr/procedures/posix/unlink.py +11 -0
- angr/procedures/posix/usleep.py +8 -0
- angr/procedures/posix/write.py +13 -0
- angr/procedures/procedure_dict.py +50 -0
- angr/procedures/stubs/CallReturn.py +13 -0
- angr/procedures/stubs/NoReturnUnconstrained.py +13 -0
- angr/procedures/stubs/Nop.py +7 -0
- angr/procedures/stubs/PathTerminator.py +9 -0
- angr/procedures/stubs/Redirect.py +18 -0
- angr/procedures/stubs/ReturnChar.py +11 -0
- angr/procedures/stubs/ReturnUnconstrained.py +24 -0
- angr/procedures/stubs/UnresolvableCallTarget.py +9 -0
- angr/procedures/stubs/UnresolvableJumpTarget.py +9 -0
- angr/procedures/stubs/UserHook.py +18 -0
- angr/procedures/stubs/__init__.py +3 -0
- angr/procedures/stubs/b64_decode.py +15 -0
- angr/procedures/stubs/caller.py +14 -0
- angr/procedures/stubs/crazy_scanf.py +20 -0
- angr/procedures/stubs/format_parser.py +669 -0
- angr/procedures/stubs/syscall_stub.py +24 -0
- angr/procedures/testing/__init__.py +3 -0
- angr/procedures/testing/manyargs.py +9 -0
- angr/procedures/testing/retreg.py +8 -0
- angr/procedures/tracer/__init__.py +4 -0
- angr/procedures/tracer/random.py +9 -0
- angr/procedures/tracer/receive.py +23 -0
- angr/procedures/tracer/transmit.py +26 -0
- angr/procedures/uclibc/__init__.py +3 -0
- angr/procedures/uclibc/__uClibc_main.py +10 -0
- angr/procedures/win32/EncodePointer.py +7 -0
- angr/procedures/win32/ExitProcess.py +9 -0
- angr/procedures/win32/GetCommandLine.py +12 -0
- angr/procedures/win32/GetCurrentProcessId.py +7 -0
- angr/procedures/win32/GetCurrentThreadId.py +7 -0
- angr/procedures/win32/GetLastInputInfo.py +40 -0
- angr/procedures/win32/GetModuleHandle.py +29 -0
- angr/procedures/win32/GetProcessAffinityMask.py +37 -0
- angr/procedures/win32/InterlockedExchange.py +15 -0
- angr/procedures/win32/IsProcessorFeaturePresent.py +7 -0
- angr/procedures/win32/VirtualAlloc.py +114 -0
- angr/procedures/win32/VirtualProtect.py +60 -0
- angr/procedures/win32/__init__.py +3 -0
- angr/procedures/win32/critical_section.py +12 -0
- angr/procedures/win32/dynamic_loading.py +104 -0
- angr/procedures/win32/file_handles.py +47 -0
- angr/procedures/win32/gethostbyname.py +12 -0
- angr/procedures/win32/heap.py +45 -0
- angr/procedures/win32/is_bad_ptr.py +26 -0
- angr/procedures/win32/local_storage.py +88 -0
- angr/procedures/win32/mutex.py +11 -0
- angr/procedures/win32/sim_time.py +135 -0
- angr/procedures/win32/system_paths.py +35 -0
- angr/procedures/win32_kernel/ExAllocatePool.py +13 -0
- angr/procedures/win32_kernel/ExFreePoolWithTag.py +8 -0
- angr/procedures/win32_kernel/__fastfail.py +15 -0
- angr/procedures/win32_kernel/__init__.py +3 -0
- angr/procedures/win_user32/__init__.py +0 -0
- angr/procedures/win_user32/chars.py +15 -0
- angr/procedures/win_user32/keyboard.py +14 -0
- angr/procedures/win_user32/messagebox.py +49 -0
- angr/project.py +860 -0
- angr/protos/__init__.py +19 -0
- angr/protos/cfg_pb2.py +42 -0
- angr/protos/function_pb2.py +38 -0
- angr/protos/primitives_pb2.py +59 -0
- angr/protos/variables_pb2.py +55 -0
- angr/protos/xrefs_pb2.py +36 -0
- angr/py.typed +1 -0
- angr/rustylib.cpython-311-darwin.so +0 -0
- angr/serializable.py +66 -0
- angr/sim_manager.py +971 -0
- angr/sim_options.py +436 -0
- angr/sim_procedure.py +626 -0
- angr/sim_state.py +926 -0
- angr/sim_state_options.py +403 -0
- angr/sim_type.py +4026 -0
- angr/sim_variable.py +470 -0
- angr/simos/__init__.py +47 -0
- angr/simos/cgc.py +153 -0
- angr/simos/javavm.py +458 -0
- angr/simos/linux.py +509 -0
- angr/simos/simos.py +444 -0
- angr/simos/snimmuc_nxp.py +149 -0
- angr/simos/userland.py +163 -0
- angr/simos/windows.py +615 -0
- angr/simos/xbox.py +32 -0
- angr/slicer.py +352 -0
- angr/state_hierarchy.py +262 -0
- angr/state_plugins/__init__.py +84 -0
- angr/state_plugins/callstack.py +478 -0
- angr/state_plugins/cgc.py +155 -0
- angr/state_plugins/debug_variables.py +192 -0
- angr/state_plugins/filesystem.py +463 -0
- angr/state_plugins/gdb.py +148 -0
- angr/state_plugins/globals.py +65 -0
- angr/state_plugins/heap/__init__.py +15 -0
- angr/state_plugins/heap/heap_base.py +128 -0
- angr/state_plugins/heap/heap_brk.py +136 -0
- angr/state_plugins/heap/heap_freelist.py +213 -0
- angr/state_plugins/heap/heap_libc.py +46 -0
- angr/state_plugins/heap/heap_ptmalloc.py +620 -0
- angr/state_plugins/heap/utils.py +22 -0
- angr/state_plugins/history.py +564 -0
- angr/state_plugins/inspect.py +375 -0
- angr/state_plugins/javavm_classloader.py +134 -0
- angr/state_plugins/jni_references.py +95 -0
- angr/state_plugins/libc.py +1263 -0
- angr/state_plugins/light_registers.py +168 -0
- angr/state_plugins/log.py +84 -0
- angr/state_plugins/loop_data.py +92 -0
- angr/state_plugins/plugin.py +176 -0
- angr/state_plugins/posix.py +703 -0
- angr/state_plugins/preconstrainer.py +196 -0
- angr/state_plugins/scratch.py +173 -0
- angr/state_plugins/sim_action.py +326 -0
- angr/state_plugins/sim_action_object.py +271 -0
- angr/state_plugins/sim_event.py +59 -0
- angr/state_plugins/solver.py +1128 -0
- angr/state_plugins/symbolizer.py +291 -0
- angr/state_plugins/trace_additions.py +738 -0
- angr/state_plugins/uc_manager.py +94 -0
- angr/state_plugins/unicorn_engine.py +1920 -0
- angr/state_plugins/view.py +340 -0
- angr/storage/__init__.py +15 -0
- angr/storage/file.py +1210 -0
- angr/storage/memory_mixins/__init__.py +317 -0
- angr/storage/memory_mixins/actions_mixin.py +72 -0
- angr/storage/memory_mixins/address_concretization_mixin.py +384 -0
- angr/storage/memory_mixins/bvv_conversion_mixin.py +73 -0
- angr/storage/memory_mixins/clouseau_mixin.py +137 -0
- angr/storage/memory_mixins/conditional_store_mixin.py +25 -0
- angr/storage/memory_mixins/convenient_mappings_mixin.py +256 -0
- angr/storage/memory_mixins/default_filler_mixin.py +144 -0
- angr/storage/memory_mixins/dirty_addrs_mixin.py +11 -0
- angr/storage/memory_mixins/hex_dumper_mixin.py +82 -0
- angr/storage/memory_mixins/javavm_memory_mixin.py +392 -0
- angr/storage/memory_mixins/keyvalue_memory_mixin.py +43 -0
- angr/storage/memory_mixins/label_merger_mixin.py +31 -0
- angr/storage/memory_mixins/memory_mixin.py +175 -0
- angr/storage/memory_mixins/multi_value_merger_mixin.py +79 -0
- angr/storage/memory_mixins/name_resolution_mixin.py +67 -0
- angr/storage/memory_mixins/paged_memory/__init__.py +0 -0
- angr/storage/memory_mixins/paged_memory/page_backer_mixins.py +266 -0
- angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +743 -0
- angr/storage/memory_mixins/paged_memory/paged_memory_multivalue_mixin.py +65 -0
- angr/storage/memory_mixins/paged_memory/pages/__init__.py +26 -0
- angr/storage/memory_mixins/paged_memory/pages/base.py +31 -0
- angr/storage/memory_mixins/paged_memory/pages/cooperation.py +341 -0
- angr/storage/memory_mixins/paged_memory/pages/history_tracking_mixin.py +92 -0
- angr/storage/memory_mixins/paged_memory/pages/ispo_mixin.py +55 -0
- angr/storage/memory_mixins/paged_memory/pages/list_page.py +338 -0
- angr/storage/memory_mixins/paged_memory/pages/multi_values.py +324 -0
- angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +419 -0
- angr/storage/memory_mixins/paged_memory/pages/permissions_mixin.py +36 -0
- angr/storage/memory_mixins/paged_memory/pages/refcount_mixin.py +52 -0
- angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +529 -0
- angr/storage/memory_mixins/paged_memory/privileged_mixin.py +36 -0
- angr/storage/memory_mixins/paged_memory/stack_allocation_mixin.py +74 -0
- angr/storage/memory_mixins/regioned_memory/__init__.py +17 -0
- angr/storage/memory_mixins/regioned_memory/abstract_address_descriptor.py +36 -0
- angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +31 -0
- angr/storage/memory_mixins/regioned_memory/region_category_mixin.py +9 -0
- angr/storage/memory_mixins/regioned_memory/region_data.py +246 -0
- angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +241 -0
- angr/storage/memory_mixins/regioned_memory/regioned_address_concretization_mixin.py +119 -0
- angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +442 -0
- angr/storage/memory_mixins/regioned_memory/static_find_mixin.py +69 -0
- angr/storage/memory_mixins/simple_interface_mixin.py +71 -0
- angr/storage/memory_mixins/simplification_mixin.py +15 -0
- angr/storage/memory_mixins/size_resolution_mixin.py +143 -0
- angr/storage/memory_mixins/slotted_memory.py +140 -0
- angr/storage/memory_mixins/smart_find_mixin.py +161 -0
- angr/storage/memory_mixins/symbolic_merger_mixin.py +16 -0
- angr/storage/memory_mixins/top_merger_mixin.py +25 -0
- angr/storage/memory_mixins/underconstrained_mixin.py +67 -0
- angr/storage/memory_mixins/unwrapper_mixin.py +26 -0
- angr/storage/memory_object.py +195 -0
- angr/tablespecs.py +91 -0
- angr/unicornlib.dylib +0 -0
- angr/utils/__init__.py +46 -0
- angr/utils/ail.py +176 -0
- angr/utils/algo.py +34 -0
- angr/utils/balancer.py +776 -0
- angr/utils/bits.py +46 -0
- angr/utils/constants.py +9 -0
- angr/utils/cowdict.py +63 -0
- angr/utils/cpp.py +17 -0
- angr/utils/doms.py +150 -0
- angr/utils/dynamic_dictlist.py +89 -0
- angr/utils/endness.py +18 -0
- angr/utils/enums_conv.py +97 -0
- angr/utils/env.py +12 -0
- angr/utils/formatting.py +128 -0
- angr/utils/funcid.py +244 -0
- angr/utils/graph.py +981 -0
- angr/utils/lazy_import.py +13 -0
- angr/utils/library.py +236 -0
- angr/utils/loader.py +55 -0
- angr/utils/mp.py +66 -0
- angr/utils/orderedset.py +74 -0
- angr/utils/ssa/__init__.py +455 -0
- angr/utils/ssa/tmp_uses_collector.py +23 -0
- angr/utils/ssa/vvar_uses_collector.py +36 -0
- angr/utils/strings.py +20 -0
- angr/utils/tagged_interval_map.py +112 -0
- angr/utils/timing.py +74 -0
- angr/utils/types.py +193 -0
- angr/utils/vex.py +11 -0
- angr/vaults.py +367 -0
- angr-9.2.192.dist-info/METADATA +112 -0
- angr-9.2.192.dist-info/RECORD +1442 -0
- angr-9.2.192.dist-info/WHEEL +6 -0
- angr-9.2.192.dist-info/entry_points.txt +2 -0
- angr-9.2.192.dist-info/licenses/LICENSE +27 -0
- angr-9.2.192.dist-info/top_level.txt +1 -0
angr/analyses/ddg.py
ADDED
|
@@ -0,0 +1,1670 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import logging
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
|
|
5
|
+
import claripy
|
|
6
|
+
import networkx
|
|
7
|
+
import pyvex
|
|
8
|
+
|
|
9
|
+
from angr.analyses import Analysis, AnalysesHub
|
|
10
|
+
from angr.code_location import CodeLocation
|
|
11
|
+
from angr.errors import SimSolverModeError, SimUnsatError, AngrDDGError
|
|
12
|
+
from angr.sim_variable import (
|
|
13
|
+
SimRegisterVariable,
|
|
14
|
+
SimMemoryVariable,
|
|
15
|
+
SimTemporaryVariable,
|
|
16
|
+
SimConstantVariable,
|
|
17
|
+
SimStackVariable,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
l = logging.getLogger(name=__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AST:
|
|
24
|
+
"""
|
|
25
|
+
A mini implementation for AST
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, op, *operands):
|
|
29
|
+
self.op = op
|
|
30
|
+
self.operands = tuple(operands)
|
|
31
|
+
|
|
32
|
+
def __hash__(self):
|
|
33
|
+
return hash((self.op, self.operands))
|
|
34
|
+
|
|
35
|
+
def __eq__(self, other):
|
|
36
|
+
return type(other) is AST and other.op == self.op and other.operands == self.operands
|
|
37
|
+
|
|
38
|
+
def __repr__(self):
|
|
39
|
+
def _short_repr(a):
|
|
40
|
+
return a.short_repr
|
|
41
|
+
|
|
42
|
+
if len(self.operands) == 1:
|
|
43
|
+
return f"{self.op}{_short_repr(self.operands[0])}"
|
|
44
|
+
if len(self.operands) == 2:
|
|
45
|
+
return f"{_short_repr(self.operands[0])} {self.op} {_short_repr(self.operands[1])}"
|
|
46
|
+
return f"{self.op} ({self.operands})"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ProgramVariable:
|
|
50
|
+
"""
|
|
51
|
+
Describes a variable in the program at a specific location.
|
|
52
|
+
|
|
53
|
+
:ivar SimVariable variable: The variable.
|
|
54
|
+
:ivar CodeLocation location: Location of the variable.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(self, variable, location, initial=False, arch=None):
|
|
58
|
+
self.variable = variable
|
|
59
|
+
self.location = location
|
|
60
|
+
self.initial = initial
|
|
61
|
+
self._arch = arch # for pretty printing
|
|
62
|
+
|
|
63
|
+
def __hash__(self):
|
|
64
|
+
return hash((self.variable, self.location))
|
|
65
|
+
|
|
66
|
+
def __eq__(self, other):
|
|
67
|
+
if not isinstance(other, ProgramVariable):
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
return self.variable == other.variable and self.location == other.location
|
|
71
|
+
|
|
72
|
+
def __ne__(self, other):
|
|
73
|
+
return not self.__eq__(other)
|
|
74
|
+
|
|
75
|
+
def __repr__(self):
|
|
76
|
+
if self._arch is not None:
|
|
77
|
+
s = f"{{{self.variable} @ {self.location}}}"
|
|
78
|
+
else:
|
|
79
|
+
s = f"{{{self.variable} @ {self.location}}}"
|
|
80
|
+
return s
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def short_repr(self):
|
|
84
|
+
if self._arch is not None:
|
|
85
|
+
s = f"{{{self.variable}@{self.location.short_repr}}}"
|
|
86
|
+
else:
|
|
87
|
+
s = f"{{{self.variable}@{self.location.short_repr}}}"
|
|
88
|
+
return s
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class DDGJob:
|
|
92
|
+
def __init__(self, cfg_node, call_depth):
|
|
93
|
+
self.cfg_node = cfg_node
|
|
94
|
+
self.call_depth = call_depth
|
|
95
|
+
|
|
96
|
+
def __repr__(self):
|
|
97
|
+
return f"<DDGJob {self.cfg_node}, call_depth {self.call_depth}>"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class LiveDefinitions:
|
|
101
|
+
"""
|
|
102
|
+
A collection of live definitions with some handy interfaces for definition killing and lookups.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
def __init__(self):
|
|
106
|
+
"""
|
|
107
|
+
Constructor.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
# byte-to-byte mappings
|
|
111
|
+
# TODO: make it copy-on-write in order to save memory.
|
|
112
|
+
# TODO: options are either collections.ChainMap or a modified version of simuvex.SimPagedMemory
|
|
113
|
+
self._memory_map = defaultdict(set)
|
|
114
|
+
self._register_map = defaultdict(set)
|
|
115
|
+
self._defs = defaultdict(set)
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Overridden methods
|
|
119
|
+
#
|
|
120
|
+
|
|
121
|
+
def __contains__(self, variable):
|
|
122
|
+
return variable in self._defs
|
|
123
|
+
|
|
124
|
+
#
|
|
125
|
+
# Public methods
|
|
126
|
+
#
|
|
127
|
+
|
|
128
|
+
def branch(self):
|
|
129
|
+
"""
|
|
130
|
+
Create a branch of the current live definition collection.
|
|
131
|
+
|
|
132
|
+
:return: A new LiveDefinition instance.
|
|
133
|
+
:rtype: angr.analyses.ddg.LiveDefinitions
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
ld = LiveDefinitions()
|
|
137
|
+
ld._memory_map = self._memory_map.copy()
|
|
138
|
+
ld._register_map = self._register_map.copy()
|
|
139
|
+
ld._defs = self._defs.copy()
|
|
140
|
+
|
|
141
|
+
return ld
|
|
142
|
+
|
|
143
|
+
def copy(self):
|
|
144
|
+
"""
|
|
145
|
+
Make a hard copy of `self`.
|
|
146
|
+
|
|
147
|
+
:return: A new LiveDefinition instance.
|
|
148
|
+
:rtype: angr.analyses.ddg.LiveDefinitions
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
ld = LiveDefinitions()
|
|
152
|
+
ld._memory_map = self._memory_map.copy()
|
|
153
|
+
ld._register_map = self._register_map.copy()
|
|
154
|
+
ld._defs = self._defs.copy()
|
|
155
|
+
|
|
156
|
+
return ld
|
|
157
|
+
|
|
158
|
+
def add_def(self, variable, location, size_threshold=32):
|
|
159
|
+
"""
|
|
160
|
+
Add a new definition of variable.
|
|
161
|
+
|
|
162
|
+
:param SimVariable variable: The variable being defined.
|
|
163
|
+
:param CodeLocation location: Location of the variable being defined.
|
|
164
|
+
:param int size_threshold: The maximum bytes to consider for the variable.
|
|
165
|
+
:return: True if the definition was new, False otherwise
|
|
166
|
+
:rtype: bool
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
new_defs_added = False
|
|
170
|
+
|
|
171
|
+
if isinstance(variable, SimRegisterVariable):
|
|
172
|
+
if variable.reg is None:
|
|
173
|
+
l.warning("add_def: Got a None for a SimRegisterVariable. Consider fixing.")
|
|
174
|
+
return new_defs_added
|
|
175
|
+
|
|
176
|
+
size = min(variable.size, size_threshold)
|
|
177
|
+
offset = variable.reg
|
|
178
|
+
while offset < variable.reg + size:
|
|
179
|
+
if location not in self._register_map[offset]:
|
|
180
|
+
new_defs_added = True
|
|
181
|
+
self._register_map[offset].add(location)
|
|
182
|
+
offset += 1
|
|
183
|
+
|
|
184
|
+
self._defs[variable].add(location)
|
|
185
|
+
|
|
186
|
+
elif isinstance(variable, SimMemoryVariable):
|
|
187
|
+
size = min(variable.size, size_threshold)
|
|
188
|
+
offset = variable.addr
|
|
189
|
+
while offset < variable.addr + size:
|
|
190
|
+
if location not in self._memory_map[offset]:
|
|
191
|
+
new_defs_added = True
|
|
192
|
+
self._memory_map[offset].add(location)
|
|
193
|
+
offset += 1
|
|
194
|
+
|
|
195
|
+
self._defs[variable].add(location)
|
|
196
|
+
|
|
197
|
+
else:
|
|
198
|
+
l.error('Unsupported variable type "%s".', type(variable))
|
|
199
|
+
|
|
200
|
+
return new_defs_added
|
|
201
|
+
|
|
202
|
+
def add_defs(self, variable, locations, size_threshold=32):
|
|
203
|
+
"""
|
|
204
|
+
Add a collection of new definitions of a variable.
|
|
205
|
+
|
|
206
|
+
:param SimVariable variable: The variable being defined.
|
|
207
|
+
:param iterable locations: A collection of locations where the variable was defined.
|
|
208
|
+
:param int size_threshold: The maximum bytes to consider for the variable.
|
|
209
|
+
:return: True if any of the definition was new, False otherwise
|
|
210
|
+
:rtype: bool
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
new_defs_added = False
|
|
214
|
+
|
|
215
|
+
for loc in locations:
|
|
216
|
+
new_defs_added |= self.add_def(variable, loc, size_threshold=size_threshold)
|
|
217
|
+
|
|
218
|
+
return new_defs_added
|
|
219
|
+
|
|
220
|
+
def kill_def(self, variable, location, size_threshold=32):
|
|
221
|
+
"""
|
|
222
|
+
Add a new definition for variable and kill all previous definitions.
|
|
223
|
+
|
|
224
|
+
:param SimVariable variable: The variable to kill.
|
|
225
|
+
:param CodeLocation location: The location where this variable is defined.
|
|
226
|
+
:param int size_threshold: The maximum bytes to consider for the variable.
|
|
227
|
+
:return: None
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
if isinstance(variable, SimRegisterVariable):
|
|
231
|
+
if variable.reg is None:
|
|
232
|
+
l.warning("kill_def: Got a None for a SimRegisterVariable. Consider fixing.")
|
|
233
|
+
return
|
|
234
|
+
|
|
235
|
+
size = min(variable.size, size_threshold)
|
|
236
|
+
offset = variable.reg
|
|
237
|
+
while offset < variable.reg + size:
|
|
238
|
+
self._register_map[offset] = {location}
|
|
239
|
+
offset += 1
|
|
240
|
+
|
|
241
|
+
self._defs[variable] = {location}
|
|
242
|
+
|
|
243
|
+
elif isinstance(variable, SimMemoryVariable):
|
|
244
|
+
size = min(variable.size, size_threshold)
|
|
245
|
+
offset = variable.addr
|
|
246
|
+
while offset < variable.addr + size:
|
|
247
|
+
self._memory_map[offset] = {location}
|
|
248
|
+
offset += 1
|
|
249
|
+
|
|
250
|
+
self._defs[variable] = {location}
|
|
251
|
+
|
|
252
|
+
else:
|
|
253
|
+
l.error('Unsupported variable type "%s".', type(variable))
|
|
254
|
+
|
|
255
|
+
def lookup_defs(self, variable, size_threshold=32):
|
|
256
|
+
"""
|
|
257
|
+
Find all definitions of the variable.
|
|
258
|
+
|
|
259
|
+
:param SimVariable variable: The variable to lookup for.
|
|
260
|
+
:param int size_threshold: The maximum bytes to consider for the variable. For example, if the variable is 100
|
|
261
|
+
byte long, only the first `size_threshold` bytes are considered.
|
|
262
|
+
:return: A set of code locations where the variable is defined.
|
|
263
|
+
:rtype: set
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
live_def_locs = set()
|
|
267
|
+
|
|
268
|
+
if isinstance(variable, SimRegisterVariable):
|
|
269
|
+
if variable.reg is None:
|
|
270
|
+
l.warning("lookup_defs: Got a None for a SimRegisterVariable. Consider fixing.")
|
|
271
|
+
return live_def_locs
|
|
272
|
+
|
|
273
|
+
size = min(variable.size, size_threshold)
|
|
274
|
+
offset = variable.reg
|
|
275
|
+
while offset < variable.reg + size:
|
|
276
|
+
if offset in self._register_map:
|
|
277
|
+
live_def_locs |= self._register_map[offset]
|
|
278
|
+
offset += 1
|
|
279
|
+
|
|
280
|
+
elif isinstance(variable, SimMemoryVariable):
|
|
281
|
+
size = min(variable.size, size_threshold)
|
|
282
|
+
offset = variable.addr
|
|
283
|
+
while offset < variable.addr + size:
|
|
284
|
+
if offset in self._memory_map:
|
|
285
|
+
live_def_locs |= self._memory_map[offset]
|
|
286
|
+
offset += 1
|
|
287
|
+
|
|
288
|
+
else:
|
|
289
|
+
# umm unsupported variable type
|
|
290
|
+
l.error('Unsupported variable type "%s".', type(variable))
|
|
291
|
+
|
|
292
|
+
return live_def_locs
|
|
293
|
+
|
|
294
|
+
def items(self):
|
|
295
|
+
"""
|
|
296
|
+
An iterator that returns all live definitions.
|
|
297
|
+
|
|
298
|
+
:return: The iterator.
|
|
299
|
+
:rtype: iter
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
return self._defs.items()
|
|
303
|
+
|
|
304
|
+
def itervariables(self):
|
|
305
|
+
"""
|
|
306
|
+
An iterator that returns all live variables.
|
|
307
|
+
|
|
308
|
+
:return: The iterator.
|
|
309
|
+
:rtype: iter
|
|
310
|
+
"""
|
|
311
|
+
|
|
312
|
+
return self._defs.keys()
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
class DDGViewItem:
|
|
316
|
+
def __init__(self, ddg, variable, simplified=False):
|
|
317
|
+
self._ddg = ddg
|
|
318
|
+
self._variable = variable
|
|
319
|
+
self._simplified = simplified
|
|
320
|
+
|
|
321
|
+
@property
|
|
322
|
+
def depends_on(self):
|
|
323
|
+
graph = self._ddg.simplified_data_graph if self._simplified else self._ddg.data_graph
|
|
324
|
+
if self._variable in graph:
|
|
325
|
+
return [
|
|
326
|
+
self._to_viewitem(n)
|
|
327
|
+
for n, _, data in graph.in_edges(self._variable, data=True)
|
|
328
|
+
if data.get("type", None) != "kill"
|
|
329
|
+
]
|
|
330
|
+
return None
|
|
331
|
+
|
|
332
|
+
@property
|
|
333
|
+
def dependents(self):
|
|
334
|
+
graph = self._ddg.simplified_data_graph if self._simplified else self._ddg.data_graph
|
|
335
|
+
if self._variable in graph:
|
|
336
|
+
return [
|
|
337
|
+
self._to_viewitem(n)
|
|
338
|
+
for _, n, data in graph.in_edges(self._variable, data=True)
|
|
339
|
+
if data.get("type", None) != "kill"
|
|
340
|
+
]
|
|
341
|
+
return None
|
|
342
|
+
|
|
343
|
+
def __repr__(self):
|
|
344
|
+
return f"[{self._variable}, {len(self.dependents)} dependents, depends on {len(self.depends_on)}]"
|
|
345
|
+
|
|
346
|
+
def __eq__(self, other):
|
|
347
|
+
return (
|
|
348
|
+
isinstance(other, DDGViewItem)
|
|
349
|
+
and self._variable == other._variable
|
|
350
|
+
and self._simplified == other._simplified
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
def __hash__(self):
|
|
354
|
+
return hash(
|
|
355
|
+
(
|
|
356
|
+
self._ddg,
|
|
357
|
+
self._variable,
|
|
358
|
+
self._simplified,
|
|
359
|
+
)
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
def _to_viewitem(self, prog_var):
|
|
363
|
+
"""
|
|
364
|
+
Convert a ProgramVariable instance to a DDGViewItem object.
|
|
365
|
+
|
|
366
|
+
:param ProgramVariable prog_var: The ProgramVariable object to convert.
|
|
367
|
+
:return: The converted DDGViewItem object.
|
|
368
|
+
:rtype: DDGViewItem
|
|
369
|
+
"""
|
|
370
|
+
|
|
371
|
+
return DDGViewItem(self._ddg, prog_var, simplified=self._simplified)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
class DDGViewInstruction:
|
|
375
|
+
def __init__(self, cfg, ddg, insn_addr, simplified=False):
|
|
376
|
+
self._cfg = cfg
|
|
377
|
+
self._ddg = ddg
|
|
378
|
+
self._insn_addr = insn_addr
|
|
379
|
+
self._simplified = simplified
|
|
380
|
+
|
|
381
|
+
# shorthand
|
|
382
|
+
self._project = self._ddg.project
|
|
383
|
+
|
|
384
|
+
def __getitem__(self, key):
|
|
385
|
+
arch = self._project.arch
|
|
386
|
+
if key in arch.registers:
|
|
387
|
+
# it's a register name
|
|
388
|
+
reg_offset, size = arch.registers[key]
|
|
389
|
+
|
|
390
|
+
# obtain the CFGNode
|
|
391
|
+
cfg_node = self._cfg.model.get_any_node(self._insn_addr, anyaddr=True)
|
|
392
|
+
if cfg_node is None:
|
|
393
|
+
# not found
|
|
394
|
+
raise KeyError(f"CFGNode for instruction {self._insn_addr:#x} is not found.")
|
|
395
|
+
|
|
396
|
+
# determine the statement ID
|
|
397
|
+
vex_block = self._project.factory.block(
|
|
398
|
+
cfg_node.addr, size=cfg_node.size, opt_level=self._cfg._iropt_level
|
|
399
|
+
).vex
|
|
400
|
+
stmt_idx = None
|
|
401
|
+
insn_addr = cfg_node.addr
|
|
402
|
+
for i, stmt in enumerate(vex_block.statements):
|
|
403
|
+
if isinstance(stmt, pyvex.IRStmt.IMark):
|
|
404
|
+
insn_addr = stmt.addr + stmt.delta
|
|
405
|
+
elif insn_addr == self._insn_addr:
|
|
406
|
+
if isinstance(stmt, pyvex.IRStmt.Put) and stmt.offset == reg_offset:
|
|
407
|
+
stmt_idx = i
|
|
408
|
+
break
|
|
409
|
+
elif insn_addr > self._insn_addr:
|
|
410
|
+
break
|
|
411
|
+
|
|
412
|
+
if stmt_idx is None:
|
|
413
|
+
raise KeyError("Cannot find the statement.")
|
|
414
|
+
|
|
415
|
+
# create a program variable
|
|
416
|
+
variable = SimRegisterVariable(reg_offset, size)
|
|
417
|
+
location = CodeLocation(cfg_node.addr, stmt_idx, ins_addr=self._insn_addr)
|
|
418
|
+
pv = ProgramVariable(variable, location, arch=self._project.arch)
|
|
419
|
+
|
|
420
|
+
return DDGViewItem(self._ddg, pv, simplified=self._simplified)
|
|
421
|
+
return None
|
|
422
|
+
|
|
423
|
+
@property
|
|
424
|
+
def definitions(self) -> list[DDGViewItem]:
|
|
425
|
+
"""
|
|
426
|
+
Get all definitions located at the current instruction address.
|
|
427
|
+
|
|
428
|
+
:return: A list of ProgramVariable instances.
|
|
429
|
+
"""
|
|
430
|
+
|
|
431
|
+
defs = set()
|
|
432
|
+
|
|
433
|
+
graph = self._ddg.simplified_data_graph if self._simplified else self._ddg.data_graph
|
|
434
|
+
|
|
435
|
+
n: ProgramVariable
|
|
436
|
+
for n in graph.nodes():
|
|
437
|
+
if n.location.ins_addr == self._insn_addr:
|
|
438
|
+
defs.add(DDGViewItem(self._ddg, n, simplified=self._simplified))
|
|
439
|
+
|
|
440
|
+
return list(defs)
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
class DDGView:
|
|
444
|
+
"""
|
|
445
|
+
A view of the data dependence graph.
|
|
446
|
+
"""
|
|
447
|
+
|
|
448
|
+
def __init__(self, cfg, ddg, simplified=False):
|
|
449
|
+
self._cfg = cfg
|
|
450
|
+
self._ddg = ddg
|
|
451
|
+
self._simplified = simplified
|
|
452
|
+
|
|
453
|
+
# shorthand
|
|
454
|
+
self._project = self._ddg.project
|
|
455
|
+
|
|
456
|
+
def __getitem__(self, key):
|
|
457
|
+
if isinstance(key, int):
|
|
458
|
+
# instruction address
|
|
459
|
+
return DDGViewInstruction(self._cfg, self._ddg, key, simplified=self._simplified)
|
|
460
|
+
return None
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
class DDG(Analysis):
|
|
464
|
+
"""
|
|
465
|
+
This is a fast data dependence graph directly generated from our CFG analysis result. The only reason for its
|
|
466
|
+
existence is the speed. There is zero guarantee for being sound or accurate. You are supposed to use it only when
|
|
467
|
+
you want to track the simplest data dependence, and you do not care about soundness or accuracy.
|
|
468
|
+
|
|
469
|
+
For a better data dependence graph, please consider performing a better static analysis first (like Value-set
|
|
470
|
+
Analysis), and then construct a dependence graph on top of the analysis result (for example, the VFG in angr).
|
|
471
|
+
|
|
472
|
+
The DDG is based on a CFG, which should ideally be a CFGEmulated generated with the following options:
|
|
473
|
+
|
|
474
|
+
- keep_state=True to keep all input states
|
|
475
|
+
- state_add_options=angr.options.refs to store memory, register, and temporary value accesses
|
|
476
|
+
|
|
477
|
+
You may want to consider a high value for context_sensitivity_level as well when generating the CFG.
|
|
478
|
+
|
|
479
|
+
Also note that since we are using states from CFG, any improvement in analysis performed on CFG (like a points-to
|
|
480
|
+
analysis) will directly benefit the DDG.
|
|
481
|
+
"""
|
|
482
|
+
|
|
483
|
+
def __init__(self, cfg, start=None, call_depth=None, block_addrs=None):
|
|
484
|
+
"""
|
|
485
|
+
:param cfg: Control flow graph. Please make sure each node has an associated `state` with it, e.g. by
|
|
486
|
+
passing the keep_state=True and state_add_options=angr.options.refs arguments to
|
|
487
|
+
CFGEmulated.
|
|
488
|
+
:param start: An address, Specifies where we start the generation of this data dependence graph.
|
|
489
|
+
:param call_depth: None or integers. A non-negative integer specifies how deep we would like to track in the
|
|
490
|
+
call tree. None disables call_depth limit.
|
|
491
|
+
:param iterable or None block_addrs: A collection of block addresses that the DDG analysis should be performed
|
|
492
|
+
on.
|
|
493
|
+
"""
|
|
494
|
+
|
|
495
|
+
# Sanity check
|
|
496
|
+
if not cfg._keep_state:
|
|
497
|
+
raise AngrDDGError('CFG must have "keep_state" set to True.')
|
|
498
|
+
|
|
499
|
+
self._cfg = cfg
|
|
500
|
+
self._start = self.project.entry if start is None else start
|
|
501
|
+
self._call_depth = call_depth
|
|
502
|
+
self._block_addrs = block_addrs
|
|
503
|
+
|
|
504
|
+
# analysis output
|
|
505
|
+
self._stmt_graph = networkx.DiGraph()
|
|
506
|
+
self._data_graph = networkx.DiGraph()
|
|
507
|
+
self._simplified_data_graph = None
|
|
508
|
+
|
|
509
|
+
self._ast_graph = networkx.DiGraph() # A mapping of ProgramVariable to ASTs
|
|
510
|
+
|
|
511
|
+
self._symbolic_mem_ops = set()
|
|
512
|
+
|
|
513
|
+
# Data dependency graph per function
|
|
514
|
+
self._function_data_dependencies = None
|
|
515
|
+
|
|
516
|
+
self.view = DDGView(self._cfg, self, simplified=False)
|
|
517
|
+
self.simple_view = DDGView(self._cfg, self, simplified=True)
|
|
518
|
+
|
|
519
|
+
# Local variables
|
|
520
|
+
self._live_defs = None
|
|
521
|
+
self._temp_variables = None
|
|
522
|
+
self._temp_register_symbols = None
|
|
523
|
+
self._temp_edges = None
|
|
524
|
+
self._temp_register_symbols = None
|
|
525
|
+
self._variables_per_statement = None
|
|
526
|
+
self._custom_data_per_statement = None
|
|
527
|
+
self._register_edges = None
|
|
528
|
+
|
|
529
|
+
# Begin construction!
|
|
530
|
+
self._construct()
|
|
531
|
+
|
|
532
|
+
#
|
|
533
|
+
# Properties
|
|
534
|
+
#
|
|
535
|
+
|
|
536
|
+
@property
|
|
537
|
+
def graph(self):
|
|
538
|
+
"""
|
|
539
|
+
:returns: A networkx DiGraph instance representing the dependence relations between statements.
|
|
540
|
+
:rtype: networkx.DiGraph
|
|
541
|
+
"""
|
|
542
|
+
|
|
543
|
+
return self._stmt_graph
|
|
544
|
+
|
|
545
|
+
@property
|
|
546
|
+
def data_graph(self):
|
|
547
|
+
"""
|
|
548
|
+
Get the data dependence graph.
|
|
549
|
+
|
|
550
|
+
:return: A networkx DiGraph instance representing data dependence.
|
|
551
|
+
:rtype: networkx.DiGraph
|
|
552
|
+
"""
|
|
553
|
+
|
|
554
|
+
return self._data_graph
|
|
555
|
+
|
|
556
|
+
@property
|
|
557
|
+
def simplified_data_graph(self):
|
|
558
|
+
"""
|
|
559
|
+
|
|
560
|
+
:return:
|
|
561
|
+
"""
|
|
562
|
+
|
|
563
|
+
if self._simplified_data_graph is None:
|
|
564
|
+
self._simplified_data_graph = self._simplify_data_graph(self.data_graph)
|
|
565
|
+
|
|
566
|
+
return self._simplified_data_graph
|
|
567
|
+
|
|
568
|
+
@property
|
|
569
|
+
def ast_graph(self):
|
|
570
|
+
return self._ast_graph
|
|
571
|
+
|
|
572
|
+
#
|
|
573
|
+
# Public methods
|
|
574
|
+
#
|
|
575
|
+
|
|
576
|
+
def pp(self):
|
|
577
|
+
"""
|
|
578
|
+
Pretty printing.
|
|
579
|
+
"""
|
|
580
|
+
# TODO: make it prettier
|
|
581
|
+
for src, dst, data in self.graph.edges(data=True):
|
|
582
|
+
print(f"{src} <-- {dst}, {data}")
|
|
583
|
+
|
|
584
|
+
def dbg_repr(self):
|
|
585
|
+
"""
|
|
586
|
+
Representation for debugging.
|
|
587
|
+
"""
|
|
588
|
+
# TODO:
|
|
589
|
+
return str(self.graph)
|
|
590
|
+
|
|
591
|
+
def __contains__(self, code_location):
|
|
592
|
+
"""
|
|
593
|
+
Returns whether `code_location` is in the graph.
|
|
594
|
+
|
|
595
|
+
:param code_location: A CodeLocation instance.
|
|
596
|
+
:returns: True/False
|
|
597
|
+
"""
|
|
598
|
+
|
|
599
|
+
return code_location in self.graph
|
|
600
|
+
|
|
601
|
+
def get_predecessors(self, code_location):
|
|
602
|
+
"""
|
|
603
|
+
Returns all predecessors of the code location.
|
|
604
|
+
|
|
605
|
+
:param code_location: A CodeLocation instance.
|
|
606
|
+
:returns: A list of all predecessors.
|
|
607
|
+
"""
|
|
608
|
+
|
|
609
|
+
return self.graph.predecessors(code_location)
|
|
610
|
+
|
|
611
|
+
def function_dependency_graph(self, func):
|
|
612
|
+
"""
|
|
613
|
+
Get a dependency graph for the function `func`.
|
|
614
|
+
|
|
615
|
+
:param func: The Function object in CFG.function_manager.
|
|
616
|
+
:returns: A networkx.DiGraph instance.
|
|
617
|
+
"""
|
|
618
|
+
|
|
619
|
+
if self._function_data_dependencies is None:
|
|
620
|
+
self._build_function_dependency_graphs()
|
|
621
|
+
|
|
622
|
+
if func in self._function_data_dependencies:
|
|
623
|
+
return self._function_data_dependencies[func]
|
|
624
|
+
|
|
625
|
+
# Not found
|
|
626
|
+
return None
|
|
627
|
+
|
|
628
|
+
def data_sub_graph(self, pv, simplified=True, killing_edges=False, excluding_types=None):
|
|
629
|
+
"""
|
|
630
|
+
Get a subgraph from the data graph or the simplified data graph that starts from node pv.
|
|
631
|
+
|
|
632
|
+
:param ProgramVariable pv: The starting point of the subgraph.
|
|
633
|
+
:param bool simplified: When True, the simplified data graph is used, otherwise the data graph is used.
|
|
634
|
+
:param bool killing_edges: Are killing edges included or not.
|
|
635
|
+
:param iterable excluding_types: Excluding edges whose types are among those excluded types.
|
|
636
|
+
:return: A subgraph.
|
|
637
|
+
:rtype: networkx.MultiDiGraph
|
|
638
|
+
"""
|
|
639
|
+
|
|
640
|
+
result = networkx.MultiDiGraph()
|
|
641
|
+
result.add_node(pv)
|
|
642
|
+
|
|
643
|
+
base_graph = self.simplified_data_graph if simplified else self.data_graph
|
|
644
|
+
if pv not in base_graph:
|
|
645
|
+
return result
|
|
646
|
+
|
|
647
|
+
# traverse all edges and add them to the result graph if needed
|
|
648
|
+
queue = [pv]
|
|
649
|
+
traversed = set()
|
|
650
|
+
while queue:
|
|
651
|
+
elem = queue[0]
|
|
652
|
+
queue = queue[1:]
|
|
653
|
+
if elem in traversed:
|
|
654
|
+
continue
|
|
655
|
+
traversed.add(elem)
|
|
656
|
+
|
|
657
|
+
out_edges = base_graph.out_edges(elem, data=True)
|
|
658
|
+
|
|
659
|
+
if not killing_edges:
|
|
660
|
+
# remove killing edges
|
|
661
|
+
out_edges = [(a, b, data) for a, b, data in out_edges if "type" not in data or data["type"] != "kill"]
|
|
662
|
+
|
|
663
|
+
if excluding_types:
|
|
664
|
+
out_edges = [
|
|
665
|
+
(a, b, data)
|
|
666
|
+
for a, b, data in out_edges
|
|
667
|
+
if "type" not in data or data["type"] not in excluding_types
|
|
668
|
+
]
|
|
669
|
+
|
|
670
|
+
for src, dst, data in out_edges:
|
|
671
|
+
result.add_edge(src, dst, **data)
|
|
672
|
+
|
|
673
|
+
if dst not in traversed:
|
|
674
|
+
queue.append(dst)
|
|
675
|
+
|
|
676
|
+
return result
|
|
677
|
+
|
|
678
|
+
#
|
|
679
|
+
# Private methods
|
|
680
|
+
#
|
|
681
|
+
|
|
682
|
+
def _construct(self):
|
|
683
|
+
"""
|
|
684
|
+
Construct the data dependence graph.
|
|
685
|
+
|
|
686
|
+
We track the following types of dependence:
|
|
687
|
+
- (Intra-IRSB) temporary variable dependencies
|
|
688
|
+
- Register dependencies
|
|
689
|
+
- Memory dependencies, although it's very limited. See below.
|
|
690
|
+
|
|
691
|
+
We track the following types of memory access:
|
|
692
|
+
- (Intra-functional) Stack read/write.
|
|
693
|
+
Trace changes of stack pointers inside a function, and the dereferences of stack pointers.
|
|
694
|
+
- (Inter-functional) Stack read/write.
|
|
695
|
+
- (Global) Static memory positions.
|
|
696
|
+
Keep a map of all accessible memory positions to their source statements per function. After that, we
|
|
697
|
+
traverse the CFG and link each pair of reads/writes together in the order of control-flow.
|
|
698
|
+
|
|
699
|
+
We do not track the following types of memory access
|
|
700
|
+
- Symbolic memory access
|
|
701
|
+
Well, they cannot be tracked under fastpath mode (which is the mode we are generating the CTF) anyways.
|
|
702
|
+
"""
|
|
703
|
+
|
|
704
|
+
worklist = []
|
|
705
|
+
worklist_set = set()
|
|
706
|
+
|
|
707
|
+
# Initialize the worklist
|
|
708
|
+
if self._start is None:
|
|
709
|
+
# initial nodes are those nodes in CFG that has no in-degrees
|
|
710
|
+
for n in self._cfg.graph.nodes():
|
|
711
|
+
if self._cfg.graph.in_degree(n) == 0:
|
|
712
|
+
# Put it into the worklist
|
|
713
|
+
job = DDGJob(n, 0)
|
|
714
|
+
self._worklist_append(job, worklist, worklist_set)
|
|
715
|
+
else:
|
|
716
|
+
for n in self._cfg.model.get_all_nodes(self._start):
|
|
717
|
+
job = DDGJob(n, 0)
|
|
718
|
+
self._worklist_append(job, worklist, worklist_set)
|
|
719
|
+
|
|
720
|
+
# A dict storing defs set
|
|
721
|
+
# DDGJob -> LiveDefinition
|
|
722
|
+
live_defs_per_node = {}
|
|
723
|
+
|
|
724
|
+
while worklist:
|
|
725
|
+
# Pop out a node
|
|
726
|
+
ddg_job = worklist[0]
|
|
727
|
+
l.debug("Processing %s.", ddg_job)
|
|
728
|
+
node, call_depth = ddg_job.cfg_node, ddg_job.call_depth
|
|
729
|
+
worklist = worklist[1:]
|
|
730
|
+
worklist_set.remove(node)
|
|
731
|
+
|
|
732
|
+
# Grab all final states. There are usually more than one (one state for each successor), and we gotta
|
|
733
|
+
# process all of them
|
|
734
|
+
final_states = node.final_states
|
|
735
|
+
|
|
736
|
+
if node in live_defs_per_node:
|
|
737
|
+
live_defs = live_defs_per_node[node]
|
|
738
|
+
else:
|
|
739
|
+
live_defs = LiveDefinitions()
|
|
740
|
+
live_defs_per_node[node] = live_defs
|
|
741
|
+
|
|
742
|
+
successing_nodes = list(self._cfg.graph.successors(node))
|
|
743
|
+
|
|
744
|
+
# try to assign every final state to a successor and vice versa
|
|
745
|
+
match_suc = defaultdict(bool)
|
|
746
|
+
match_state = defaultdict(set)
|
|
747
|
+
|
|
748
|
+
for suc in successing_nodes:
|
|
749
|
+
matched = False
|
|
750
|
+
for state in final_states:
|
|
751
|
+
try:
|
|
752
|
+
if state.solver.eval(state.ip) == suc.addr:
|
|
753
|
+
match_suc[suc.addr] = True
|
|
754
|
+
match_state[state].add(suc)
|
|
755
|
+
matched = True
|
|
756
|
+
except (SimUnsatError, SimSolverModeError, ZeroDivisionError):
|
|
757
|
+
# ignore
|
|
758
|
+
matched = matched
|
|
759
|
+
if not matched:
|
|
760
|
+
break
|
|
761
|
+
|
|
762
|
+
# whether all final states could be matched to a successor and vice versa
|
|
763
|
+
matches = len(match_suc) == len(successing_nodes) and len(match_state) == len(final_states)
|
|
764
|
+
|
|
765
|
+
for state in final_states:
|
|
766
|
+
if state.history.jumpkind == "Ijk_FakeRet" and len(final_states) > 1:
|
|
767
|
+
# Skip fakerets if there are other control flow transitions available
|
|
768
|
+
continue
|
|
769
|
+
|
|
770
|
+
new_call_depth = call_depth
|
|
771
|
+
if state.history.jumpkind == "Ijk_Call":
|
|
772
|
+
new_call_depth += 1
|
|
773
|
+
elif state.history.jumpkind == "Ijk_Ret":
|
|
774
|
+
new_call_depth -= 1
|
|
775
|
+
|
|
776
|
+
if self._call_depth is not None and call_depth > self._call_depth:
|
|
777
|
+
l.debug("Do not trace into %s due to the call depth limit", state.ip)
|
|
778
|
+
continue
|
|
779
|
+
|
|
780
|
+
new_defs = self._track(state, live_defs, node.irsb.statements if node.irsb is not None else None)
|
|
781
|
+
|
|
782
|
+
# corresponding_successors = [n for n in successing_nodes if
|
|
783
|
+
# not state.ip.symbolic and n.addr == state.solver.eval(state.ip)]
|
|
784
|
+
# if not corresponding_successors:
|
|
785
|
+
# continue
|
|
786
|
+
|
|
787
|
+
changed = False
|
|
788
|
+
|
|
789
|
+
# if every successor can be matched with one or more final states (by IP address),
|
|
790
|
+
# only take over the LiveDefinition of matching states
|
|
791
|
+
add_state_to_sucs = match_state[state] if matches else successing_nodes
|
|
792
|
+
|
|
793
|
+
for successing_node in add_state_to_sucs:
|
|
794
|
+
if (state.history.jumpkind == "Ijk_Call" or state.history.jumpkind.startswith("Ijk_Sys")) and (
|
|
795
|
+
state.ip.symbolic or successing_node.addr != state.solver.eval(state.ip)
|
|
796
|
+
):
|
|
797
|
+
suc_new_defs = self._filter_defs_at_call_sites(new_defs)
|
|
798
|
+
else:
|
|
799
|
+
suc_new_defs = new_defs
|
|
800
|
+
|
|
801
|
+
if successing_node in live_defs_per_node:
|
|
802
|
+
defs_for_next_node = live_defs_per_node[successing_node]
|
|
803
|
+
else:
|
|
804
|
+
defs_for_next_node = LiveDefinitions()
|
|
805
|
+
live_defs_per_node[successing_node] = defs_for_next_node
|
|
806
|
+
|
|
807
|
+
for var, code_loc_set in suc_new_defs.items():
|
|
808
|
+
# l.debug("Adding %d new definitions for variable %s.", len(code_loc_set), var)
|
|
809
|
+
changed |= defs_for_next_node.add_defs(var, code_loc_set)
|
|
810
|
+
|
|
811
|
+
if changed and (
|
|
812
|
+
(self._call_depth is None)
|
|
813
|
+
or (self._call_depth is not None and 0 <= new_call_depth <= self._call_depth)
|
|
814
|
+
):
|
|
815
|
+
# Put all reachable successors back to our work-list again
|
|
816
|
+
for successor in self._cfg.model.get_all_successors(node):
|
|
817
|
+
nw = DDGJob(successor, new_call_depth)
|
|
818
|
+
self._worklist_append(nw, worklist, worklist_set)
|
|
819
|
+
|
|
820
|
+
def _track(self, state, live_defs, statements):
|
|
821
|
+
"""
|
|
822
|
+
Given all live definitions prior to this program point, track the changes, and return a new list of live
|
|
823
|
+
definitions. We scan through the action list of the new state to track the changes.
|
|
824
|
+
|
|
825
|
+
:param state: The input state at that program point.
|
|
826
|
+
:param live_defs: All live definitions prior to reaching this program point.
|
|
827
|
+
:param list statements: A list of VEX statements.
|
|
828
|
+
:returns: A list of new live definitions.
|
|
829
|
+
:rtype: angr.analyses.ddg.LiveDefinitions
|
|
830
|
+
"""
|
|
831
|
+
|
|
832
|
+
# Make a copy of live_defs
|
|
833
|
+
self._live_defs = live_defs.copy()
|
|
834
|
+
|
|
835
|
+
action_list = list(state.history.recent_actions)
|
|
836
|
+
|
|
837
|
+
# Since all temporary variables are local, we simply track them in a dict
|
|
838
|
+
self._temp_variables = {}
|
|
839
|
+
self._temp_register_symbols = {}
|
|
840
|
+
|
|
841
|
+
# All dependence edges are added to the graph either at the end of this method, or when they are going to be
|
|
842
|
+
# overwritten by a new edge. This is because we sometimes have to modify a previous edge (e.g. add new labels
|
|
843
|
+
# to the edge)
|
|
844
|
+
self._temp_edges = defaultdict(list)
|
|
845
|
+
self._register_edges = defaultdict(list)
|
|
846
|
+
|
|
847
|
+
last_statement_id = None
|
|
848
|
+
self._variables_per_statement = (
|
|
849
|
+
None # program variables read out in the same statement. we keep a copy of those variables here so
|
|
850
|
+
)
|
|
851
|
+
# we can link it to the tmp_write action right afterwards
|
|
852
|
+
self._custom_data_per_statement = None
|
|
853
|
+
|
|
854
|
+
for a in action_list:
|
|
855
|
+
if last_statement_id is None or last_statement_id != a.stmt_idx:
|
|
856
|
+
# update statement ID
|
|
857
|
+
last_statement_id = a.stmt_idx
|
|
858
|
+
statement = (
|
|
859
|
+
statements[last_statement_id] if statements and last_statement_id < len(statements) else None
|
|
860
|
+
)
|
|
861
|
+
|
|
862
|
+
# initialize all per-statement data structures
|
|
863
|
+
self._variables_per_statement = []
|
|
864
|
+
self._custom_data_per_statement = None
|
|
865
|
+
|
|
866
|
+
if a.sim_procedure is None:
|
|
867
|
+
current_code_location = CodeLocation(a.bbl_addr, a.stmt_idx, ins_addr=a.ins_addr)
|
|
868
|
+
else:
|
|
869
|
+
current_code_location = CodeLocation(None, None, sim_procedure=a.sim_procedure)
|
|
870
|
+
|
|
871
|
+
if a.type == "exit":
|
|
872
|
+
self._handle_exit(a, current_code_location, state, statement)
|
|
873
|
+
elif a.type == "operation":
|
|
874
|
+
self._handle_operation(a, current_code_location, state, statement)
|
|
875
|
+
elif a.type == "constraint":
|
|
876
|
+
pass
|
|
877
|
+
else:
|
|
878
|
+
handler_name = f"_handle_{a.type}_{a.action}"
|
|
879
|
+
if hasattr(self, handler_name):
|
|
880
|
+
getattr(self, handler_name)(a, current_code_location, state, statement)
|
|
881
|
+
else:
|
|
882
|
+
l.debug("Skip an unsupported action %s.", a)
|
|
883
|
+
|
|
884
|
+
return self._live_defs
|
|
885
|
+
|
|
886
|
+
def _def_lookup(self, variable): # pylint:disable=no-self-use
|
|
887
|
+
"""
|
|
888
|
+
This is a backward lookup in the previous defs. Note that, as we are using VSA, it is possible that `variable`
|
|
889
|
+
is affected by several definitions.
|
|
890
|
+
|
|
891
|
+
:param angr.analyses.ddg.LiveDefinitions live_defs:
|
|
892
|
+
The collection of live definitions.
|
|
893
|
+
:param SimVariable: The variable to lookup for definitions.
|
|
894
|
+
:returns: A dict {stmt:labels} where label is the number of individual addresses of `addr_list` (or
|
|
895
|
+
the actual set of addresses depending on the keep_addrs flag) that are definted by stmt.
|
|
896
|
+
"""
|
|
897
|
+
|
|
898
|
+
prevdefs = {}
|
|
899
|
+
|
|
900
|
+
for code_loc in self._live_defs.lookup_defs(variable):
|
|
901
|
+
# Label edges with cardinality or actual sets of addresses
|
|
902
|
+
if isinstance(variable, SimMemoryVariable):
|
|
903
|
+
type_ = "mem"
|
|
904
|
+
elif isinstance(variable, SimRegisterVariable):
|
|
905
|
+
type_ = "reg"
|
|
906
|
+
else:
|
|
907
|
+
raise AngrDDGError(f"Unknown variable type {type(variable)}")
|
|
908
|
+
|
|
909
|
+
prevdefs[code_loc] = {"type": type_, "data": variable}
|
|
910
|
+
|
|
911
|
+
return prevdefs
|
|
912
|
+
|
|
913
|
+
def _kill(self, variable, code_loc): # pylint:disable=no-self-use
|
|
914
|
+
"""
|
|
915
|
+
Kill previous defs. addr_list is a list of normalized addresses.
|
|
916
|
+
"""
|
|
917
|
+
|
|
918
|
+
# Case 1: address perfectly match, we kill
|
|
919
|
+
# Case 2: a is a subset of the original address
|
|
920
|
+
# Case 3: a is a superset of the original address
|
|
921
|
+
|
|
922
|
+
# the previous definition is killed. mark it in data graph.
|
|
923
|
+
|
|
924
|
+
if variable in self._live_defs:
|
|
925
|
+
for loc in self._live_defs.lookup_defs(variable):
|
|
926
|
+
pv = ProgramVariable(variable, loc, arch=self.project.arch)
|
|
927
|
+
self._data_graph_add_edge(pv, ProgramVariable(variable, code_loc, arch=self.project.arch), type="kill")
|
|
928
|
+
|
|
929
|
+
self._live_defs.kill_def(variable, code_loc)
|
|
930
|
+
|
|
931
|
+
def _get_register_size(self, reg_offset):
|
|
932
|
+
"""
|
|
933
|
+
Get the size of a register.
|
|
934
|
+
|
|
935
|
+
:param int reg_offset: Offset of the register.
|
|
936
|
+
:return: Size in bytes.
|
|
937
|
+
:rtype: int
|
|
938
|
+
"""
|
|
939
|
+
|
|
940
|
+
# TODO: support registers that are not aligned
|
|
941
|
+
if reg_offset in self.project.arch.register_names:
|
|
942
|
+
reg_name = self.project.arch.register_names[reg_offset]
|
|
943
|
+
return self.project.arch.registers[reg_name][1]
|
|
944
|
+
|
|
945
|
+
l.warning(
|
|
946
|
+
"_get_register_size(): unsupported register offset %d. Assume size 1. "
|
|
947
|
+
"More register name mappings should be implemented in archinfo.",
|
|
948
|
+
reg_offset,
|
|
949
|
+
)
|
|
950
|
+
return 1
|
|
951
|
+
|
|
952
|
+
#
|
|
953
|
+
# Action handling
|
|
954
|
+
#
|
|
955
|
+
|
|
956
|
+
@staticmethod
|
|
957
|
+
def _get_actual_addrs(action, state):
|
|
958
|
+
"""
|
|
959
|
+
For memory actions, get a list of addresses it operates on.
|
|
960
|
+
|
|
961
|
+
:param SimAction action: The action object to work with.
|
|
962
|
+
:return: A list of addresses that are accessed with that action.
|
|
963
|
+
:rtype: list
|
|
964
|
+
"""
|
|
965
|
+
|
|
966
|
+
if action.actual_addrs is None:
|
|
967
|
+
# For now, mem reads don't necessarily have actual_addrs set properly
|
|
968
|
+
try:
|
|
969
|
+
addr_list = {state.solver.eval(action.addr.ast)}
|
|
970
|
+
except (SimSolverModeError, SimUnsatError, ZeroDivisionError):
|
|
971
|
+
# FIXME: ZeroDivisionError should have been caught by claripy and simuvex.
|
|
972
|
+
# FIXME: see claripy issue #75. this is just a temporary workaround.
|
|
973
|
+
# it's symbolic... just continue
|
|
974
|
+
addr_list = {0x60000000} # TODO: this is a random address that I pick. Fix it.
|
|
975
|
+
else:
|
|
976
|
+
addr_list = set(action.actual_addrs)
|
|
977
|
+
|
|
978
|
+
return addr_list
|
|
979
|
+
|
|
980
|
+
def _create_memory_variable(self, action, addr, addrs):
|
|
981
|
+
"""
|
|
982
|
+
Create a SimStackVariable or SimMemoryVariable based on action objects and its address.
|
|
983
|
+
|
|
984
|
+
:param SimAction action: The action to work with.
|
|
985
|
+
:param int addr: The address of the memory variable in creation.
|
|
986
|
+
:param list addrs: A list of all addresses that the action was effective on.
|
|
987
|
+
:return:
|
|
988
|
+
"""
|
|
989
|
+
|
|
990
|
+
variable = None
|
|
991
|
+
if len(addrs) == 1 and len(action.addr.tmp_deps) == 1:
|
|
992
|
+
addr_tmp = next(iter(action.addr.tmp_deps))
|
|
993
|
+
if addr_tmp in self._temp_register_symbols:
|
|
994
|
+
# it must be a stack variable
|
|
995
|
+
sort, offset = self._temp_register_symbols[addr_tmp]
|
|
996
|
+
base_addr = addr - offset
|
|
997
|
+
if base_addr < 0:
|
|
998
|
+
base_addr += 1 << self.project.arch.bits
|
|
999
|
+
variable = SimStackVariable(offset, action.size.ast // 8, base=sort, base_addr=base_addr)
|
|
1000
|
+
|
|
1001
|
+
if variable is None:
|
|
1002
|
+
variable = SimMemoryVariable(addr, action.size.ast // 8)
|
|
1003
|
+
|
|
1004
|
+
return variable
|
|
1005
|
+
|
|
1006
|
+
def _make_edges(self, action, prog_var):
|
|
1007
|
+
"""
|
|
1008
|
+
|
|
1009
|
+
:param SimAction action:
|
|
1010
|
+
:param ProgramVariable prog_var:
|
|
1011
|
+
:return:
|
|
1012
|
+
"""
|
|
1013
|
+
|
|
1014
|
+
# For each of its register dependency and data dependency, we annotate the corresponding edge
|
|
1015
|
+
for reg_offset in action.addr.reg_deps:
|
|
1016
|
+
self._stmt_graph_annotate_edges(self._register_edges[reg_offset], subtype="mem_addr")
|
|
1017
|
+
reg_variable = SimRegisterVariable(reg_offset, self._get_register_size(reg_offset))
|
|
1018
|
+
prev_defs = self._def_lookup(reg_variable)
|
|
1019
|
+
for loc, _ in prev_defs.items():
|
|
1020
|
+
v = ProgramVariable(reg_variable, loc, arch=self.project.arch)
|
|
1021
|
+
self._data_graph_add_edge(v, prog_var, type="mem_addr")
|
|
1022
|
+
|
|
1023
|
+
for tmp in action.addr.tmp_deps:
|
|
1024
|
+
self._stmt_graph_annotate_edges(self._temp_edges[tmp], subtype="mem_addr")
|
|
1025
|
+
if tmp in self._temp_variables:
|
|
1026
|
+
self._data_graph_add_edge(self._temp_variables[tmp], prog_var, type="mem_addr")
|
|
1027
|
+
|
|
1028
|
+
if not action.data.reg_deps and not action.data.tmp_deps:
|
|
1029
|
+
# might be a constant assignment
|
|
1030
|
+
v: claripy.ast.BV = action.data.ast
|
|
1031
|
+
if not v.symbolic:
|
|
1032
|
+
const_var = SimConstantVariable(value=v.concrete_value, size=v.size())
|
|
1033
|
+
const_progvar = ProgramVariable(const_var, prog_var.location)
|
|
1034
|
+
self._data_graph_add_edge(const_progvar, prog_var, type="mem_data")
|
|
1035
|
+
|
|
1036
|
+
else:
|
|
1037
|
+
for reg_offset in action.data.reg_deps:
|
|
1038
|
+
self._stmt_graph_annotate_edges(self._register_edges[reg_offset], subtype="mem_data")
|
|
1039
|
+
reg_variable = SimRegisterVariable(reg_offset, self._get_register_size(reg_offset))
|
|
1040
|
+
prev_defs = self._def_lookup(reg_variable)
|
|
1041
|
+
for loc, _ in prev_defs.items():
|
|
1042
|
+
v = ProgramVariable(reg_variable, loc, arch=self.project.arch)
|
|
1043
|
+
self._data_graph_add_edge(v, prog_var, type="mem_data")
|
|
1044
|
+
|
|
1045
|
+
for tmp in action.data.tmp_deps:
|
|
1046
|
+
self._stmt_graph_annotate_edges(self._temp_edges[tmp], subtype="mem_data")
|
|
1047
|
+
if tmp in self._temp_variables:
|
|
1048
|
+
self._data_graph_add_edge(self._temp_variables[tmp], prog_var, type="mem_data")
|
|
1049
|
+
|
|
1050
|
+
def _handle_mem_read(self, action, code_location, state, statement): # pylint:disable=unused-argument
|
|
1051
|
+
addrs = self._get_actual_addrs(action, state)
|
|
1052
|
+
|
|
1053
|
+
for addr in addrs:
|
|
1054
|
+
variable = self._create_memory_variable(action, addr, addrs)
|
|
1055
|
+
|
|
1056
|
+
variables = []
|
|
1057
|
+
|
|
1058
|
+
# get all definitions
|
|
1059
|
+
defs = self._def_lookup(variable)
|
|
1060
|
+
|
|
1061
|
+
if defs:
|
|
1062
|
+
# for each definition, create an edge on the graph
|
|
1063
|
+
for definition_location, labels in defs.items():
|
|
1064
|
+
self._stmt_graph_add_edge(definition_location, code_location, **labels)
|
|
1065
|
+
pv = ProgramVariable(variable, definition_location, arch=self.project.arch)
|
|
1066
|
+
variables.append(pv)
|
|
1067
|
+
self._make_edges(action, pv)
|
|
1068
|
+
else:
|
|
1069
|
+
# if no definition is found, then this is the first time this variable is accessed
|
|
1070
|
+
# mark it as "initial"
|
|
1071
|
+
pv = ProgramVariable(variable, code_location, initial=True, arch=self.project.arch)
|
|
1072
|
+
variables.append(pv)
|
|
1073
|
+
self._make_edges(action, pv)
|
|
1074
|
+
# make sure to put it into the killing set
|
|
1075
|
+
self._kill(variable, code_location)
|
|
1076
|
+
|
|
1077
|
+
for var in variables:
|
|
1078
|
+
# record accessed variables in var_per_stmt
|
|
1079
|
+
self._variables_per_statement.append(var)
|
|
1080
|
+
|
|
1081
|
+
def _handle_mem_write(self, action, location, state, statement):
|
|
1082
|
+
addrs = self._get_actual_addrs(action, state)
|
|
1083
|
+
|
|
1084
|
+
for addr in addrs:
|
|
1085
|
+
variable = self._create_memory_variable(action, addr, addrs)
|
|
1086
|
+
|
|
1087
|
+
# kill all previous variables
|
|
1088
|
+
self._kill(variable, location)
|
|
1089
|
+
|
|
1090
|
+
# create a new variable at current location
|
|
1091
|
+
pv = ProgramVariable(variable, location, arch=self.project.arch)
|
|
1092
|
+
|
|
1093
|
+
# make edges
|
|
1094
|
+
self._make_edges(action, pv)
|
|
1095
|
+
|
|
1096
|
+
if isinstance(statement, pyvex.IRStmt.Store) and self._variables_per_statement:
|
|
1097
|
+
if isinstance(statement.data, pyvex.IRExpr.RdTmp):
|
|
1098
|
+
# assignment
|
|
1099
|
+
src_tmp_idx = statement.data.tmp
|
|
1100
|
+
src_tmp_def = next(
|
|
1101
|
+
s
|
|
1102
|
+
for s in self._variables_per_statement
|
|
1103
|
+
if isinstance(s.variable, SimTemporaryVariable) and s.variable.tmp_id == src_tmp_idx
|
|
1104
|
+
)
|
|
1105
|
+
self._ast_graph.add_edge(src_tmp_def, pv)
|
|
1106
|
+
elif isinstance(statement.data, pyvex.IRExpr.Const):
|
|
1107
|
+
# assignment
|
|
1108
|
+
const = statement.data.con.value
|
|
1109
|
+
size = statement.data.con.size
|
|
1110
|
+
self._ast_graph.add_edge(ProgramVariable(SimConstantVariable(value=const, size=size), location), pv)
|
|
1111
|
+
|
|
1112
|
+
def _handle_reg_read(self, action, location, state, statement): # pylint:disable=unused-argument
|
|
1113
|
+
reg_offset = action.offset
|
|
1114
|
+
variable = SimRegisterVariable(reg_offset, action.data.ast.size() // 8)
|
|
1115
|
+
|
|
1116
|
+
# What do we want to do?
|
|
1117
|
+
definitions = self._def_lookup(variable)
|
|
1118
|
+
|
|
1119
|
+
# add edges to the statement dependence graph
|
|
1120
|
+
for definition_location, labels in definitions.items():
|
|
1121
|
+
self._stmt_graph_add_edge(definition_location, location, **labels)
|
|
1122
|
+
|
|
1123
|
+
# record the edge
|
|
1124
|
+
self._register_edges[reg_offset].append((definition_location, location))
|
|
1125
|
+
|
|
1126
|
+
self._variables_per_statement.append(ProgramVariable(variable, definition_location, arch=self.project.arch))
|
|
1127
|
+
|
|
1128
|
+
if not definitions:
|
|
1129
|
+
# the register was never defined before - it must be passed in as an argument
|
|
1130
|
+
self._variables_per_statement.append(
|
|
1131
|
+
ProgramVariable(variable, location, initial=True, arch=self.project.arch)
|
|
1132
|
+
)
|
|
1133
|
+
# make sure to put it into the killing set
|
|
1134
|
+
self._kill(variable, location)
|
|
1135
|
+
|
|
1136
|
+
if reg_offset == self.project.arch.sp_offset:
|
|
1137
|
+
self._custom_data_per_statement = ("sp", 0)
|
|
1138
|
+
elif reg_offset == self.project.arch.bp_offset:
|
|
1139
|
+
self._custom_data_per_statement = ("bp", 0)
|
|
1140
|
+
|
|
1141
|
+
def _handle_reg_write(self, action, location, state, statement: pyvex.stmt.Put): # pylint:disable=unused-argument
|
|
1142
|
+
reg_offset = action.offset
|
|
1143
|
+
variable = SimRegisterVariable(reg_offset, action.data.ast.size() // 8)
|
|
1144
|
+
|
|
1145
|
+
self._kill(variable, location)
|
|
1146
|
+
|
|
1147
|
+
if reg_offset in self._register_edges:
|
|
1148
|
+
# clear the recoreded edge, since we don't need to alter that edge anymore
|
|
1149
|
+
del self._register_edges[reg_offset]
|
|
1150
|
+
|
|
1151
|
+
# add a node on the data dependence graph
|
|
1152
|
+
pv = ProgramVariable(variable, location, arch=self.project.arch)
|
|
1153
|
+
self._data_graph_add_node(pv)
|
|
1154
|
+
|
|
1155
|
+
if not action.reg_deps and not action.tmp_deps:
|
|
1156
|
+
# moving a constant into the register
|
|
1157
|
+
# try to parse out the constant from statement
|
|
1158
|
+
const_variable = SimConstantVariable(size=1)
|
|
1159
|
+
if statement is not None and isinstance(statement.data, pyvex.IRExpr.Const):
|
|
1160
|
+
const_variable = SimConstantVariable(value=statement.data.con.value, size=statement.data.con.size)
|
|
1161
|
+
const_pv = ProgramVariable(const_variable, location, arch=self.project.arch)
|
|
1162
|
+
self._data_graph_add_edge(const_pv, pv)
|
|
1163
|
+
|
|
1164
|
+
for tmp in action.tmp_deps:
|
|
1165
|
+
if tmp in self._temp_variables:
|
|
1166
|
+
self._data_graph_add_edge(self._temp_variables[tmp], pv)
|
|
1167
|
+
|
|
1168
|
+
def _handle_tmp_read(self, action, location, state, statement): # pylint:disable=unused-argument
|
|
1169
|
+
tmp = action.tmp
|
|
1170
|
+
tmp_var = self._temp_variables[tmp]
|
|
1171
|
+
|
|
1172
|
+
def_loc = tmp_var.location
|
|
1173
|
+
|
|
1174
|
+
self._stmt_graph_add_edge(def_loc, location, type="tmp", data=action.tmp)
|
|
1175
|
+
# record the edge
|
|
1176
|
+
edge_tuple = (def_loc, location)
|
|
1177
|
+
self._temp_edges[action.tmp].append(edge_tuple)
|
|
1178
|
+
|
|
1179
|
+
if tmp in self._temp_register_symbols:
|
|
1180
|
+
self._custom_data_per_statement = self._temp_register_symbols[tmp]
|
|
1181
|
+
|
|
1182
|
+
self._variables_per_statement.append(tmp_var)
|
|
1183
|
+
|
|
1184
|
+
def _handle_tmp_write(self, action, location, state, statement): # pylint:disable=unused-argument
|
|
1185
|
+
ast = None
|
|
1186
|
+
|
|
1187
|
+
tmp = action.tmp
|
|
1188
|
+
pv = ProgramVariable(SimTemporaryVariable(tmp, len(action.data)), location, arch=self.project.arch)
|
|
1189
|
+
|
|
1190
|
+
if ast is not None:
|
|
1191
|
+
for operand in ast.operands:
|
|
1192
|
+
self._ast_graph.add_edge(operand, ast)
|
|
1193
|
+
self._ast_graph.add_edge(ast, pv)
|
|
1194
|
+
|
|
1195
|
+
self._temp_variables[tmp] = pv
|
|
1196
|
+
|
|
1197
|
+
# clear existing edges
|
|
1198
|
+
if tmp in self._temp_edges:
|
|
1199
|
+
del self._temp_edges[tmp]
|
|
1200
|
+
|
|
1201
|
+
for tmp_dep in action.tmp_deps:
|
|
1202
|
+
if tmp_dep in self._temp_variables:
|
|
1203
|
+
self._data_graph_add_edge(self._temp_variables[tmp_dep], pv)
|
|
1204
|
+
|
|
1205
|
+
if self._custom_data_per_statement is not None:
|
|
1206
|
+
self._temp_register_symbols[tmp] = self._custom_data_per_statement
|
|
1207
|
+
|
|
1208
|
+
for data in self._variables_per_statement:
|
|
1209
|
+
self._data_graph_add_edge(data, pv)
|
|
1210
|
+
|
|
1211
|
+
if isinstance(statement, pyvex.IRStmt.WrTmp) and self._variables_per_statement:
|
|
1212
|
+
if isinstance(statement.data, pyvex.IRExpr.RdTmp):
|
|
1213
|
+
# assignment: dst_tmp = src_tmp
|
|
1214
|
+
for s in filter(
|
|
1215
|
+
lambda x: isinstance(x.variable, SimTemporaryVariable) and x.variable.tmp_id != tmp,
|
|
1216
|
+
self._variables_per_statement,
|
|
1217
|
+
):
|
|
1218
|
+
self._ast_graph.add_edge(s, pv)
|
|
1219
|
+
elif isinstance(statement.data, pyvex.IRExpr.Get):
|
|
1220
|
+
# assignment: dst_tmp = src_reg
|
|
1221
|
+
for s in filter(lambda x: isinstance(x.variable, SimRegisterVariable), self._variables_per_statement):
|
|
1222
|
+
self._ast_graph.add_edge(s, pv)
|
|
1223
|
+
elif isinstance(statement.data, pyvex.IRExpr.Load):
|
|
1224
|
+
# assignment: dst_tmp = [ src_mem ]
|
|
1225
|
+
for s in filter(lambda x: isinstance(x.variable, SimMemoryVariable), self._variables_per_statement):
|
|
1226
|
+
self._ast_graph.add_edge(s, pv)
|
|
1227
|
+
|
|
1228
|
+
if not action.tmp_deps and not self._variables_per_statement and not ast:
|
|
1229
|
+
# read in a constant
|
|
1230
|
+
# try to parse out the constant from statement
|
|
1231
|
+
const_variable = SimConstantVariable(size=1)
|
|
1232
|
+
if statement is not None:
|
|
1233
|
+
if isinstance(statement, pyvex.IRStmt.Dirty):
|
|
1234
|
+
l.warning("Dirty statements are not supported in DDG for now.")
|
|
1235
|
+
elif isinstance(statement.data, pyvex.IRExpr.Const):
|
|
1236
|
+
const_variable = SimConstantVariable(value=statement.data.con.value, size=statement.data.con.size)
|
|
1237
|
+
const_pv = ProgramVariable(const_variable, location, arch=self.project.arch)
|
|
1238
|
+
self._data_graph_add_edge(const_pv, pv)
|
|
1239
|
+
|
|
1240
|
+
def _handle_exit(self, action, location, state, statement): # pylint:disable=unused-argument
|
|
1241
|
+
# exits should only depend on tmps
|
|
1242
|
+
for tmp in action.tmp_deps:
|
|
1243
|
+
prev_code_loc = self._temp_variables[tmp].location
|
|
1244
|
+
|
|
1245
|
+
# add the edge to the graph
|
|
1246
|
+
self._stmt_graph_add_edge(prev_code_loc, location, type="exit", data="tmp")
|
|
1247
|
+
|
|
1248
|
+
# log the edge
|
|
1249
|
+
edge_tuple = (prev_code_loc, location)
|
|
1250
|
+
self._temp_edges[tmp].append(edge_tuple)
|
|
1251
|
+
|
|
1252
|
+
def _handle_operation(self, action, location, state, statement): # pylint:disable=unused-argument
|
|
1253
|
+
if action.op.endswith("Sub32") or action.op.endswith("Sub64"):
|
|
1254
|
+
# subtract
|
|
1255
|
+
expr_0, expr_1 = action.exprs
|
|
1256
|
+
|
|
1257
|
+
if expr_0.tmp_deps and (not expr_1.tmp_deps and not expr_1.reg_deps):
|
|
1258
|
+
# tmp - const
|
|
1259
|
+
|
|
1260
|
+
const_value = expr_1.ast.args[0]
|
|
1261
|
+
|
|
1262
|
+
tmp = next(iter(expr_0.tmp_deps))
|
|
1263
|
+
if tmp in self._temp_register_symbols:
|
|
1264
|
+
sort, offset = self._temp_register_symbols[tmp]
|
|
1265
|
+
offset -= const_value
|
|
1266
|
+
if offset < 0:
|
|
1267
|
+
offset += 1 << self.project.arch.bits
|
|
1268
|
+
self._custom_data_per_statement = (sort, offset)
|
|
1269
|
+
|
|
1270
|
+
elif action.op.endswith("Add32") or action.op.endswith("Add64"):
|
|
1271
|
+
# add
|
|
1272
|
+
|
|
1273
|
+
expr_0, expr_1 = action.exprs
|
|
1274
|
+
|
|
1275
|
+
if expr_0.tmp_deps and (not expr_1.tmp_deps and not expr_1.reg_deps):
|
|
1276
|
+
# tmp + const
|
|
1277
|
+
const_value = expr_1.ast.args[0]
|
|
1278
|
+
|
|
1279
|
+
tmp = next(iter(expr_0.tmp_deps))
|
|
1280
|
+
if tmp in self._temp_register_symbols:
|
|
1281
|
+
sort, offset = self._temp_register_symbols[tmp]
|
|
1282
|
+
offset += const_value
|
|
1283
|
+
if offset >= (1 << self.project.arch.bits):
|
|
1284
|
+
offset -= 1 << self.project.arch.bits
|
|
1285
|
+
self._custom_data_per_statement = (sort, offset)
|
|
1286
|
+
|
|
1287
|
+
def _process_operation(self, action, location, state, statement): # pylint:disable=unused-argument
|
|
1288
|
+
if action.op.endswith("Sub32") or action.op.endswith("Sub64"):
|
|
1289
|
+
# subtract
|
|
1290
|
+
expr_0, expr_1 = action.exprs
|
|
1291
|
+
|
|
1292
|
+
if expr_0.tmp_deps and (not expr_1.tmp_deps and not expr_1.reg_deps):
|
|
1293
|
+
# tmp - const
|
|
1294
|
+
const_value = expr_1.ast.args[0]
|
|
1295
|
+
tmp = next(iter(expr_0.tmp_deps))
|
|
1296
|
+
|
|
1297
|
+
const_def = ProgramVariable(SimConstantVariable(value=const_value, size=len(expr_1.ast)), location)
|
|
1298
|
+
tmp_def = self._temp_variables[tmp]
|
|
1299
|
+
return AST("-", tmp_def, const_def)
|
|
1300
|
+
|
|
1301
|
+
elif action.op.endswith("Add32") or action.op.endswith("Add64"):
|
|
1302
|
+
# add
|
|
1303
|
+
|
|
1304
|
+
expr_0, expr_1 = action.exprs
|
|
1305
|
+
|
|
1306
|
+
if expr_0.tmp_deps and (not expr_1.tmp_deps and not expr_1.reg_deps):
|
|
1307
|
+
# tmp + const
|
|
1308
|
+
const_value = expr_1.ast.args[0]
|
|
1309
|
+
tmp = next(iter(expr_0.tmp_deps))
|
|
1310
|
+
|
|
1311
|
+
const_def = ProgramVariable(SimConstantVariable(value=const_value, size=len(expr_1.ast)), location)
|
|
1312
|
+
tmp_def = self._temp_variables[tmp]
|
|
1313
|
+
return AST("+", tmp_def, const_def)
|
|
1314
|
+
|
|
1315
|
+
return None
|
|
1316
|
+
|
|
1317
|
+
#
|
|
1318
|
+
# Graph operations
|
|
1319
|
+
#
|
|
1320
|
+
|
|
1321
|
+
def _data_graph_add_node(self, node):
|
|
1322
|
+
"""
|
|
1323
|
+
Add a node in the data dependence graph.
|
|
1324
|
+
|
|
1325
|
+
:param ProgramVariable node: The node to add.
|
|
1326
|
+
:return: None
|
|
1327
|
+
"""
|
|
1328
|
+
|
|
1329
|
+
self._data_graph.add_node(node)
|
|
1330
|
+
|
|
1331
|
+
self._simplified_data_graph = None
|
|
1332
|
+
|
|
1333
|
+
def _data_graph_add_edge(self, src, dst, **edge_labels):
|
|
1334
|
+
"""
|
|
1335
|
+
Add an edge in the data dependence graph.
|
|
1336
|
+
|
|
1337
|
+
:param ProgramVariable src: Source node.
|
|
1338
|
+
:param ProgramVariable dst: Destination node.
|
|
1339
|
+
:param edge_labels: All labels associated with the edge.
|
|
1340
|
+
:return: None
|
|
1341
|
+
"""
|
|
1342
|
+
|
|
1343
|
+
if src in self._data_graph and dst in self._data_graph[src]:
|
|
1344
|
+
return
|
|
1345
|
+
|
|
1346
|
+
self._data_graph.add_edge(src, dst, **edge_labels)
|
|
1347
|
+
|
|
1348
|
+
self._simplified_data_graph = None
|
|
1349
|
+
|
|
1350
|
+
def _stmt_graph_add_edge(self, src, dst, **edge_labels):
|
|
1351
|
+
"""
|
|
1352
|
+
Add an edge in the statement dependence graph from a program location `src` to another program location `dst`.
|
|
1353
|
+
|
|
1354
|
+
:param CodeLocation src: Source node.
|
|
1355
|
+
:param CodeLocation dst: Destination node.
|
|
1356
|
+
:param edge_labels: All labels associated with the edge.
|
|
1357
|
+
:returns: None
|
|
1358
|
+
"""
|
|
1359
|
+
|
|
1360
|
+
# Is that edge already in the graph ?
|
|
1361
|
+
# If at least one is new, then we are not redoing the same path again
|
|
1362
|
+
if src in self._stmt_graph and dst in self._stmt_graph[src]:
|
|
1363
|
+
return
|
|
1364
|
+
|
|
1365
|
+
self._stmt_graph.add_edge(src, dst, **edge_labels)
|
|
1366
|
+
|
|
1367
|
+
def _stmt_graph_annotate_edges(self, edges_to_annotate, **new_labels):
|
|
1368
|
+
"""
|
|
1369
|
+
Add new annotations to edges in the statement dependence graph.
|
|
1370
|
+
|
|
1371
|
+
:param list edges_to_annotate: A list of edges to annotate.
|
|
1372
|
+
:param new_labels: New labels to be added to those edges.
|
|
1373
|
+
:returns: None
|
|
1374
|
+
"""
|
|
1375
|
+
|
|
1376
|
+
graph = self.graph
|
|
1377
|
+
|
|
1378
|
+
for src, dst in edges_to_annotate:
|
|
1379
|
+
if src not in graph:
|
|
1380
|
+
continue
|
|
1381
|
+
if dst not in graph[src]:
|
|
1382
|
+
continue
|
|
1383
|
+
|
|
1384
|
+
data = graph[src][dst]
|
|
1385
|
+
|
|
1386
|
+
for k, v in new_labels.items():
|
|
1387
|
+
if k in data:
|
|
1388
|
+
if v not in data[k]:
|
|
1389
|
+
data[k] = data[k] + (v,)
|
|
1390
|
+
else:
|
|
1391
|
+
# Construct a tuple
|
|
1392
|
+
data[k] = (v,)
|
|
1393
|
+
|
|
1394
|
+
def _simplify_data_graph(self, data_graph): # pylint:disable=no-self-use
|
|
1395
|
+
"""
|
|
1396
|
+
Simplify a data graph by removing all temp variable nodes on the graph.
|
|
1397
|
+
|
|
1398
|
+
:param networkx.DiGraph data_graph: The data dependence graph to simplify.
|
|
1399
|
+
:return: The simplified graph.
|
|
1400
|
+
:rtype: networkx.MultiDiGraph
|
|
1401
|
+
"""
|
|
1402
|
+
|
|
1403
|
+
graph = networkx.MultiDiGraph(data_graph)
|
|
1404
|
+
|
|
1405
|
+
all_nodes = [n for n in graph.nodes() if isinstance(n.variable, SimTemporaryVariable)]
|
|
1406
|
+
|
|
1407
|
+
for tmp_node in all_nodes:
|
|
1408
|
+
# remove each tmp node by linking their successors and predecessors directly
|
|
1409
|
+
in_edges = graph.in_edges(tmp_node, data=True)
|
|
1410
|
+
out_edges = graph.out_edges(tmp_node, data=True)
|
|
1411
|
+
|
|
1412
|
+
for pred, _, _ in in_edges:
|
|
1413
|
+
graph.remove_edge(pred, tmp_node)
|
|
1414
|
+
for _, suc, _ in out_edges:
|
|
1415
|
+
graph.remove_edge(tmp_node, suc)
|
|
1416
|
+
|
|
1417
|
+
for pred, _, data_in in in_edges:
|
|
1418
|
+
for _, suc, data_out in out_edges:
|
|
1419
|
+
if pred is not tmp_node and suc is not tmp_node and suc not in graph[pred]:
|
|
1420
|
+
data = data_in.copy()
|
|
1421
|
+
data.update(data_out)
|
|
1422
|
+
graph.add_edge(pred, suc, **data)
|
|
1423
|
+
|
|
1424
|
+
graph.remove_node(tmp_node)
|
|
1425
|
+
|
|
1426
|
+
return graph
|
|
1427
|
+
|
|
1428
|
+
def _worklist_append(self, node_wrapper, worklist, worklist_set):
|
|
1429
|
+
"""
|
|
1430
|
+
Append a CFGNode and its successors into the work-list, and respect the call-depth limit
|
|
1431
|
+
|
|
1432
|
+
:param node_wrapper: The NodeWrapper instance to insert.
|
|
1433
|
+
:param worklist: The work-list, which is a list.
|
|
1434
|
+
:param worklist_set: A set of all CFGNodes that are inside the work-list, just for the sake of fast look-up.
|
|
1435
|
+
It will be updated as well.
|
|
1436
|
+
:returns: A set of newly-inserted CFGNodes (not NodeWrapper instances).
|
|
1437
|
+
"""
|
|
1438
|
+
|
|
1439
|
+
if node_wrapper.cfg_node in worklist_set:
|
|
1440
|
+
# It's already in the work-list
|
|
1441
|
+
return None
|
|
1442
|
+
|
|
1443
|
+
worklist.append(node_wrapper)
|
|
1444
|
+
worklist_set.add(node_wrapper.cfg_node)
|
|
1445
|
+
|
|
1446
|
+
stack = [node_wrapper]
|
|
1447
|
+
traversed_nodes = {node_wrapper.cfg_node}
|
|
1448
|
+
inserted = {node_wrapper.cfg_node}
|
|
1449
|
+
|
|
1450
|
+
while stack:
|
|
1451
|
+
nw = stack.pop()
|
|
1452
|
+
n, call_depth = nw.cfg_node, nw.call_depth
|
|
1453
|
+
|
|
1454
|
+
# Get successors
|
|
1455
|
+
edges = self._cfg.graph.out_edges(n, data=True)
|
|
1456
|
+
|
|
1457
|
+
for _, dst, data in edges:
|
|
1458
|
+
if (
|
|
1459
|
+
dst not in traversed_nodes # which means we haven't touch this node in this appending procedure
|
|
1460
|
+
and dst not in worklist_set
|
|
1461
|
+
): # which means this node is not in the work-list
|
|
1462
|
+
# We see a new node!
|
|
1463
|
+
traversed_nodes.add(dst)
|
|
1464
|
+
|
|
1465
|
+
if data["jumpkind"] == "Ijk_Call":
|
|
1466
|
+
if self._call_depth is None or call_depth < self._call_depth:
|
|
1467
|
+
inserted.add(dst)
|
|
1468
|
+
new_nw = DDGJob(dst, call_depth + 1)
|
|
1469
|
+
worklist.append(new_nw)
|
|
1470
|
+
worklist_set.add(dst)
|
|
1471
|
+
stack.append(new_nw)
|
|
1472
|
+
elif data["jumpkind"] == "Ijk_Ret":
|
|
1473
|
+
if call_depth > 0:
|
|
1474
|
+
inserted.add(dst)
|
|
1475
|
+
new_nw = DDGJob(dst, call_depth - 1)
|
|
1476
|
+
worklist.append(new_nw)
|
|
1477
|
+
worklist_set.add(dst)
|
|
1478
|
+
stack.append(new_nw)
|
|
1479
|
+
else:
|
|
1480
|
+
new_nw = DDGJob(dst, call_depth)
|
|
1481
|
+
inserted.add(dst)
|
|
1482
|
+
worklist_set.add(dst)
|
|
1483
|
+
worklist.append(new_nw)
|
|
1484
|
+
stack.append(new_nw)
|
|
1485
|
+
|
|
1486
|
+
return inserted
|
|
1487
|
+
|
|
1488
|
+
def _build_function_dependency_graphs(self):
|
|
1489
|
+
"""
|
|
1490
|
+
Build dependency graphs for each function, and save them in self._function_data_dependencies.
|
|
1491
|
+
"""
|
|
1492
|
+
|
|
1493
|
+
# This is a map between functions and its corresponding dependencies
|
|
1494
|
+
self._function_data_dependencies = defaultdict(networkx.DiGraph)
|
|
1495
|
+
|
|
1496
|
+
# Group all dependencies first
|
|
1497
|
+
|
|
1498
|
+
block_addr_to_func = {}
|
|
1499
|
+
for _, func in self.kb.functions.items():
|
|
1500
|
+
for block in func.blocks:
|
|
1501
|
+
block_addr_to_func[block.addr] = func
|
|
1502
|
+
|
|
1503
|
+
for src, dst, data in self.graph.edges(data=True):
|
|
1504
|
+
src_target_func = None
|
|
1505
|
+
if src.block_addr in block_addr_to_func:
|
|
1506
|
+
src_target_func = block_addr_to_func[src.block_addr]
|
|
1507
|
+
self._function_data_dependencies[src_target_func].add_edge(src, dst, **data)
|
|
1508
|
+
|
|
1509
|
+
if dst.block_addr in block_addr_to_func:
|
|
1510
|
+
dst_target_func = block_addr_to_func[dst.block_addr]
|
|
1511
|
+
if dst_target_func is not src_target_func:
|
|
1512
|
+
self._function_data_dependencies[dst_target_func].add_edge(src, dst, **data)
|
|
1513
|
+
|
|
1514
|
+
#
|
|
1515
|
+
# Other private methods
|
|
1516
|
+
#
|
|
1517
|
+
|
|
1518
|
+
def _filter_defs_at_call_sites(self, defs):
|
|
1519
|
+
"""
|
|
1520
|
+
If we are not tracing into the function that are called in a real execution, we should properly filter the defs
|
|
1521
|
+
to account for the behavior of the skipped function at this call site.
|
|
1522
|
+
|
|
1523
|
+
This function is a WIP. See TODOs inside.
|
|
1524
|
+
|
|
1525
|
+
:param defs:
|
|
1526
|
+
:return:
|
|
1527
|
+
"""
|
|
1528
|
+
|
|
1529
|
+
# TODO: make definition killing architecture independent and calling convention independent
|
|
1530
|
+
# TODO: use information from a calling convention analysis
|
|
1531
|
+
filtered_defs = LiveDefinitions()
|
|
1532
|
+
for variable, locs in defs.items():
|
|
1533
|
+
if not (
|
|
1534
|
+
isinstance(variable, SimRegisterVariable)
|
|
1535
|
+
and self.project.arch.name == "X86"
|
|
1536
|
+
and variable.reg
|
|
1537
|
+
in (
|
|
1538
|
+
self.project.arch.registers["eax"][0],
|
|
1539
|
+
self.project.arch.registers["ecx"][0],
|
|
1540
|
+
self.project.arch.registers["edx"][0],
|
|
1541
|
+
)
|
|
1542
|
+
):
|
|
1543
|
+
filtered_defs.add_defs(variable, locs)
|
|
1544
|
+
|
|
1545
|
+
return filtered_defs
|
|
1546
|
+
|
|
1547
|
+
def find_definitions(self, variable, location=None, simplified_graph=True):
|
|
1548
|
+
"""
|
|
1549
|
+
Find all definitions of the given variable.
|
|
1550
|
+
|
|
1551
|
+
:param SimVariable variable:
|
|
1552
|
+
:param bool simplified_graph: True if you just want to search in the simplified graph instead of the normal
|
|
1553
|
+
graph. Usually the simplified graph suffices for finding definitions of register
|
|
1554
|
+
or memory variables.
|
|
1555
|
+
:return: A collection of all variable definitions to the specific variable.
|
|
1556
|
+
:rtype: list
|
|
1557
|
+
"""
|
|
1558
|
+
|
|
1559
|
+
graph = self.simplified_data_graph if simplified_graph else self.data_graph
|
|
1560
|
+
|
|
1561
|
+
defs = []
|
|
1562
|
+
|
|
1563
|
+
n: ProgramVariable
|
|
1564
|
+
for n in graph.nodes():
|
|
1565
|
+
if n.variable == variable:
|
|
1566
|
+
if location is None:
|
|
1567
|
+
defs.append(n)
|
|
1568
|
+
else:
|
|
1569
|
+
# TODO: finish this part
|
|
1570
|
+
if n.location.block_addr == location.block_addr:
|
|
1571
|
+
defs.append(n)
|
|
1572
|
+
|
|
1573
|
+
return defs
|
|
1574
|
+
|
|
1575
|
+
def find_consumers(self, var_def, simplified_graph=True):
|
|
1576
|
+
"""
|
|
1577
|
+
Find all consumers to the specified variable definition.
|
|
1578
|
+
|
|
1579
|
+
:param ProgramVariable var_def: The variable definition.
|
|
1580
|
+
:param bool simplified_graph: True if we want to search in the simplified graph, False otherwise.
|
|
1581
|
+
:return: A collection of all consumers to the specified variable definition.
|
|
1582
|
+
:rtype: list
|
|
1583
|
+
"""
|
|
1584
|
+
|
|
1585
|
+
graph = self.simplified_data_graph if simplified_graph else self.data_graph
|
|
1586
|
+
|
|
1587
|
+
if var_def not in graph:
|
|
1588
|
+
return []
|
|
1589
|
+
|
|
1590
|
+
consumers = []
|
|
1591
|
+
srcs = [var_def]
|
|
1592
|
+
traversed = set()
|
|
1593
|
+
|
|
1594
|
+
while srcs:
|
|
1595
|
+
src = srcs.pop()
|
|
1596
|
+
out_edges = graph.out_edges(src, data=True)
|
|
1597
|
+
for _, dst, data in out_edges:
|
|
1598
|
+
if "type" in data and data["type"] == "kill":
|
|
1599
|
+
# skip killing edges
|
|
1600
|
+
continue
|
|
1601
|
+
if isinstance(dst.variable, SimTemporaryVariable):
|
|
1602
|
+
if dst not in traversed:
|
|
1603
|
+
srcs.append(dst)
|
|
1604
|
+
traversed.add(dst)
|
|
1605
|
+
else:
|
|
1606
|
+
if dst not in consumers:
|
|
1607
|
+
consumers.append(dst)
|
|
1608
|
+
|
|
1609
|
+
return consumers
|
|
1610
|
+
|
|
1611
|
+
def find_killers(self, var_def, simplified_graph=True):
|
|
1612
|
+
"""
|
|
1613
|
+
Find all killers to the specified variable definition.
|
|
1614
|
+
|
|
1615
|
+
:param ProgramVariable var_def: The variable definition.
|
|
1616
|
+
:param bool simplified_graph: True if we want to search in the simplified graph, False otherwise.
|
|
1617
|
+
:return: A collection of all killers to the specified variable definition.
|
|
1618
|
+
:rtype: list
|
|
1619
|
+
"""
|
|
1620
|
+
|
|
1621
|
+
graph = self.simplified_data_graph if simplified_graph else self.data_graph
|
|
1622
|
+
|
|
1623
|
+
if var_def not in graph:
|
|
1624
|
+
return []
|
|
1625
|
+
|
|
1626
|
+
killers = []
|
|
1627
|
+
out_edges = graph.out_edges(var_def, data=True)
|
|
1628
|
+
for _, dst, data in out_edges:
|
|
1629
|
+
if "type" in data and data["type"] == "kill":
|
|
1630
|
+
killers.append(dst)
|
|
1631
|
+
|
|
1632
|
+
return killers
|
|
1633
|
+
|
|
1634
|
+
def find_sources(self, var_def, simplified_graph=True):
|
|
1635
|
+
"""
|
|
1636
|
+
Find all sources to the specified variable definition.
|
|
1637
|
+
|
|
1638
|
+
:param ProgramVariable var_def: The variable definition.
|
|
1639
|
+
:param bool simplified_graph: True if we want to search in the simplified graph, False otherwise.
|
|
1640
|
+
:return: A collection of all sources to the specified variable definition.
|
|
1641
|
+
:rtype: list
|
|
1642
|
+
"""
|
|
1643
|
+
|
|
1644
|
+
graph = self.simplified_data_graph if simplified_graph else self.data_graph
|
|
1645
|
+
|
|
1646
|
+
if var_def not in graph:
|
|
1647
|
+
return []
|
|
1648
|
+
|
|
1649
|
+
sources = []
|
|
1650
|
+
defs = [var_def]
|
|
1651
|
+
traversed = set()
|
|
1652
|
+
|
|
1653
|
+
while defs:
|
|
1654
|
+
definition = defs.pop()
|
|
1655
|
+
in_edges = graph.in_edges(definition, data=True)
|
|
1656
|
+
for src, _, data in in_edges:
|
|
1657
|
+
if "type" in data and data["type"] == "kill":
|
|
1658
|
+
continue
|
|
1659
|
+
if isinstance(src.variable, SimTemporaryVariable):
|
|
1660
|
+
if src not in traversed:
|
|
1661
|
+
defs.append(src)
|
|
1662
|
+
traversed.add(src)
|
|
1663
|
+
else:
|
|
1664
|
+
if src not in sources:
|
|
1665
|
+
sources.append(src)
|
|
1666
|
+
|
|
1667
|
+
return sources
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
AnalysesHub.register_default("DDG", DDG)
|