| 98 | |
| 99 | @exceptions_handler(Exception) |
| 100 | def print_sections(binary): |
| 101 | sections = binary.sections |
| 102 | if len(sections) > 0: |
| 103 | print("== Sections ==\n") |
| 104 | f_title = "|{:<30} | {:<12}| {:<17}| {:<12}| {:<10}| {:<8}| {:<8}|" |
| 105 | f_value = "|{:<30} | {:<12}| 0x{:<14x} | 0x{:<10x}| 0x{:<8x}| {:<8.2f}| {:<10}" |
| 106 | print(f_title.format("Name", "Type", "Virtual address", "File offset", "Size", "Entropy", "Segment(s)")) |
| 107 | |
| 108 | for section in sections: |
| 109 | segments_str = " - ".join([str(s.type).split(".")[-1] for s in section.segments]) |
| 110 | print(f_value.format( |
| 111 | section.name, |
| 112 | str(section.type).split(".")[-1], |
| 113 | section.virtual_address, |
| 114 | section.file_offset, |
| 115 | section.size, |
| 116 | abs(section.entropy), |
| 117 | segments_str)) |
| 118 | print("") |
| 119 | else: |
| 120 | print("No sections") |
| 121 | |
| 122 | @exceptions_handler(Exception) |
| 123 | def print_segments(binary): |