| 255 | |
| 256 | @exceptions_handler(Exception) |
| 257 | def print_debug(binary): |
| 258 | format_str = "{:<33} {:<30}" |
| 259 | format_hex = "{:<33} 0x{:<28x}" |
| 260 | format_dec = "{:<33} {:<30d}" |
| 261 | |
| 262 | debugs = binary.debug |
| 263 | print("== Debug ({}) ==".format(len(debugs))) |
| 264 | for debug in debugs: |
| 265 | print(format_hex.format("Characteristics:", debug.characteristics)) |
| 266 | print(format_hex.format("Timestamp:", debug.timestamp)) |
| 267 | print(format_dec.format("Major version:", debug.major_version)) |
| 268 | print(format_dec.format("Minor version:", debug.minor_version)) |
| 269 | print(format_str.format("type:", str(debug.type).split(".")[-1])) |
| 270 | print(format_hex.format("Size of data:", debug.sizeof_data)) |
| 271 | print(format_hex.format("Address of raw data:", debug.addressof_rawdata)) |
| 272 | print(format_hex.format("Pointer to raw data:", debug.pointerto_rawdata)) |
| 273 | |
| 274 | if isinstance(debug, lief.PE.CodeViewPDB): |
| 275 | code_view: lief.PE.CodeViewPDB = debug |
| 276 | cv_signature = code_view.cv_signature |
| 277 | sig_str = " ".join(map(lambda e : "{:02x}".format(e), code_view.signature)) |
| 278 | print(format_str.format("Code View Signature:", str(cv_signature).split(".")[-1])) |
| 279 | print(format_str.format("Signature:", sig_str)) |
| 280 | print(format_dec.format("Age:", code_view.age)) |
| 281 | print(format_str.format("Filename:", code_view.filename)) |
| 282 | elif isinstance(debug, lief.PE.CodeView): |
| 283 | code_view: lief.PE.CodeView = debug |
| 284 | cv_signature = code_view.cv_signature |
| 285 | print(format_str.format("Code View Signature:", str(cv_signature).split(".")[-1])) |
| 286 | elif isinstance(debug, lief.PE.Pogo): |
| 287 | pogo: lief.PE.Pogo = debug |
| 288 | sig_str = str(pogo.signature).split(".")[-1] |
| 289 | print(format_str.format("Signature:", sig_str)) |
| 290 | print("Entries:") |
| 291 | for entry in pogo.entries: |
| 292 | print(" {:<20} 0x{:x} ({:d})".format(entry.name, entry.start_rva, entry.size)) |
| 293 | |
| 294 | print("\n") |
| 295 | |
| 296 | @exceptions_handler(Exception) |
| 297 | def print_signature(binary): |