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
|
@@ -0,0 +1,1217 @@
|
|
|
1
|
+
# pylint:disable=multiple-statements,line-too-long,consider-using-enumerate
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from typing import Any, TYPE_CHECKING
|
|
4
|
+
import logging
|
|
5
|
+
from collections import defaultdict, OrderedDict
|
|
6
|
+
|
|
7
|
+
import networkx
|
|
8
|
+
|
|
9
|
+
import claripy
|
|
10
|
+
import angr.ailment as ailment
|
|
11
|
+
|
|
12
|
+
from angr.utils.graph import GraphUtils
|
|
13
|
+
from angr.knowledge_plugins.cfg import IndirectJumpType
|
|
14
|
+
from angr.analyses.decompiler.graph_region import GraphRegion
|
|
15
|
+
from angr.analyses.decompiler.empty_node_remover import EmptyNodeRemover
|
|
16
|
+
from angr.analyses.decompiler.jumptable_entry_condition_rewriter import JumpTableEntryConditionRewriter
|
|
17
|
+
from angr.analyses.decompiler.condition_processor import ConditionProcessor
|
|
18
|
+
from angr.analyses.decompiler.region_simplifiers.cascading_cond_transformer import CascadingConditionTransformer
|
|
19
|
+
from angr.analyses.decompiler.utils import (
|
|
20
|
+
extract_jump_targets,
|
|
21
|
+
get_ast_subexprs,
|
|
22
|
+
switch_extract_cmp_bounds,
|
|
23
|
+
remove_last_statement,
|
|
24
|
+
first_nonlabel_nonphi_node,
|
|
25
|
+
)
|
|
26
|
+
from .structurer_nodes import (
|
|
27
|
+
SequenceNode,
|
|
28
|
+
CodeNode,
|
|
29
|
+
ConditionNode,
|
|
30
|
+
ConditionalBreakNode,
|
|
31
|
+
LoopNode,
|
|
32
|
+
SwitchCaseNode,
|
|
33
|
+
BreakNode,
|
|
34
|
+
ContinueNode,
|
|
35
|
+
MultiNode,
|
|
36
|
+
CascadingConditionNode,
|
|
37
|
+
BaseNode,
|
|
38
|
+
EmptyBlockNotice,
|
|
39
|
+
)
|
|
40
|
+
from .structurer_base import StructurerBase
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from angr.knowledge_plugins.functions import Function
|
|
45
|
+
|
|
46
|
+
l = logging.getLogger(name=__name__)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# The main analysis
|
|
51
|
+
#
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class DreamStructurer(StructurerBase):
|
|
55
|
+
"""
|
|
56
|
+
Structure a region using a structuring algorithm that is similar to the one in Dream decompiler (described in the
|
|
57
|
+
"no more gotos" paper). Note that this implementation has quite a few improvements over the original described
|
|
58
|
+
version and *should not* be used to evaluate the performance of the original algorithm described in that paper.
|
|
59
|
+
|
|
60
|
+
The current function graph is provided so that we can detect certain edge cases, for example, jump table entries no
|
|
61
|
+
longer exist due to empty node removal during structuring or prior steps.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
NAME = "dream"
|
|
65
|
+
|
|
66
|
+
def __init__(
|
|
67
|
+
self,
|
|
68
|
+
region,
|
|
69
|
+
parent_map=None,
|
|
70
|
+
condition_processor=None,
|
|
71
|
+
func: Function | None = None,
|
|
72
|
+
case_entry_to_switch_head: dict[int, int] | None = None,
|
|
73
|
+
parent_region=None,
|
|
74
|
+
**kwargs,
|
|
75
|
+
):
|
|
76
|
+
super().__init__(
|
|
77
|
+
region,
|
|
78
|
+
parent_map=parent_map,
|
|
79
|
+
condition_processor=condition_processor,
|
|
80
|
+
func=func,
|
|
81
|
+
case_entry_to_switch_head=case_entry_to_switch_head,
|
|
82
|
+
parent_region=parent_region,
|
|
83
|
+
**kwargs,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
self._analyze()
|
|
87
|
+
|
|
88
|
+
def _analyze(self):
|
|
89
|
+
has_cycle = self._has_cycle()
|
|
90
|
+
# sanity checks
|
|
91
|
+
if self._region.cyclic:
|
|
92
|
+
if not has_cycle:
|
|
93
|
+
l.critical(
|
|
94
|
+
"Region %r is supposed to be a cyclic region but there is no cycle inside. This is usually "
|
|
95
|
+
"due to the existence of loop headers with more than one in-edges, which angr decompiler "
|
|
96
|
+
"does not support yet. The decompilation result will be wrong.",
|
|
97
|
+
self._region,
|
|
98
|
+
)
|
|
99
|
+
self._analyze_cyclic()
|
|
100
|
+
else:
|
|
101
|
+
if has_cycle:
|
|
102
|
+
l.critical(
|
|
103
|
+
"Region %r is supposed to be an acyclic region but there are cycles inside. This is usually "
|
|
104
|
+
"due to the existence of loop headers with more than one in-edges, which angr decompiler "
|
|
105
|
+
"does not support yet. The decompilation result will be wrong.",
|
|
106
|
+
self._region,
|
|
107
|
+
)
|
|
108
|
+
self._analyze_acyclic()
|
|
109
|
+
|
|
110
|
+
def _analyze_cyclic(self):
|
|
111
|
+
loop_head = self._region.head
|
|
112
|
+
|
|
113
|
+
loop_subgraph = self._region.graph
|
|
114
|
+
successors = self._region.successors
|
|
115
|
+
assert successors is not None
|
|
116
|
+
|
|
117
|
+
assert len(successors) <= 1
|
|
118
|
+
|
|
119
|
+
loop_node = self._make_endless_loop(loop_head, loop_subgraph, successors)
|
|
120
|
+
|
|
121
|
+
loop_node = self._refine_loop(loop_node)
|
|
122
|
+
|
|
123
|
+
seq = SequenceNode(
|
|
124
|
+
loop_head.addr, nodes=[loop_node] + [succ for succ in successors if succ in self._region.graph]
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
self.result = seq
|
|
128
|
+
|
|
129
|
+
def _analyze_acyclic(self):
|
|
130
|
+
# let's generate conditions first
|
|
131
|
+
self.cond_proc.recover_reaching_conditions(
|
|
132
|
+
self._region, with_successors=True, case_entry_to_switch_head=self._case_entry_to_switch_head
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# make the sequence node and pack reaching conditions into CodeNode instances
|
|
136
|
+
seq = self._make_sequence()
|
|
137
|
+
|
|
138
|
+
self._new_sequences.append(seq)
|
|
139
|
+
|
|
140
|
+
while self._new_sequences:
|
|
141
|
+
seq_ = self._new_sequences.pop(0)
|
|
142
|
+
if len(seq_.nodes) <= 1:
|
|
143
|
+
continue
|
|
144
|
+
self._structure_sequence(seq_)
|
|
145
|
+
|
|
146
|
+
seq = EmptyNodeRemover(seq).result
|
|
147
|
+
|
|
148
|
+
# unpack nodes and remove CodeNode wrappers
|
|
149
|
+
seq = self._unpack_sequence(seq)
|
|
150
|
+
|
|
151
|
+
self.result = seq
|
|
152
|
+
|
|
153
|
+
def _find_loop_nodes_and_successors(self):
|
|
154
|
+
graph = self._region.graph
|
|
155
|
+
head = self._region.head
|
|
156
|
+
|
|
157
|
+
# find initial loop nodes
|
|
158
|
+
loop_nodes = None
|
|
159
|
+
components = networkx.strongly_connected_components(graph)
|
|
160
|
+
for component in components:
|
|
161
|
+
if head in component:
|
|
162
|
+
loop_nodes = component
|
|
163
|
+
break
|
|
164
|
+
if loop_nodes is None:
|
|
165
|
+
# this should never happen - loop head always forms a cycle
|
|
166
|
+
raise TypeError("A bug (impossible case) in the algorithm is triggered.")
|
|
167
|
+
|
|
168
|
+
# extend loop nodes
|
|
169
|
+
while True:
|
|
170
|
+
loop_nodes_updated = False
|
|
171
|
+
for loop_node in loop_nodes:
|
|
172
|
+
for succ in graph.successors(loop_node):
|
|
173
|
+
if succ not in loop_nodes:
|
|
174
|
+
# determine if this successor's all predecessors are in the loop
|
|
175
|
+
predecessors = graph.predecessors(succ)
|
|
176
|
+
if all(pred in loop_nodes for pred in predecessors):
|
|
177
|
+
# yes!
|
|
178
|
+
loop_nodes.add(succ)
|
|
179
|
+
loop_nodes_updated = True
|
|
180
|
+
break
|
|
181
|
+
if loop_nodes_updated:
|
|
182
|
+
break
|
|
183
|
+
if not loop_nodes_updated:
|
|
184
|
+
break
|
|
185
|
+
|
|
186
|
+
# find loop nodes and successors
|
|
187
|
+
loop_subgraph = networkx.subgraph(graph, loop_nodes)
|
|
188
|
+
loop_node_addrs = {node.addr for node in loop_subgraph}
|
|
189
|
+
|
|
190
|
+
# Case A: The loop successor is inside the current region (does it happen at all?)
|
|
191
|
+
loop_successors = set()
|
|
192
|
+
|
|
193
|
+
for node, successors in networkx.bfs_successors(graph, head):
|
|
194
|
+
if node.addr in loop_node_addrs:
|
|
195
|
+
for suc in successors:
|
|
196
|
+
if suc not in loop_subgraph:
|
|
197
|
+
loop_successors.add(suc)
|
|
198
|
+
|
|
199
|
+
# Case B: The loop successor is the successor to this region in the parent graph
|
|
200
|
+
if not loop_successors and self._parent_map is not None:
|
|
201
|
+
current_region = self._region
|
|
202
|
+
parent_region = self._parent_map.get(current_region, None)
|
|
203
|
+
while parent_region and not loop_successors:
|
|
204
|
+
parent_graph = parent_region.graph
|
|
205
|
+
for node, successors in networkx.bfs_successors(parent_graph, current_region):
|
|
206
|
+
if node.addr == current_region.addr:
|
|
207
|
+
for suc in successors:
|
|
208
|
+
if suc not in loop_subgraph:
|
|
209
|
+
loop_successors.add(suc)
|
|
210
|
+
current_region = parent_region
|
|
211
|
+
parent_region = self._parent_map.get(current_region, None)
|
|
212
|
+
|
|
213
|
+
return loop_subgraph, loop_successors
|
|
214
|
+
|
|
215
|
+
def _make_endless_loop(self, loop_head, loop_subgraph, loop_successors):
|
|
216
|
+
loop_body = self._to_loop_body_sequence(loop_head, loop_subgraph, loop_successors)
|
|
217
|
+
|
|
218
|
+
# create a while(true) loop with sequence node being the loop body
|
|
219
|
+
return LoopNode("while", None, loop_body, addr=loop_head.addr)
|
|
220
|
+
|
|
221
|
+
def _refine_loop(self, loop_node):
|
|
222
|
+
while True:
|
|
223
|
+
# while
|
|
224
|
+
r, loop_node = self._refine_loop_while(loop_node)
|
|
225
|
+
if r:
|
|
226
|
+
continue
|
|
227
|
+
|
|
228
|
+
# do-while
|
|
229
|
+
r, loop_node = self._refine_loop_dowhile(loop_node)
|
|
230
|
+
if r:
|
|
231
|
+
continue
|
|
232
|
+
|
|
233
|
+
# no more changes
|
|
234
|
+
break
|
|
235
|
+
|
|
236
|
+
return loop_node
|
|
237
|
+
|
|
238
|
+
@staticmethod
|
|
239
|
+
def _refine_loop_while(loop_node):
|
|
240
|
+
if loop_node.sort == "while" and loop_node.condition is None and loop_node.sequence_node.nodes:
|
|
241
|
+
# it's an endless loop
|
|
242
|
+
first_node = first_nonlabel_nonphi_node(loop_node.sequence_node)
|
|
243
|
+
inner_first_node = first_node.node if type(first_node) is CodeNode else first_node
|
|
244
|
+
if type(inner_first_node) is ConditionalBreakNode:
|
|
245
|
+
while_cond = ConditionProcessor.simplify_condition(claripy.Not(inner_first_node.condition))
|
|
246
|
+
new_seq = loop_node.sequence_node.copy()
|
|
247
|
+
new_seq.nodes = [nn for nn in new_seq.nodes if nn is not first_node]
|
|
248
|
+
new_loop_node = LoopNode("while", while_cond, new_seq, addr=loop_node.addr)
|
|
249
|
+
|
|
250
|
+
return True, new_loop_node
|
|
251
|
+
|
|
252
|
+
return False, loop_node
|
|
253
|
+
|
|
254
|
+
@staticmethod
|
|
255
|
+
def _refine_loop_dowhile(loop_node):
|
|
256
|
+
if loop_node.sort == "while" and loop_node.condition is None and loop_node.sequence_node.nodes:
|
|
257
|
+
# it's an endless loop
|
|
258
|
+
last_node = loop_node.sequence_node.nodes[-1]
|
|
259
|
+
if type(last_node) is ConditionalBreakNode:
|
|
260
|
+
while_cond = ConditionProcessor.simplify_condition(claripy.Not(last_node.condition))
|
|
261
|
+
new_seq = loop_node.sequence_node.copy()
|
|
262
|
+
new_seq.nodes = new_seq.nodes[:-1]
|
|
263
|
+
new_loop_node = LoopNode("do-while", while_cond, new_seq)
|
|
264
|
+
|
|
265
|
+
return True, new_loop_node
|
|
266
|
+
|
|
267
|
+
return False, loop_node
|
|
268
|
+
|
|
269
|
+
def _to_loop_body_sequence(self, loop_head, loop_subgraph, loop_successors):
|
|
270
|
+
graph = self._region.graph_with_successors
|
|
271
|
+
assert graph is not None
|
|
272
|
+
loop_region_graph = networkx.DiGraph()
|
|
273
|
+
|
|
274
|
+
# TODO: Make sure the loop body has been structured
|
|
275
|
+
|
|
276
|
+
queue = [loop_head]
|
|
277
|
+
traversed = set()
|
|
278
|
+
loop_successor_addrs = {succ.addr for succ in loop_successors}
|
|
279
|
+
replaced_nodes = {}
|
|
280
|
+
outedges = []
|
|
281
|
+
|
|
282
|
+
while queue:
|
|
283
|
+
node = queue[0]
|
|
284
|
+
queue = queue[1:]
|
|
285
|
+
|
|
286
|
+
loop_region_graph.add_node(node)
|
|
287
|
+
traversed.add(node)
|
|
288
|
+
|
|
289
|
+
successors_and_data = list(graph.out_edges(node, data=True)) # successors are all inside the current region
|
|
290
|
+
|
|
291
|
+
for _, dst, edge_data in successors_and_data:
|
|
292
|
+
# sanity check
|
|
293
|
+
if dst.addr in loop_successor_addrs:
|
|
294
|
+
outedges.append((node, dst, edge_data))
|
|
295
|
+
continue
|
|
296
|
+
if dst not in loop_subgraph and dst.addr not in loop_successor_addrs:
|
|
297
|
+
# what's this node?
|
|
298
|
+
l.error("Found a node that belongs to neither loop body nor loop successors. Something is wrong.")
|
|
299
|
+
# raise Exception()
|
|
300
|
+
|
|
301
|
+
if replaced_nodes.get(dst, dst) is not loop_head:
|
|
302
|
+
loop_region_graph.add_edge(node, replaced_nodes.get(dst, dst), **edge_data)
|
|
303
|
+
if dst in traversed or dst in queue:
|
|
304
|
+
continue
|
|
305
|
+
queue.append(dst)
|
|
306
|
+
|
|
307
|
+
# Create a graph region and structure it
|
|
308
|
+
loop_region_graph_with_successors = networkx.DiGraph(loop_region_graph)
|
|
309
|
+
loop_successors = set() # update loop_successors with nodes in outedges
|
|
310
|
+
for src, dst, edge_data in outedges:
|
|
311
|
+
loop_region_graph_with_successors.add_edge(src, dst, **edge_data)
|
|
312
|
+
loop_successors.add(dst)
|
|
313
|
+
region = GraphRegion(
|
|
314
|
+
loop_head, loop_region_graph, successors=None, graph_with_successors=None, cyclic=False, full_graph=None
|
|
315
|
+
)
|
|
316
|
+
structurer = self.project.analyses[DreamStructurer].prep()(
|
|
317
|
+
region, condition_processor=self.cond_proc, func=self.function, jump_tables=self.jump_tables
|
|
318
|
+
)
|
|
319
|
+
seq = structurer.result
|
|
320
|
+
|
|
321
|
+
# traverse this node and rewrite all conditional jumps that go outside the loop to breaks
|
|
322
|
+
self._rewrite_conditional_jumps_to_breaks(seq, loop_successor_addrs)
|
|
323
|
+
# traverse this node and rewrite all jumps that go to the beginning of the loop to continue
|
|
324
|
+
self._rewrite_jumps_to_continues(seq)
|
|
325
|
+
|
|
326
|
+
seq = self._remove_redundant_jumps(seq)
|
|
327
|
+
seq = self._remove_conditional_jumps(seq)
|
|
328
|
+
seq = EmptyNodeRemover(seq).result
|
|
329
|
+
|
|
330
|
+
while True:
|
|
331
|
+
r, seq = self._merge_conditional_breaks(seq)
|
|
332
|
+
if r:
|
|
333
|
+
continue
|
|
334
|
+
r, seq = self._merge_nesting_conditionals(seq)
|
|
335
|
+
if r:
|
|
336
|
+
continue
|
|
337
|
+
break
|
|
338
|
+
|
|
339
|
+
return EmptyNodeRemover(seq).result
|
|
340
|
+
|
|
341
|
+
def _make_sequence(self):
|
|
342
|
+
seq = SequenceNode(None)
|
|
343
|
+
|
|
344
|
+
for node in GraphUtils.quasi_topological_sort_nodes(self._region.graph):
|
|
345
|
+
seq.add_node(CodeNode(node, self.cond_proc.reaching_conditions.get(node, None)))
|
|
346
|
+
|
|
347
|
+
if seq.nodes:
|
|
348
|
+
seq.addr = seq.nodes[0].addr
|
|
349
|
+
|
|
350
|
+
return seq
|
|
351
|
+
|
|
352
|
+
@staticmethod
|
|
353
|
+
def _unpack_sequence(seq):
|
|
354
|
+
def _handle_Code(node, **kwargs): # pylint:disable=unused-argument
|
|
355
|
+
node = node.node
|
|
356
|
+
return walker._handle(node)
|
|
357
|
+
|
|
358
|
+
def _handle_Sequence(node, **kwargs): # pylint:disable=unused-argument
|
|
359
|
+
for i in range(len(node.nodes)): # pylint:disable=consider-using-enumerate
|
|
360
|
+
node.nodes[i] = walker._handle(node.nodes[i])
|
|
361
|
+
return node
|
|
362
|
+
|
|
363
|
+
def _handle_ConditionNode(node, **kwargs): # pylint:disable=unused-argument
|
|
364
|
+
if node.true_node is not None:
|
|
365
|
+
node.true_node = walker._handle(node.true_node)
|
|
366
|
+
if node.false_node is not None:
|
|
367
|
+
node.false_node = walker._handle(node.false_node)
|
|
368
|
+
return node
|
|
369
|
+
|
|
370
|
+
def _handle_CascadingConditionNode(node: CascadingConditionNode, **kwargs): # pylint:disable=unused-argument
|
|
371
|
+
new_cond_and_nodes = []
|
|
372
|
+
for cond, child_node in node.condition_and_nodes:
|
|
373
|
+
new_cond_and_nodes.append((cond, walker._handle(child_node)))
|
|
374
|
+
node.condition_and_nodes = new_cond_and_nodes
|
|
375
|
+
|
|
376
|
+
if node.else_node is not None:
|
|
377
|
+
node.else_node = walker._handle(node.else_node) # type: ignore
|
|
378
|
+
return node
|
|
379
|
+
|
|
380
|
+
def _handle_SwitchCaseNode(node, **kwargs): # pylint:disable=unused-argument
|
|
381
|
+
for i in list(node.cases.keys()):
|
|
382
|
+
node.cases[i] = walker._handle(node.cases[i])
|
|
383
|
+
if node.default_node is not None:
|
|
384
|
+
node.default_node = walker._handle(node.default_node)
|
|
385
|
+
return node
|
|
386
|
+
|
|
387
|
+
def _handle_Default(node, **kwargs): # pylint:disable=unused-argument
|
|
388
|
+
return node
|
|
389
|
+
|
|
390
|
+
handlers = {
|
|
391
|
+
CodeNode: _handle_Code,
|
|
392
|
+
SequenceNode: _handle_Sequence,
|
|
393
|
+
ConditionNode: _handle_ConditionNode,
|
|
394
|
+
CascadingConditionNode: _handle_CascadingConditionNode,
|
|
395
|
+
SwitchCaseNode: _handle_SwitchCaseNode,
|
|
396
|
+
# don't do anything
|
|
397
|
+
LoopNode: _handle_Default,
|
|
398
|
+
ContinueNode: _handle_Default,
|
|
399
|
+
ConditionalBreakNode: _handle_Default,
|
|
400
|
+
BreakNode: _handle_Default,
|
|
401
|
+
MultiNode: _handle_Default,
|
|
402
|
+
ailment.Block: _handle_Default,
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
walker = SequenceWalker(handlers=handlers)
|
|
406
|
+
walker.walk(seq)
|
|
407
|
+
|
|
408
|
+
return seq
|
|
409
|
+
|
|
410
|
+
def _structure_sequence(self, seq):
|
|
411
|
+
self._make_switch_cases(seq)
|
|
412
|
+
|
|
413
|
+
# this is hackish...
|
|
414
|
+
# seq.nodes = new_seq.nodes
|
|
415
|
+
|
|
416
|
+
self._merge_same_conditioned_nodes(seq)
|
|
417
|
+
self._structure_common_subexpression_conditions(seq)
|
|
418
|
+
self._make_ites(seq)
|
|
419
|
+
self._remove_redundant_jumps(seq)
|
|
420
|
+
|
|
421
|
+
empty_node_remover = EmptyNodeRemover(seq)
|
|
422
|
+
new_seq = empty_node_remover.result
|
|
423
|
+
# update self._new_sequences
|
|
424
|
+
self._update_new_sequences(set(empty_node_remover.removed_sequences), empty_node_remover.replaced_sequences)
|
|
425
|
+
|
|
426
|
+
# we need to do it in-place
|
|
427
|
+
seq.nodes = new_seq.nodes
|
|
428
|
+
|
|
429
|
+
self._replace_complex_reaching_conditions(seq)
|
|
430
|
+
self._make_condition_nodes(seq)
|
|
431
|
+
self._make_cascading_condition_nodes(seq)
|
|
432
|
+
|
|
433
|
+
while True:
|
|
434
|
+
r, seq = self._merge_conditional_breaks(seq)
|
|
435
|
+
if r:
|
|
436
|
+
continue
|
|
437
|
+
r, seq = self._merge_nesting_conditionals(seq)
|
|
438
|
+
if r:
|
|
439
|
+
continue
|
|
440
|
+
break
|
|
441
|
+
|
|
442
|
+
def _merge_same_conditioned_nodes(self, seq):
|
|
443
|
+
# search for nodes with the same reaching condition and then merge them into one sequence node
|
|
444
|
+
i = 0
|
|
445
|
+
while i < len(seq.nodes) - 1:
|
|
446
|
+
node_0 = seq.nodes[i]
|
|
447
|
+
if type(node_0) is not CodeNode:
|
|
448
|
+
i += 1
|
|
449
|
+
continue
|
|
450
|
+
rcond_0 = node_0.reaching_condition
|
|
451
|
+
if rcond_0 is None:
|
|
452
|
+
i += 1
|
|
453
|
+
continue
|
|
454
|
+
node_1 = seq.nodes[i + 1]
|
|
455
|
+
if type(node_1) is not CodeNode:
|
|
456
|
+
i += 1
|
|
457
|
+
continue
|
|
458
|
+
rcond_1 = node_1.reaching_condition
|
|
459
|
+
if rcond_1 is None:
|
|
460
|
+
i += 1
|
|
461
|
+
continue
|
|
462
|
+
r = claripy.simplify(rcond_0 == rcond_1)
|
|
463
|
+
if claripy.is_true(r):
|
|
464
|
+
# node_0 and node_1 should be put into the same sequence node
|
|
465
|
+
new_node = CodeNode(
|
|
466
|
+
self._merge_nodes(node_0.node, node_1.node),
|
|
467
|
+
node_0.reaching_condition,
|
|
468
|
+
)
|
|
469
|
+
seq.nodes = [*seq.nodes[:i], new_node, *seq.nodes[i + 2 :]]
|
|
470
|
+
continue
|
|
471
|
+
i += 1
|
|
472
|
+
|
|
473
|
+
#
|
|
474
|
+
# Dealing with switch-case structures
|
|
475
|
+
#
|
|
476
|
+
|
|
477
|
+
def _make_switch_cases(self, seq):
|
|
478
|
+
"""
|
|
479
|
+
Search for nodes that look like switch-cases and convert them to switch cases.
|
|
480
|
+
|
|
481
|
+
:param seq: The Sequence node.
|
|
482
|
+
:return: None
|
|
483
|
+
"""
|
|
484
|
+
|
|
485
|
+
addr2nodes: dict[int, set[CodeNode]] = defaultdict(set)
|
|
486
|
+
for node in seq.nodes:
|
|
487
|
+
addr2nodes[node.addr].add(node)
|
|
488
|
+
|
|
489
|
+
while True:
|
|
490
|
+
for i in range(len(seq.nodes)):
|
|
491
|
+
node = seq.nodes[i]
|
|
492
|
+
|
|
493
|
+
# Jumptable_AddressLoadedFromMemory
|
|
494
|
+
r = self._make_switch_cases_address_loaded_from_memory(seq, i, node, addr2nodes)
|
|
495
|
+
if r:
|
|
496
|
+
# we found a node that looks like a switch-case. seq.nodes are changed. resume to find the next such
|
|
497
|
+
# case
|
|
498
|
+
break
|
|
499
|
+
|
|
500
|
+
# Jumptable_AddressComputed
|
|
501
|
+
r = self._make_switch_cases_address_computed(seq, i, node, addr2nodes)
|
|
502
|
+
if r:
|
|
503
|
+
break
|
|
504
|
+
|
|
505
|
+
else:
|
|
506
|
+
# we did not find any node that looks like a switch-case. exit.
|
|
507
|
+
break
|
|
508
|
+
|
|
509
|
+
def _make_switch_cases_address_loaded_from_memory(self, seq, i, node, addr2nodes: dict[int, set[CodeNode]]) -> bool:
|
|
510
|
+
"""
|
|
511
|
+
A typical jump table involves multiple nodes, which look like the following:
|
|
512
|
+
|
|
513
|
+
Head: s_50 = Conv(32->64, (Load(addr=stack_base-28, size=4, endness=Iend_LE) - 0x3f<32>))<8>
|
|
514
|
+
if (((Load(addr=stack_base-28, size=4, endness=Iend_LE) - 0x3f<32>) <= 0x36<32>))
|
|
515
|
+
{ Goto A<64> } else { Goto B<64> }
|
|
516
|
+
|
|
517
|
+
A: (with an indirect jump)
|
|
518
|
+
Goto((
|
|
519
|
+
Conv(32->64, Load(addr=(0x40964c<64> + (Load(addr=stack_base-80, size=8, endness=Iend_LE) Mul 0x4<8>)),
|
|
520
|
+
size=4, endness=Iend_LE)) + 0x40964c<64>))
|
|
521
|
+
|
|
522
|
+
B: (the default case)
|
|
523
|
+
"""
|
|
524
|
+
|
|
525
|
+
try:
|
|
526
|
+
last_stmt = self.cond_proc.get_last_statement(node)
|
|
527
|
+
if not isinstance(last_stmt, ailment.Stmt.ConditionalJump):
|
|
528
|
+
return False
|
|
529
|
+
except EmptyBlockNotice:
|
|
530
|
+
return False
|
|
531
|
+
successor_addrs = extract_jump_targets(last_stmt)
|
|
532
|
+
if len(successor_addrs) != 2:
|
|
533
|
+
return False
|
|
534
|
+
|
|
535
|
+
for t in successor_addrs:
|
|
536
|
+
if t in addr2nodes and t in self.jump_tables:
|
|
537
|
+
# this is a candidate!
|
|
538
|
+
target = t
|
|
539
|
+
break
|
|
540
|
+
else:
|
|
541
|
+
return False
|
|
542
|
+
|
|
543
|
+
jump_table = self.jump_tables[target]
|
|
544
|
+
if jump_table.type != IndirectJumpType.Jumptable_AddressLoadedFromMemory:
|
|
545
|
+
return False
|
|
546
|
+
|
|
547
|
+
# extract the comparison expression, lower-, and upper-bounds from the last statement
|
|
548
|
+
cmp = switch_extract_cmp_bounds(last_stmt)
|
|
549
|
+
if not cmp:
|
|
550
|
+
return False
|
|
551
|
+
cmp_expr, cmp_lb, _cmp_ub = cmp # pylint:disable=unused-variable
|
|
552
|
+
|
|
553
|
+
# the real indirect jump
|
|
554
|
+
if len(addr2nodes[target]) != 1:
|
|
555
|
+
return False
|
|
556
|
+
node_a = next(iter(addr2nodes[target]))
|
|
557
|
+
# the default case
|
|
558
|
+
node_b_addr = next(iter(t for t in successor_addrs if t != target))
|
|
559
|
+
|
|
560
|
+
# Node A might have been structured. Un-structure it if that is the case.
|
|
561
|
+
r, node_a = self._switch_unpack_sequence_node(seq, node_a, node_b_addr, jump_table, addr2nodes)
|
|
562
|
+
if not r:
|
|
563
|
+
return False
|
|
564
|
+
|
|
565
|
+
# build switch-cases
|
|
566
|
+
assert jump_table.jumptable_entries is not None
|
|
567
|
+
cases, node_default, to_remove = self._switch_build_cases(
|
|
568
|
+
seq, cmp_lb, jump_table.jumptable_entries, i, node_b_addr, addr2nodes
|
|
569
|
+
)
|
|
570
|
+
# if we don't know what the end address of this switch-case structure is, let's figure it out
|
|
571
|
+
switch_end_addr = (
|
|
572
|
+
node_b_addr
|
|
573
|
+
if node_default is None
|
|
574
|
+
else self._switch_find_switch_end_addr(cases, node_default, {nn.addr for nn in self._region.graph})
|
|
575
|
+
)
|
|
576
|
+
if switch_end_addr is not None:
|
|
577
|
+
self._switch_handle_gotos(cases, node_default, switch_end_addr)
|
|
578
|
+
|
|
579
|
+
assert last_stmt.tags["ins_addr"] is not None
|
|
580
|
+
self._make_switch_cases_core(
|
|
581
|
+
seq,
|
|
582
|
+
i,
|
|
583
|
+
node,
|
|
584
|
+
cmp_expr,
|
|
585
|
+
cases,
|
|
586
|
+
node_default,
|
|
587
|
+
last_stmt.tags["ins_addr"],
|
|
588
|
+
addr2nodes,
|
|
589
|
+
to_remove,
|
|
590
|
+
node_a=node_a,
|
|
591
|
+
jumptable_addr=jump_table.addr,
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
return True
|
|
595
|
+
|
|
596
|
+
def _make_switch_cases_address_computed(self, seq, i, node, addr2nodes: dict[int, set[CodeNode]]) -> bool:
|
|
597
|
+
if node.addr not in self.jump_tables:
|
|
598
|
+
return False
|
|
599
|
+
jump_table = self.jump_tables[node.addr]
|
|
600
|
+
if jump_table.type != IndirectJumpType.Jumptable_AddressComputed:
|
|
601
|
+
return False
|
|
602
|
+
|
|
603
|
+
try:
|
|
604
|
+
last_stmts = self.cond_proc.get_last_statements(node)
|
|
605
|
+
except EmptyBlockNotice:
|
|
606
|
+
return False
|
|
607
|
+
if len(last_stmts) != 1:
|
|
608
|
+
return False
|
|
609
|
+
last_stmt = last_stmts[0]
|
|
610
|
+
|
|
611
|
+
if not isinstance(last_stmt, ailment.Stmt.ConditionalJump):
|
|
612
|
+
return False
|
|
613
|
+
|
|
614
|
+
# Typical look:
|
|
615
|
+
# t2 = (r5<4> - 0x22<32>)
|
|
616
|
+
# if ((t2 <= 0x1c<32>)) { Goto (0x41d10c<32> + (t2 << 0x2<8>)) } else { Goto 0x41d108<32> }
|
|
617
|
+
#
|
|
618
|
+
# extract the comparison expression, lower-, and upper-bounds from the last statement
|
|
619
|
+
cmp = switch_extract_cmp_bounds(last_stmt)
|
|
620
|
+
if not cmp:
|
|
621
|
+
return False
|
|
622
|
+
cmp_expr, cmp_lb, _cmp_ub = cmp # pylint:disable=unused-variable
|
|
623
|
+
|
|
624
|
+
jumptable_entries = jump_table.jumptable_entries
|
|
625
|
+
assert jumptable_entries is not None
|
|
626
|
+
|
|
627
|
+
if isinstance(last_stmt.false_target, ailment.Expr.Const):
|
|
628
|
+
default_addr = last_stmt.false_target.value
|
|
629
|
+
assert isinstance(default_addr, int)
|
|
630
|
+
else:
|
|
631
|
+
return False
|
|
632
|
+
|
|
633
|
+
cases, node_default, to_remove = self._switch_build_cases(
|
|
634
|
+
seq, cmp_lb, jumptable_entries, i, default_addr, addr2nodes
|
|
635
|
+
)
|
|
636
|
+
if node_default is None:
|
|
637
|
+
# there must be a default case
|
|
638
|
+
return False
|
|
639
|
+
|
|
640
|
+
self._make_switch_cases_core(
|
|
641
|
+
seq,
|
|
642
|
+
i,
|
|
643
|
+
node,
|
|
644
|
+
cmp_expr,
|
|
645
|
+
cases,
|
|
646
|
+
node_default,
|
|
647
|
+
node.addr,
|
|
648
|
+
addr2nodes,
|
|
649
|
+
to_remove,
|
|
650
|
+
jumptable_addr=jump_table.addr,
|
|
651
|
+
)
|
|
652
|
+
|
|
653
|
+
return True
|
|
654
|
+
|
|
655
|
+
def _make_switch_cases_core(
|
|
656
|
+
self,
|
|
657
|
+
seq,
|
|
658
|
+
i,
|
|
659
|
+
node,
|
|
660
|
+
cmp_expr,
|
|
661
|
+
cases: OrderedDict,
|
|
662
|
+
node_default,
|
|
663
|
+
addr,
|
|
664
|
+
addr2nodes,
|
|
665
|
+
to_remove,
|
|
666
|
+
*,
|
|
667
|
+
jumptable_addr: int,
|
|
668
|
+
node_a=None,
|
|
669
|
+
):
|
|
670
|
+
scnode = SwitchCaseNode(cmp_expr, cases, node_default, addr=addr)
|
|
671
|
+
scnode = CodeNode(scnode, node.reaching_condition)
|
|
672
|
+
|
|
673
|
+
# insert the switch-case node
|
|
674
|
+
seq.insert_node(i + 1, scnode)
|
|
675
|
+
# remove all those entry nodes
|
|
676
|
+
if node_default is not None:
|
|
677
|
+
to_remove.add(node_default)
|
|
678
|
+
for node_ in to_remove:
|
|
679
|
+
seq.remove_node(node_)
|
|
680
|
+
addr2nodes[node_.addr].discard(node_)
|
|
681
|
+
if not addr2nodes[node_.addr]:
|
|
682
|
+
del addr2nodes[node_.addr]
|
|
683
|
+
# remove the last statement in node
|
|
684
|
+
remove_last_statement(node)
|
|
685
|
+
if BaseNode.test_empty_node(node):
|
|
686
|
+
seq.remove_node(node)
|
|
687
|
+
if node_a is not None:
|
|
688
|
+
# remove the last statement in node_a
|
|
689
|
+
remove_last_statement(node_a)
|
|
690
|
+
if BaseNode.test_empty_node(node_a):
|
|
691
|
+
seq.remove_node(node_a)
|
|
692
|
+
|
|
693
|
+
# rewrite conditions in the entire SequenceNode to remove jump table entry conditions
|
|
694
|
+
rewriter = JumpTableEntryConditionRewriter(self.cond_proc.jump_table_conds[jumptable_addr])
|
|
695
|
+
rewriter.walk(seq) # update SequenceNodes in-place
|
|
696
|
+
|
|
697
|
+
def _switch_unpack_sequence_node(
|
|
698
|
+
self, seq: SequenceNode, node_a, node_b_addr: int, jumptable, addr2nodes: dict[int, set[CodeNode]]
|
|
699
|
+
) -> tuple[bool, CodeNode | None]:
|
|
700
|
+
"""
|
|
701
|
+
We might have already structured the actual body of the switch-case structure into a single Sequence node (node
|
|
702
|
+
A). If that is the case, we un-structure the sequence node in this method.
|
|
703
|
+
|
|
704
|
+
:param seq: The original Sequence node.
|
|
705
|
+
:param node_a: Node A.
|
|
706
|
+
:param node_b_addr: Address of node B.
|
|
707
|
+
:param jumptable: The corresponding jump table instance.
|
|
708
|
+
:param addr2nodes: A dict of addresses to their corresponding nodes in `seq`.
|
|
709
|
+
:return: A boolean value indicating the result and an updated node_a. The boolean value is
|
|
710
|
+
True if unpacking is not necessary or we successfully unpacked the sequence node,
|
|
711
|
+
False otherwise.
|
|
712
|
+
"""
|
|
713
|
+
|
|
714
|
+
jumptable_entries = jumptable.jumptable_entries
|
|
715
|
+
|
|
716
|
+
node_a_block_addrs = {n.addr for n in node_a.node.nodes} if isinstance(node_a.node, SequenceNode) else set()
|
|
717
|
+
#
|
|
718
|
+
# if that is the case, we un-structure it here
|
|
719
|
+
if all(entry_addr in addr2nodes for entry_addr in jumptable_entries):
|
|
720
|
+
return True, node_a
|
|
721
|
+
if self._switch_check_existence_of_jumptable_entries(
|
|
722
|
+
jumptable_entries, node_a_block_addrs, set(addr2nodes.keys()), node_a.addr, node_b_addr
|
|
723
|
+
):
|
|
724
|
+
# unpacking is needed
|
|
725
|
+
for n in node_a.node.nodes:
|
|
726
|
+
assert n.addr is not None
|
|
727
|
+
if isinstance(n, ConditionNode):
|
|
728
|
+
unpacked = self._switch_unpack_condition_node(n, jumptable)
|
|
729
|
+
if unpacked is None:
|
|
730
|
+
# unsupported. bail
|
|
731
|
+
return False, None
|
|
732
|
+
if n.addr in addr2nodes:
|
|
733
|
+
del addr2nodes[n.addr]
|
|
734
|
+
addr2nodes[n.addr].add(unpacked)
|
|
735
|
+
seq.add_node(unpacked)
|
|
736
|
+
else:
|
|
737
|
+
the_node = CodeNode(n, None)
|
|
738
|
+
if n.addr in addr2nodes:
|
|
739
|
+
del addr2nodes[n.addr]
|
|
740
|
+
addr2nodes[n.addr].add(the_node)
|
|
741
|
+
seq.add_node(the_node)
|
|
742
|
+
if node_a != addr2nodes[node_a.addr]:
|
|
743
|
+
# update node_a
|
|
744
|
+
seq.remove_node(node_a)
|
|
745
|
+
node_a = next(iter(addr2nodes[node_a.addr]))
|
|
746
|
+
return True, node_a
|
|
747
|
+
|
|
748
|
+
# a jumptable entry is missing. it's very likely marked as the successor of the entire switch-case region. we
|
|
749
|
+
# should have been handling it when dealing with multi-exit regions. ignore it here.
|
|
750
|
+
return True, node_a
|
|
751
|
+
|
|
752
|
+
def _switch_unpack_condition_node(self, cond_node: ConditionNode, jumptable) -> CodeNode | None:
|
|
753
|
+
"""
|
|
754
|
+
Unpack condition nodes by only removing one condition in the form of
|
|
755
|
+
<Bool jump_table_402020 == 0x402ac4>.
|
|
756
|
+
|
|
757
|
+
:param cond_node: The condition node to unpack.
|
|
758
|
+
:return: The new unpacked node.
|
|
759
|
+
"""
|
|
760
|
+
|
|
761
|
+
# FIXME: With the new jump table entry condition, this function is probably never used. Remove sequence node
|
|
762
|
+
# FIXME: unpacking logic if that is the case.
|
|
763
|
+
|
|
764
|
+
cond = cond_node.condition
|
|
765
|
+
|
|
766
|
+
# look for a condition in the form of xxx == jump_target
|
|
767
|
+
eq_condition = None
|
|
768
|
+
remaining_cond = None
|
|
769
|
+
true_node = None
|
|
770
|
+
false_node = None
|
|
771
|
+
|
|
772
|
+
jumptable_var = self.cond_proc.create_jump_target_var(jumptable.addr)
|
|
773
|
+
|
|
774
|
+
if cond.op == "And":
|
|
775
|
+
for arg in cond.args:
|
|
776
|
+
if (
|
|
777
|
+
arg.op == "__eq__"
|
|
778
|
+
and arg.args[0] is jumptable_var
|
|
779
|
+
and isinstance(arg.args[1], claripy.ast.Bits)
|
|
780
|
+
and arg.args[1].concrete
|
|
781
|
+
):
|
|
782
|
+
# found it
|
|
783
|
+
eq_condition = arg
|
|
784
|
+
remaining_cond = claripy.And(*(arg_ for arg_ in cond.args if arg_ is not arg))
|
|
785
|
+
true_node = cond_node.true_node
|
|
786
|
+
false_node = cond_node.false_node
|
|
787
|
+
break
|
|
788
|
+
else:
|
|
789
|
+
# unsupported
|
|
790
|
+
return None
|
|
791
|
+
elif cond.op == "__eq__":
|
|
792
|
+
if cond.args[0] is jumptable_var and isinstance(cond.args[1], claripy.ast.Bits) and cond.args[1].concrete:
|
|
793
|
+
# found it
|
|
794
|
+
eq_condition = cond
|
|
795
|
+
true_node = cond_node.true_node
|
|
796
|
+
false_node = cond_node.false_node
|
|
797
|
+
remaining_cond = None
|
|
798
|
+
else:
|
|
799
|
+
# unsupported
|
|
800
|
+
return None
|
|
801
|
+
else:
|
|
802
|
+
# unsupported
|
|
803
|
+
return None
|
|
804
|
+
|
|
805
|
+
if remaining_cond is None:
|
|
806
|
+
if true_node is not None and false_node is None:
|
|
807
|
+
return CodeNode(true_node, eq_condition)
|
|
808
|
+
# unsupported
|
|
809
|
+
return None
|
|
810
|
+
|
|
811
|
+
return CodeNode(
|
|
812
|
+
ConditionNode(cond_node.addr, claripy.true(), remaining_cond, true_node, false_node=false_node),
|
|
813
|
+
eq_condition,
|
|
814
|
+
)
|
|
815
|
+
|
|
816
|
+
def _switch_check_existence_of_jumptable_entries(
|
|
817
|
+
self,
|
|
818
|
+
jumptable_entries,
|
|
819
|
+
node_a_block_addrs: set[int],
|
|
820
|
+
known_node_addrs: set[int],
|
|
821
|
+
node_a_addr: int,
|
|
822
|
+
node_b_addr: int,
|
|
823
|
+
) -> bool:
|
|
824
|
+
"""
|
|
825
|
+
Check if all entries in the given jump table exist in the given set of nodes of a SequenceNode.
|
|
826
|
+
|
|
827
|
+
:param jumptable_entries: Addresses of jump table entries.
|
|
828
|
+
:param node_a_block_addrs: A set of addresses for nodes that belong to Node A.
|
|
829
|
+
:return: True if the check passes, False otherwise.
|
|
830
|
+
"""
|
|
831
|
+
|
|
832
|
+
all_node_addrs = node_a_block_addrs | known_node_addrs | {node_b_addr}
|
|
833
|
+
expected_node_a_addrs = set()
|
|
834
|
+
for entry_addr in jumptable_entries:
|
|
835
|
+
if entry_addr in all_node_addrs:
|
|
836
|
+
expected_node_a_addrs.add(entry_addr)
|
|
837
|
+
continue
|
|
838
|
+
# the entry may go missing if the entire node has been folded into its successor node.
|
|
839
|
+
# in this case, we check if (a) this entry node has only one successor, and (b) this successor exists in
|
|
840
|
+
# seq_node_addrs.
|
|
841
|
+
if self.function is not None:
|
|
842
|
+
entry_node = self.function.get_node(entry_addr)
|
|
843
|
+
if entry_node is not None:
|
|
844
|
+
successors = []
|
|
845
|
+
for _, dst, data in self.function.graph.out_edges(entry_node, data=True):
|
|
846
|
+
if data.get("type", "transition") != "call":
|
|
847
|
+
successors.append(dst)
|
|
848
|
+
if len(successors) == 1 and successors[0].addr in all_node_addrs:
|
|
849
|
+
# found the single successor
|
|
850
|
+
expected_node_a_addrs.add(successors[0].addr)
|
|
851
|
+
continue
|
|
852
|
+
# it's also possible that this is just a jump that breaks out of the switch-case. we simply ignore it.
|
|
853
|
+
continue
|
|
854
|
+
|
|
855
|
+
# finally, make sure all expected nodes exist
|
|
856
|
+
# not sure what is going on... if it's false
|
|
857
|
+
return node_a_block_addrs.issuperset((expected_node_a_addrs | {node_a_addr}) - {node_b_addr})
|
|
858
|
+
|
|
859
|
+
def _switch_find_jumptable_entry_node(self, entry_addr: int, addr2nodes: dict[int, set[CodeNode]]) -> Any | None:
|
|
860
|
+
"""
|
|
861
|
+
Find the correct node for a given jump table entry address in addr2nodes.
|
|
862
|
+
|
|
863
|
+
This method is needed because prior optimization steps may remove some blocks (e.g., empty blocks or blocks that
|
|
864
|
+
only have branch instructions). If the given jump table entry address corresponds to a removed block, it will
|
|
865
|
+
not be found inside addr2nodes dict. In such cases, we need to follow graph edges in the CFG and find the first
|
|
866
|
+
block whose address is inside addr2nodes dict.
|
|
867
|
+
|
|
868
|
+
:param entry_addr: Address of the jump table entry.
|
|
869
|
+
:return: The correct node if we can find it, or None if we fail to find one.
|
|
870
|
+
"""
|
|
871
|
+
|
|
872
|
+
if entry_addr in addr2nodes and len(addr2nodes[entry_addr]) == 1:
|
|
873
|
+
return next(iter(addr2nodes[entry_addr]))
|
|
874
|
+
# magic
|
|
875
|
+
if self.function is None:
|
|
876
|
+
return None
|
|
877
|
+
|
|
878
|
+
addr = entry_addr
|
|
879
|
+
node = self.function.get_node(addr)
|
|
880
|
+
for _ in range(5): # we try at most five steps
|
|
881
|
+
if node is None:
|
|
882
|
+
return None
|
|
883
|
+
successors = []
|
|
884
|
+
for _, dst, data in self.function.graph.out_edges(node, data=True):
|
|
885
|
+
if data.get("type", "transition") != "call":
|
|
886
|
+
successors.append(dst)
|
|
887
|
+
if len(successors) != 1:
|
|
888
|
+
return None
|
|
889
|
+
successor = successors[0]
|
|
890
|
+
if successor.addr in addr2nodes:
|
|
891
|
+
# found it!
|
|
892
|
+
return next(iter(addr2nodes[successor.addr]))
|
|
893
|
+
# keep looking
|
|
894
|
+
node = successor
|
|
895
|
+
return None
|
|
896
|
+
|
|
897
|
+
def _switch_build_cases(
|
|
898
|
+
self,
|
|
899
|
+
seq: SequenceNode,
|
|
900
|
+
cmp_lb: int,
|
|
901
|
+
jumptable_entries: list[int],
|
|
902
|
+
head_node_idx: int,
|
|
903
|
+
node_b_addr: int,
|
|
904
|
+
addr2nodes: dict[int, set[CodeNode]],
|
|
905
|
+
) -> tuple[OrderedDict, Any, Any]:
|
|
906
|
+
"""
|
|
907
|
+
Discover all cases for the switch-case structure and build the switch-cases dict.
|
|
908
|
+
|
|
909
|
+
:param seq: The original Sequence node.
|
|
910
|
+
:param cmp_lb: The lower bound of the jump table comparison.
|
|
911
|
+
:param jumptable_entries: Addresses of indirect jump targets in the jump table.
|
|
912
|
+
:param head_node_addr: The index of the head block of this jump table in `seq`.
|
|
913
|
+
:param node_b_addr: Address of node B. Potentially, node B is the default node.
|
|
914
|
+
:param addr2nodes: A dict of addresses to their corresponding nodes in `seq`.
|
|
915
|
+
:return: A tuple of (dict of cases, the default node if exists, nodes to remove).
|
|
916
|
+
"""
|
|
917
|
+
|
|
918
|
+
cases: OrderedDict[int | tuple[int, ...], SequenceNode] = OrderedDict()
|
|
919
|
+
to_remove = set()
|
|
920
|
+
node_default = addr2nodes.get(node_b_addr)
|
|
921
|
+
if node_default is not None:
|
|
922
|
+
node_default = next(iter(node_default))
|
|
923
|
+
|
|
924
|
+
entry_addrs_set = set(jumptable_entries)
|
|
925
|
+
converted_nodes: dict[int, Any] = {}
|
|
926
|
+
entry_addr_to_ids = defaultdict(set)
|
|
927
|
+
|
|
928
|
+
for j, entry_addr in enumerate(jumptable_entries):
|
|
929
|
+
cases_idx = cmp_lb + j
|
|
930
|
+
if entry_addr == node_b_addr:
|
|
931
|
+
# jump to default or end of the switch-case structure - ignore this case
|
|
932
|
+
continue
|
|
933
|
+
|
|
934
|
+
entry_addr_to_ids[entry_addr].add(cases_idx)
|
|
935
|
+
|
|
936
|
+
if entry_addr in converted_nodes:
|
|
937
|
+
continue
|
|
938
|
+
|
|
939
|
+
entry_node = self._switch_find_jumptable_entry_node(entry_addr, addr2nodes)
|
|
940
|
+
if entry_node is None:
|
|
941
|
+
# Missing entries. They are probably *after* the entire switch-case construct. Replace it with an empty
|
|
942
|
+
# Goto node.
|
|
943
|
+
case_inner_node = ailment.Block(
|
|
944
|
+
0,
|
|
945
|
+
0,
|
|
946
|
+
statements=[
|
|
947
|
+
ailment.Stmt.Jump(
|
|
948
|
+
None,
|
|
949
|
+
ailment.Expr.Const(None, None, entry_addr, self.project.arch.bits),
|
|
950
|
+
ins_addr=0,
|
|
951
|
+
stmt_idx=0,
|
|
952
|
+
)
|
|
953
|
+
],
|
|
954
|
+
)
|
|
955
|
+
case_node = SequenceNode(0, nodes=[CodeNode(case_inner_node, claripy.true())])
|
|
956
|
+
converted_nodes[entry_addr] = case_node
|
|
957
|
+
continue
|
|
958
|
+
|
|
959
|
+
case_node = SequenceNode(entry_node.addr, nodes=[CodeNode(entry_node.node, claripy.true())])
|
|
960
|
+
to_remove.add(entry_node)
|
|
961
|
+
entry_node_idx = seq.nodes.index(entry_node)
|
|
962
|
+
|
|
963
|
+
if entry_node_idx <= head_node_idx:
|
|
964
|
+
# it's jumping to a block that dominates the head. it's likely to be an optimized continue; statement
|
|
965
|
+
# in a switch-case wrapped inside a while loop.
|
|
966
|
+
# replace it with an empty Goto node
|
|
967
|
+
case_inner_node = ailment.Block(
|
|
968
|
+
0,
|
|
969
|
+
0,
|
|
970
|
+
statements=[
|
|
971
|
+
ailment.Stmt.Jump(
|
|
972
|
+
None,
|
|
973
|
+
ailment.Expr.Const(None, None, entry_addr, self.project.arch.bits),
|
|
974
|
+
ins_addr=0,
|
|
975
|
+
stmt_idx=0,
|
|
976
|
+
)
|
|
977
|
+
],
|
|
978
|
+
)
|
|
979
|
+
case_node = SequenceNode(0, nodes=[CodeNode(case_inner_node, claripy.true())])
|
|
980
|
+
converted_nodes[entry_addr] = case_node
|
|
981
|
+
continue
|
|
982
|
+
|
|
983
|
+
# find nodes that this entry node dominates
|
|
984
|
+
cond_subexprs = list(get_ast_subexprs(entry_node.reaching_condition))
|
|
985
|
+
guarded_nodes = None
|
|
986
|
+
for subexpr in cond_subexprs:
|
|
987
|
+
guarded_node_candidates = self._nodes_guarded_by_common_subexpr(seq, subexpr, entry_node_idx + 1)
|
|
988
|
+
if guarded_nodes is None:
|
|
989
|
+
guarded_nodes = {node_ for _, node_, _ in guarded_node_candidates}
|
|
990
|
+
else:
|
|
991
|
+
guarded_nodes = guarded_nodes.intersection({node_ for _, node_, _ in guarded_node_candidates})
|
|
992
|
+
|
|
993
|
+
if guarded_nodes is not None:
|
|
994
|
+
# keep the topological order of nodes in Sequence node
|
|
995
|
+
sorted_guarded_nodes = [node_ for node_ in seq.nodes[entry_node_idx + 1 :] if node_ in guarded_nodes]
|
|
996
|
+
for node_ in sorted_guarded_nodes:
|
|
997
|
+
if node_ is not entry_node and node_.addr not in entry_addrs_set:
|
|
998
|
+
# fix reaching condition
|
|
999
|
+
reaching_condition_subexprs = set(get_ast_subexprs(node_.reaching_condition)).difference(
|
|
1000
|
+
set(cond_subexprs)
|
|
1001
|
+
)
|
|
1002
|
+
new_reaching_condition = claripy.And(*reaching_condition_subexprs)
|
|
1003
|
+
new_node = CodeNode(node_.node, new_reaching_condition)
|
|
1004
|
+
case_node.add_node(new_node)
|
|
1005
|
+
to_remove.add(node_)
|
|
1006
|
+
|
|
1007
|
+
# do we have a default node?
|
|
1008
|
+
case_last_stmt = self.cond_proc.get_last_statement(case_node)
|
|
1009
|
+
if isinstance(case_last_stmt, ailment.Stmt.Jump):
|
|
1010
|
+
targets = extract_jump_targets(case_last_stmt)
|
|
1011
|
+
if len(targets) == 1 and targets[0] == node_b_addr:
|
|
1012
|
+
# jump to the default case is rare - it's more likely that there is no default for this
|
|
1013
|
+
# switch-case struct
|
|
1014
|
+
node_default = None
|
|
1015
|
+
|
|
1016
|
+
converted_nodes[entry_addr] = case_node
|
|
1017
|
+
|
|
1018
|
+
for entry_addr, converted_node in converted_nodes.items():
|
|
1019
|
+
cases_ids = entry_addr_to_ids[entry_addr]
|
|
1020
|
+
if len(cases_ids) == 1:
|
|
1021
|
+
cases[next(iter(cases_ids))] = converted_node
|
|
1022
|
+
else:
|
|
1023
|
+
cases[tuple(sorted(cases_ids))] = converted_node
|
|
1024
|
+
|
|
1025
|
+
self._new_sequences.append(converted_node)
|
|
1026
|
+
|
|
1027
|
+
# reorganize cases to handle fallthroughs
|
|
1028
|
+
cases = self._reorganize_switch_cases(cases)
|
|
1029
|
+
|
|
1030
|
+
return cases, node_default, to_remove
|
|
1031
|
+
|
|
1032
|
+
#
|
|
1033
|
+
# Dealing with If-Then-Else structures
|
|
1034
|
+
#
|
|
1035
|
+
|
|
1036
|
+
def _make_ites(self, seq):
|
|
1037
|
+
# search for a == ^a pairs
|
|
1038
|
+
|
|
1039
|
+
while True:
|
|
1040
|
+
break_hard = False
|
|
1041
|
+
for i in range(len(seq.nodes)):
|
|
1042
|
+
node_0 = seq.nodes[i]
|
|
1043
|
+
if type(node_0) is not CodeNode:
|
|
1044
|
+
continue
|
|
1045
|
+
rcond_0 = node_0.reaching_condition
|
|
1046
|
+
if rcond_0 is None:
|
|
1047
|
+
continue
|
|
1048
|
+
if claripy.is_true(rcond_0) or claripy.is_false(rcond_0):
|
|
1049
|
+
continue
|
|
1050
|
+
for j in range(i + 1, len(seq.nodes)):
|
|
1051
|
+
node_1 = seq.nodes[j]
|
|
1052
|
+
if type(node_1) is not CodeNode:
|
|
1053
|
+
continue
|
|
1054
|
+
if node_0 is node_1:
|
|
1055
|
+
continue
|
|
1056
|
+
rcond_1 = node_1.reaching_condition
|
|
1057
|
+
if rcond_1 is None:
|
|
1058
|
+
continue
|
|
1059
|
+
cond_ = claripy.simplify(claripy.Not(rcond_0) == rcond_1)
|
|
1060
|
+
if claripy.is_true(cond_):
|
|
1061
|
+
# node_0 and node_1 should be structured using an if-then-else
|
|
1062
|
+
self._make_ite(seq, node_0, node_1)
|
|
1063
|
+
break_hard = True
|
|
1064
|
+
break
|
|
1065
|
+
if break_hard:
|
|
1066
|
+
break
|
|
1067
|
+
else:
|
|
1068
|
+
break
|
|
1069
|
+
|
|
1070
|
+
def _structure_common_subexpression_conditions(self, seq):
|
|
1071
|
+
# use common subexpressions to structure nodes and create more if-then-else instances
|
|
1072
|
+
|
|
1073
|
+
i = 0
|
|
1074
|
+
while i < len(seq.nodes) - 1:
|
|
1075
|
+
structured = False
|
|
1076
|
+
node_0 = seq.nodes[i]
|
|
1077
|
+
if not isinstance(node_0, CodeNode):
|
|
1078
|
+
i += 1
|
|
1079
|
+
continue
|
|
1080
|
+
rcond_0 = node_0.reaching_condition
|
|
1081
|
+
if rcond_0 is None:
|
|
1082
|
+
i += 1
|
|
1083
|
+
continue
|
|
1084
|
+
subexprs_0 = list(get_ast_subexprs(rcond_0))
|
|
1085
|
+
|
|
1086
|
+
for common_subexpr in subexprs_0:
|
|
1087
|
+
if claripy.is_true(common_subexpr):
|
|
1088
|
+
continue
|
|
1089
|
+
candidates = self._nodes_guarded_by_common_subexpr(seq, common_subexpr, i + 1)
|
|
1090
|
+
if candidates:
|
|
1091
|
+
candidates.insert(0, (i, node_0, subexprs_0))
|
|
1092
|
+
new_node = self._create_seq_node_guarded_by_common_subexpr(common_subexpr, candidates)
|
|
1093
|
+
self._new_sequences.append(new_node)
|
|
1094
|
+
|
|
1095
|
+
# remove all old nodes and replace them with the new node
|
|
1096
|
+
for idx, _, _ in candidates:
|
|
1097
|
+
seq.nodes[idx] = None
|
|
1098
|
+
seq.nodes[i] = CodeNode(new_node, common_subexpr)
|
|
1099
|
+
seq.nodes = [n for n in seq.nodes if n is not None]
|
|
1100
|
+
structured = True
|
|
1101
|
+
break
|
|
1102
|
+
|
|
1103
|
+
if not structured:
|
|
1104
|
+
i += 1
|
|
1105
|
+
|
|
1106
|
+
@staticmethod
|
|
1107
|
+
def _nodes_guarded_by_common_subexpr(seq, common_subexpr, starting_idx):
|
|
1108
|
+
candidates = []
|
|
1109
|
+
|
|
1110
|
+
if common_subexpr is claripy.true():
|
|
1111
|
+
return []
|
|
1112
|
+
for j, node_1 in enumerate(seq.nodes[starting_idx:]):
|
|
1113
|
+
rcond_1 = getattr(node_1, "reaching_condition", None)
|
|
1114
|
+
if rcond_1 is None:
|
|
1115
|
+
continue
|
|
1116
|
+
subexprs_1 = list(get_ast_subexprs(rcond_1))
|
|
1117
|
+
if any(subexpr_1 is common_subexpr for subexpr_1 in subexprs_1):
|
|
1118
|
+
# we found one!
|
|
1119
|
+
candidates.append((starting_idx + j, node_1, subexprs_1))
|
|
1120
|
+
|
|
1121
|
+
return candidates
|
|
1122
|
+
|
|
1123
|
+
@staticmethod
|
|
1124
|
+
def _create_seq_node_guarded_by_common_subexpr(common_subexpr, candidates):
|
|
1125
|
+
new_nodes = []
|
|
1126
|
+
|
|
1127
|
+
for _, node, subexprs in candidates:
|
|
1128
|
+
# :)
|
|
1129
|
+
new_subexprs = [ex for ex in subexprs if ex is not common_subexpr]
|
|
1130
|
+
new_node = CodeNode(
|
|
1131
|
+
node.node,
|
|
1132
|
+
claripy.And(*new_subexprs),
|
|
1133
|
+
)
|
|
1134
|
+
new_nodes.append(new_node)
|
|
1135
|
+
|
|
1136
|
+
return SequenceNode(None if not new_nodes else new_nodes[0].addr, nodes=new_nodes)
|
|
1137
|
+
|
|
1138
|
+
def _replace_complex_reaching_conditions(self, seq: SequenceNode):
|
|
1139
|
+
for i in range(len(seq.nodes)):
|
|
1140
|
+
node = seq.nodes[i]
|
|
1141
|
+
|
|
1142
|
+
if (
|
|
1143
|
+
isinstance(node, CodeNode)
|
|
1144
|
+
and node.reaching_condition is not None
|
|
1145
|
+
and node.reaching_condition.op == "Or"
|
|
1146
|
+
and node.node in self.cond_proc.guarding_conditions
|
|
1147
|
+
):
|
|
1148
|
+
guarding_condition = self.cond_proc.guarding_conditions[node.node]
|
|
1149
|
+
# the op of guarding condition is always "Or"
|
|
1150
|
+
if (
|
|
1151
|
+
len(guarding_condition.args) < len(node.reaching_condition.args)
|
|
1152
|
+
and guarding_condition.depth < node.reaching_condition.depth
|
|
1153
|
+
):
|
|
1154
|
+
node.reaching_condition = guarding_condition
|
|
1155
|
+
|
|
1156
|
+
def _make_condition_nodes(self, seq):
|
|
1157
|
+
# make all conditionally-reachable nodes ConditionNodes
|
|
1158
|
+
for i in range(len(seq.nodes)):
|
|
1159
|
+
node = seq.nodes[i]
|
|
1160
|
+
|
|
1161
|
+
if isinstance(node, CodeNode):
|
|
1162
|
+
if isinstance(node.node, SequenceNode) and node.node not in self._new_sequences:
|
|
1163
|
+
self._make_condition_nodes(node.node)
|
|
1164
|
+
|
|
1165
|
+
if node.reaching_condition is not None and not claripy.is_true(node.reaching_condition):
|
|
1166
|
+
if isinstance(node.node, ConditionalBreakNode):
|
|
1167
|
+
# Put conditions together and simplify them
|
|
1168
|
+
cond = claripy.And(node.reaching_condition, node.node.condition)
|
|
1169
|
+
new_node = CodeNode(ConditionalBreakNode(node.node.addr, cond, node.node.target), None)
|
|
1170
|
+
else:
|
|
1171
|
+
new_node = ConditionNode(node.addr, None, node.reaching_condition, node, None)
|
|
1172
|
+
seq.nodes[i] = new_node
|
|
1173
|
+
|
|
1174
|
+
@staticmethod
|
|
1175
|
+
def _make_cascading_condition_nodes(seq: SequenceNode):
|
|
1176
|
+
"""
|
|
1177
|
+
Convert nested condition nodes into a CascadingConditionNode.
|
|
1178
|
+
"""
|
|
1179
|
+
CascadingConditionTransformer(seq)
|
|
1180
|
+
|
|
1181
|
+
def _make_ite(self, seq, node_0, node_1):
|
|
1182
|
+
# ensure order
|
|
1183
|
+
if node_0.addr > node_1.addr:
|
|
1184
|
+
node_0, node_1 = node_1, node_0
|
|
1185
|
+
|
|
1186
|
+
node_0_pos = seq.node_position(node_0)
|
|
1187
|
+
node_1_pos = seq.node_position(node_1)
|
|
1188
|
+
pos = max(node_0_pos, node_1_pos)
|
|
1189
|
+
|
|
1190
|
+
node_0_, node_1_ = node_0.copy(), node_1.copy()
|
|
1191
|
+
# clear their reaching conditions
|
|
1192
|
+
node_0_.reaching_condition = None
|
|
1193
|
+
node_1_.reaching_condition = None
|
|
1194
|
+
|
|
1195
|
+
node_0_kids = self._nodes_guarded_by_common_subexpr(seq, node_0.reaching_condition, node_0_pos + 1)
|
|
1196
|
+
node_0_kids.insert(0, (node_0_pos, node_0_, [node_0.reaching_condition]))
|
|
1197
|
+
node_1_kids = self._nodes_guarded_by_common_subexpr(seq, node_1.reaching_condition, node_1_pos + 1)
|
|
1198
|
+
node_1_kids.insert(0, (node_1_pos, node_1_, [node_1.reaching_condition]))
|
|
1199
|
+
|
|
1200
|
+
new_node_0 = self._create_seq_node_guarded_by_common_subexpr(node_0.reaching_condition, node_0_kids)
|
|
1201
|
+
new_node_1 = self._create_seq_node_guarded_by_common_subexpr(node_1.reaching_condition, node_1_kids)
|
|
1202
|
+
|
|
1203
|
+
self._new_sequences.append(new_node_0)
|
|
1204
|
+
self._new_sequences.append(new_node_1)
|
|
1205
|
+
|
|
1206
|
+
seq_addr = seq.addr
|
|
1207
|
+
|
|
1208
|
+
# erase all nodes in the candidates
|
|
1209
|
+
for idx, _, _ in node_0_kids + node_1_kids:
|
|
1210
|
+
seq.nodes[idx] = None
|
|
1211
|
+
|
|
1212
|
+
seq.insert_node(pos, ConditionNode(seq_addr, None, node_0.reaching_condition, new_node_0, new_node_1))
|
|
1213
|
+
seq.nodes = [n for n in seq.nodes if n is not None]
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
# delayed import
|
|
1217
|
+
from angr.analyses.decompiler.sequence_walker import SequenceWalker # pylint:disable=wrong-import-position
|