def get_sections(binary_file):
"""
Gets file sections => thanks to PE.
Returns an multiDimensional array: [binary_file, sections_exe, sections_data]
"""
sections_exe = []
sections_data = []
pe = pefile.PE(data=binary_file)
sections = pe.sections
for section in sections:
# 0x20000000 IMAGE_SCN_MEM_EXECUTE
# 0x40000000 IMAGE_SCN_MEM_READ
# 0x00000020 IMAGE_SCN_CNT_CODE
if all(section.Characteristics & n for n in [0x20000000, 0x40000000, 0x00000020]):
sections_exe.append(section)
else:
sections_data.append(section)
return [binary_file, sections_exe, sections_data]
评论列表
文章目录