sample.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:polichombr 作者: ANSSI-FR 项目源码 文件源码
def disassemble_sample_get_svg(sample_id, address):
    """
        Gets SVG file data, with functions names.
    """
    graph = disassemble_sample(sample_id, address)
    filename = Sample.query.get(sample_id).storage_file
    data = Source(graph, format='svg')
    out_file = filename + "_disass_"
    if address is not None:
        out_file += hex(address)
    out_file = data.render(out_file)
    beautify_svg(out_file)
    svg_data = open(out_file, 'rb').read()
    elements = re.findall("func_<!-- -->[0-9a-f]{3,}h", svg_data)
    for e in elements:
        et = e[13:-1]
        for i in Sample.query.get(sample_id).functions:
            if i.address == et:
                svg_data = svg_data.replace(e, i.name)
    elements = re.findall("loc_[0-9a-f]{3,}h", svg_data)
    for e in elements:
        et = e[4:-1]
        for i in Sample.query.get(sample_id).functions:
            if i.address == et:
                svg_data = svg_data.replace(e, i.name)
    return svg_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号