项目作者: 0vercl0k

项目描述 :
Windows kernel dump C++ parser with Python 3 bindings.
高级语言: C++
项目地址: git://github.com/0vercl0k/kdmp-parser.git
创建时间: 2020-02-15T15:27:14Z
项目社区:https://github.com/0vercl0k/kdmp-parser

开源协议:MIT License

下载


kdmp-parser

Build status
Downloads

This C++ library parses Windows kernel full dumps (.dump /f in WinDbg), BMP dumps (.dump /ka in WinDbg) as well as more recent dump types that were introduced in ~2022.

parser

The library supports loading 64-bit dumps and provides read access to things like:

  • The context record,
  • The exception record,
  • The bugcheck parameters,
  • The physical memory.

Compiled binaries are available in the releases section.

Special thanks to:

Parser

The parser.exe application is able to dump various information about the dump file: exception record, context record, etc.

  1. >parser.exe -c -e -p 0x1000 full.dmp
  2. --------------------------------------------------------------------------------
  3. Context Record:
  4. rax=0000000000000003 rbx=fffff8050f4e9f70 rcx=0000000000000001
  5. rdx=fffff805135684d0 rsi=0000000000000100 rdi=fffff8050f4e9f80
  6. rip=fffff805108776a0 rsp=fffff805135684f8 rbp=fffff80513568600
  7. r8=0000000000000003 r9=fffff805135684b8 r10=0000000000000000
  8. r11=ffffa8848825e000 r12=fffff8050f4e9f80 r13=fffff80510c3c958
  9. r14=0000000000000000 r15=0000000000000052
  10. cs=0010 ss=0018 ds=002b es=002b fs=0053 gs=002b efl=00040202
  11. fpcw=0000 fpsw=0000 fptw=0001
  12. st0=fffff80510bbf000fffff80510c3c9c0 st1=0005e5a800ab2000fffff805106b3000
  13. st2=4000000000200000fffff80510beaea8 st3=000000000a0d656c69666f7250206465
  14. st4=0000000a0d656c69666f725000000010 st5=0000000000000000fffff80510b16900
  15. st6=0000000000000000fffff805133e9000 st7=fffff47c02899f480000000000000000
  16. xmm0=000000000a0d656c69666f7250206465 xmm1=0000000a0d656c69666f725000000010
  17. xmm2=0000000000000000fffff80510b16900 xmm3=0000000000000000fffff805133e9000
  18. xmm4=fffff47c02899f480000000000000000 xmm5=00000000000000000000000000000000
  19. xmm6=00000000000000000000000000000000 xmm7=00000000000000000000000000000000
  20. xmm8=00000000000000000000000000000000 xmm9=00000000000000000000000000000000
  21. xmm10=00000000000000000000000000000000 xmm11=00000000000000000000000000000000
  22. xmm12=00000000000000000000000000000000 xmm13=00000000000000000000000000000000
  23. xmm14=00000000000000000000000000000000 xmm15=00000000000000000000000000000000
  24. --------------------------------------------------------------------------------
  25. Exception Record:
  26. KDMP_PARSER_EXCEPTION_RECORD64
  27. +0x0000: ExceptionCode : 0x80000003.
  28. +0x0004: ExceptionFlags : 0x00000000.
  29. +0x0008: ExceptionRecord : 0x0000000000000000.
  30. +0x0010: ExceptionAddress : 0xfffff805108776a0.
  31. +0x0018: NumberParameters : 0x00000001.
  32. +0x0020: ExceptionInformation[0] : 0x0000000000000000.
  33. +0x0028: ExceptionInformation[1] : 0x0000000000000000.
  34. +0x0030: ExceptionInformation[2] : 0xffffa8848825e000.
  35. +0x0038: ExceptionInformation[3] : 0x00000000000002c0.
  36. +0x0040: ExceptionInformation[4] : 0xfffff80511022203.
  37. +0x0048: ExceptionInformation[5] : 0x0000000000004280.
  38. +0x0050: ExceptionInformation[6] : 0xfffff80510880524.
  39. +0x0058: ExceptionInformation[7] : 0xffffa88488282360.
  40. +0x0060: ExceptionInformation[8] : 0x0000000000000280.
  41. +0x0068: ExceptionInformation[9] : 0xfffff805135683d8.
  42. +0x0070: ExceptionInformation[10] : 0xffffa8848d9d6fb0.
  43. +0x0078: ExceptionInformation[11] : 0x0000000000004280.
  44. +0x0080: ExceptionInformation[12] : 0x00001f8001004280.
  45. +0x0088: ExceptionInformation[13] : 0x0000000000000003.
  46. +0x0090: ExceptionInformation[14] : 0xfffff80513568578.
  47. --------------------------------------------------------------------------------
  48. Physical memory:
  49. 00001000: 00 00 00 00 00 00 00 00 00 00 f9 ff 00 00 00 00 |................|
  50. 00001010: 00 06 01 01 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  51. 00001020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  52. 00001030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  53. 00001040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  54. 00001050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  55. 00001060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  56. 00001070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  57. 00001080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  58. 00001090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  59. 000010a0: 00 00 00 00 00 00 00 00 00 a0 87 00 00 00 00 00 |................|
  60. 000010b0: ff ff ff ff ff ff ff ff 00 00 60 11 05 f8 ff ff |..........`.....|
  61. 000010c0: 00 90 2f 00 00 00 00 00 ff ff ff ff 03 80 ff ff |../.............|
  62. 000010d0: f8 00 00 c0 c1 f7 ff ff 00 00 00 00 03 00 00 00 |................|
  63. 000010e0: f8 00 00 c0 c1 f7 ff ff 00 00 00 00 03 00 00 00 |................|
  64. 000010f0: 00 00 00 00 00 00 00 00 70 37 01 c0 c1 f7 ff ff |........p7......|
  65. ...

Building

You can build it yourself using CMake and it builds on Linux, Windows, OSX with the Microsoft, the LLVM Clang and GNU compilers.

Here is an example on Windows:

  1. > mkdir build
  2. > cd build
  3. > cmake ..
  4. -- Building for: Visual Studio 17 2022
  5. ...
  6. > cmake --build . --config RelWithDebInfo
  7. MSBuild version 17.8.3+195e7f5a3 for .NET Framework
  8. ...
  9. > src\parser\RelWithDebInfo\parser.exe
  10. You didn't provide the path to the dump file.
  11. parser.exe [-p [<physical address>]] [-c] [-e] [-h] <kdump path>
  12. Examples:
  13. Show every structures of the dump:
  14. parser.exe -a full.dmp
  15. Show the context record:
  16. parser.exe -c full.dmp
  17. Show the exception record:
  18. parser.exe -e full.dmp
  19. Show all the physical memory (first 16 bytes of every pages):
  20. parser.exe -p full.dmp
  21. Show the context record as well as the page at physical address 0x1000:
  22. parser.exe -c -p 0x1000 full.dmp

Here is another example on Linux (with the Python bindings):

  1. $ mkdir build
  2. $ cd build
  3. $ cmake .. -DBUILD_PYTHON_BINDING=ON
  4. ...
  5. $ cmake --build . --config RelWithDebInfo
  6. ...
  7. $ ./src/parser/parser
  8. You didn't provide the path to the dump file.
  9. parser.exe [-p [<physical address>]] [-c] [-e] [-h] <kdump path>
  10. Examples:
  11. Show every structures of the dump:
  12. parser.exe -a full.dmp
  13. Show the context record:
  14. parser.exe -c full.dmp
  15. Show the exception record:
  16. parser.exe -e full.dmp
  17. Show all the physical memory (first 16 bytes of every pages):
  18. parser.exe -p full.dmp
  19. Show the context record as well as the page at physical address 0x1000:
  20. parser.exe -c -p 0x1000 full.dmp

Python bindings

From PyPI

The easiest way is simply to:

  1. pip install kdmp_parser

Using PIP

Run the following after installing CMake and Python 3.8+ / pip:

  1. cd src/python
  2. pip install requirements.txt
  3. pip install .

To create a wheel pacakge:

  1. cd src/python
  2. pip wheel .

Usage

Get context, print the program counter

  1. import kdmp_parser
  2. dmp = kdmp_parser.KernelDumpParser("full.dmp")
  3. assert dmp.type == kdmp_parser.DumpType.FullDump
  4. print(f"Dump RIP={dmp.context.Rip:#x}")

Read a virtual memory page at address pointed by RIP

  1. import kdmp_parser
  2. dmp = kdmp_parser.KernelDumpParser("full.dmp")
  3. dmp.read_virtual_page(dmp.context.Rip)

Explore the physical memory

  1. import kdmp_parser
  2. dmp = kdmp_parser.KernelDumpParser("full.dmp")
  3. pml4 = dmp.directory_table_base
  4. print(f"{pml4=:#x}")
  5. dmp.read_physical_page(pml4)

Translate a virtual address into a physical address

  1. import kdmp_parser
  2. dmp = kdmp_parser.KernelDumpParser("full.dmp")
  3. VA = dmp.context.Rip
  4. PA = dmp.translate_virtual(VA)
  5. print(f"{VA=:#x} -> {PA=:#x}")

Authors

Contributors

contributors-img