| 145 | |
| 146 | @exceptions_handler(Exception) |
| 147 | def print_sections(binary): |
| 148 | sections = binary.sections |
| 149 | |
| 150 | print("== Sections ==") |
| 151 | f_title = "|{:<10} | {:<16} | {:<16} | {:<18} | {:<16} | {:<9} | {:<9}" |
| 152 | f_value = "|{:<10} | 0x{:<14x} | 0x{:<14x} | 0x{:<16x} | 0x{:<14x} | {:<9.2f} | {:<9}" |
| 153 | print(f_title.format("Name", "Offset", "Size", "Virtual Address", "Virtual size", "Entropy", "Flags")) |
| 154 | |
| 155 | for section in sections: |
| 156 | flags = "" |
| 157 | for flag in section.characteristics_lists: |
| 158 | flags += str(flag).split(".")[-1] + " " |
| 159 | print(f_value.format(section.name, section.offset, section.size, section.virtual_address, section.virtual_size, section.entropy, flags)) |
| 160 | print("") |
| 161 | |
| 162 | |
| 163 | @exceptions_handler(Exception) |