示例#1
0
def print_features(functions, extractor):
    for f in functions:
        function_address = int(f)

        if extractor.is_library_function(function_address):
            function_name = extractor.get_function_name(function_address)
            logger.debug("skipping library function 0x%x (%s)",
                         function_address, function_name)
            continue

        for feature, va in extractor.extract_function_features(f):
            print("func: 0x%08x: %s" % (va, feature))

        for bb in extractor.get_basic_blocks(f):
            for feature, va in extractor.extract_basic_block_features(f, bb):
                print("bb  : 0x%08x: %s" % (va, feature))

            for insn in extractor.get_instructions(f, bb):
                for feature, va in extractor.extract_insn_features(
                        f, bb, insn):
                    try:
                        print("insn: 0x%08x: %s" % (va, feature))
                    except UnicodeEncodeError:
                        # may be an issue while piping to less and encountering non-ascii characters
                        continue
示例#2
0
文件: form.py 项目: gunjin1/capa
def find_func_features(f, extractor):
    """ """
    func_features = collections.defaultdict(set)
    bb_features = collections.defaultdict(dict)

    for (feature, ea) in extractor.extract_function_features(f):
        func_features[feature].add(ea)

    for bb in extractor.get_basic_blocks(f):
        _bb_features = collections.defaultdict(set)

        for (feature, ea) in extractor.extract_basic_block_features(f, bb):
            _bb_features[feature].add(ea)
            func_features[feature].add(ea)

        for insn in extractor.get_instructions(f, bb):
            for (feature, ea) in extractor.extract_insn_features(f, bb, insn):
                _bb_features[feature].add(ea)
                func_features[feature].add(ea)

        bb_features[int(bb)] = _bb_features

    return func_features, bb_features