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
评论列表
文章目录