GithubHelp home page GithubHelp logo

swwwolf / wdbgark Goto Github PK

View Code? Open in Web Editor NEW
602.0 61.0 176.0 3.01 MB

WinDBG Anti-RootKit Extension

Home Page: https://sww-it.ru

License: Other

C++ 66.42% C 3.17% CMake 0.21% Batchfile 0.15% Python 0.18% PowerShell 0.02% Makefile 0.02% HTML 27.70% CSS 0.90% JavaScript 1.21%
kernel-mode c-plus-plus malware malware-analysis malware-research forensic-analysis windbg windbg-extension anti-rootkit windows

wdbgark's Introduction

WinDBG Anti-RootKit extension

Coverity Scan Build Status Build status License: GPL v3

Preface

WDBGARK is an extension (dynamic library) for the Microsoft Debugging Tools for Windows. It main purpose is to view and analyze anomalies in Windows kernel using kernel debugger. It is possible to view various system callbacks, system tables, object types and so on. For more user-friendly view extension uses DML. For the most of commands kernel-mode connection is required. Feel free to use extension with live kernel-mode debugging or with kernel-mode crash dump analysis (some commands will not work). Public symbols are required, so use them, force to reload them, ignore checksum problems, prepare them before analysis and you'll be happy.

Requirements

  • Microsoft Visual Studio 2017
  • WDK and SDK for Windows 10, version 1709 (10.0.16299.0)
  • Visual C++ Redistributable for Visual Studio 2017

Supported commands

Supported targets

  • Microsoft Windows XP (x86)
  • Microsoft Windows 2003 (x86/x64)
  • Microsoft Windows Vista (x86/x64)
  • Microsoft Windows 7 (x86/x64)
  • Microsoft Windows 8.x (x86/x64)
  • Microsoft Windows 10 (x86/x64)

Multiple targets debugging is not supported!

Windows BETA/RC is supported by design, but read a few notes. First, i don't care about checked builds. Second, i don't care if you don't have symbols (public or private). IA64/ARM is unsupported (and will not).

Sources and build

Sources are organized as a Visual Studio 2017 solution.

Build using VS2017

  • Download and install latest WDK
  • Select Build -> Batch Build from the menu and build dummypdb module (x86 and x64). Batch Build
  • Choose solution configuration and platform for the main project.
  • Build.

NOTE!

Post-build event is enabled for debug build. It automatically copies linked extension into WinDBG's plugins folder (e.g. x64 target:
"copy /B /Y "$(OutDir)$(TargetName)$(TargetExt)" "$(WindowsSdkDir)Debuggers\x64\winext\$(TargetName)$(TargetExt)").

Build using BUILD

Deprecated.

Build using CMD

Yeah, it's possible to build all the stuff using simple batch script.

  • Make sure that you have already installed PowerShell at least version 3.0.
  • Execute the release_build.cmd with a single parameter - a version.
  • Voila! If there were no errors, the archive file will be created (e.g. wdbgark.X.Y.zip).
    • If something is wrong, check the path to the Visual Studio 2017 in the script and/or output log file (release_build.log).

Using

  • Download and install Debugging Tools.
  • Build or download the extention.
  • Make sure that Visual C++ Redistributable for Visual Studio 2017 has already been installed.
  • Copy extension to the WDK debugger's directory (e.g. WDK 10):
    • x64: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\
    • x86: C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\winext\
  • Start WinDBG.
  • Setup WinDBG to use Microsoft Symbol Server correctly or deal with them manually.
  • Load extension by .load wdbgark (you can see loaded extensions with a .chain command).
  • Execute !wdbgark.help for help or !wdbgark.wa_scan for a full system scan.
  • Have fun!
0: kd> .load wdbgark
0: kd> .chain
Extension DLL search Path:
<...>
Extension DLL chain:
    wdbgark: image 2.5.0.0, API 2.5.0, built Fri Oct 20 17:54:03 2017
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\wdbgark.dll]
    dbghelp: image 10.0.16299.15, API 10.0.6, 
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll]
    ext: image 10.0.16299.15, API 1.0.0, 
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\ext.dll]
    exts: image 10.0.16299.15, API 1.0.0, 
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP\exts.dll]
    kext: image 10.0.16299.15, API 1.0.0, 
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\kext.dll]
    kdexts: image 10.0.16299.15, API 1.0.0, 
        [path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP\kdexts.dll]
0: kd> !wdbgark.help
Commands for C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\wdbgark.dll:
  !help               - Displays information on available extension commands
  !wa_apiset          - Output user-mode and/or kernel-mode ApiSet map
  !wa_callouts        - Output kernel-mode win32k callouts
  !wa_checkmsr        - Output system MSRs (live debug only!)
  !wa_chknirvana      - Checks processes for Hooking Nirvana instrumentation
  !wa_cicallbacks     - Output kernel-mode nt!g_CiCallbacks or nt!SeCiCallbacks
  !wa_ciinfo          - Output Code Integrity information
  !wa_colorize        - Adjust WinDBG colors dynamically (prints info with no
                        parameters)
  !wa_crashdmpcall    - Output kernel-mode nt!CrashdmpCallTable
  !wa_drvmajor        - Output driver(s) major table
  !wa_eop             - Checks processes for Elevation of Privilege
  !wa_gdt             - Output processors GDT
  !wa_haltables       - Output kernel-mode HAL tables: nt!HalDispatchTable,
                        nt!HalPrivateDispatchTable, nt!HalIommuDispatchTable
  !wa_idt             - Output processors IDT
  !wa_lxsdt           - Output the Linux Subsystem Service Descriptor Table
  !wa_objtype         - Output kernel-mode object type(s)
  !wa_objtypecb       - Output kernel-mode callbacks registered with
                        ObRegisterCallbacks
  !wa_objtypeidx      - Output kernel-mode nt!ObTypeIndexTable
  !wa_pnptable        - Output kernel-mode nt!PlugPlayHandlerTable
  !wa_process_anomaly - Checks processes for various anomalies
  !wa_psppico         - Output kernel-mode Pico tables
  !wa_scan            - Scan system (execute all commands)
  !wa_ssdt            - Output the System Service Descriptor Table
  !wa_systables       - Output various kernel-mode system tables
  !wa_systemcb        - Output kernel-mode registered callback(s)
  !wa_ver             - Shows extension version number
  !wa_w32psdt         - Output the Win32k Service Descriptor Table
  !wa_w32psdtflt      - Output the Win32k Service Descriptor Table Filter
  !wdrce_copyfile     - Copy file (live debug only!)
  !wdrce_cpuid        - Execute CPUID instruction (live debug only!)
!help <cmd> will give more information for a particular command

FAQ

Q: What is the main purpose of the extension?
A: Well, first is educational only. Second, for fun and profit.

Q: Do you know about PyKd? I can script the whole Anti-Rootkit using Python.
A: Yeah, i know, but C++ is much better.

Q: Where is version 1.0?
A: Lost in space of Google Code.

Q: When did the project start?
A: February 2013 on Google Code.

Q: What version should i use?
A: Please use x64 version only. In the era of x64 i dunno why the heck you may need to use x86 version. x64 WinDBG is able to debug both x86 and x64. Host OS bitness is the only limitation.

Q: How can i help?
A: Spread a word. Report issues and feature requests. I'm open for any suggestions. Thanks!

Q: What kind of memory dump is better to use with an extension?
A: Complete memory dump.

Q: How to report an issue?
A: Feel free to report an issue using GitHub or email to me directly, but please, attach complete memory crash dump file.

Help

Wiki can help.

Used code

Whoami

License

This software is released under the GNU GPL v3 License. See the COPYING file for the full license text and this small addition.

wdbgark's People

Contributors

sckelemen avatar swwwolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wdbgark's Issues

FsRtlRegisterFileSystemFilterCallbacks and more

Add various callbacks.

First of all is FsRtlRegisterFileSystemFilterCallbacks.

kd> dt nt!_DRIVER_EXTENSION 0x8a7eca00
+0x000 DriverObject : 0x8a7ec958 _DRIVER_OBJECT
...
+0x018 FsFilterCallbacks : (null)
+0x01c KseCallbacks : (null)
+0x020 DvCallbacks : (null)

Research ExRegisterExtension

Reasearch ExRegisterExtension. It's a list ExpHostList.

{
0x0 _LIST_ENTRY ListEntry;
...
0x1c PVOID SomeRoutine;
...
0x2C PVOID TableOfRoutines;
}

kd> dd ExpHostList
819f7ee8 8340abe0 84f978f0 935c3608 8de3b040
819f7ef8 00000000 00000000 00000007 00000000
819f7f08 00000000 00000000 00000000 00000000
819f7f18 00000000 00000000 00000001 00000000
819f7f28 00000000 00040001 00000000 819f7f34
819f7f38 819f7f34 00000000 00000001 00000000
819f7f48 00000000 00000000 00000000 00000000
819f7f58 00000000 00000000 00000113 81a1d300

kd> dd 8340abe0+1c
8340abfc 81b3a105 00000000 00000000 00000000
8340ac0c 82ff7070 0a04020e 6e54624f 06030208
8340ac1c 6944624f 8340ac60 84f81ec0 1f8c7605
8340ac2c 00001000 06050203 6d4e624f 00700054
8340ac3c 006f0057 006b0072 00720065 00610046
8340ac4c 00740063 0072006f 00000079 06030205
8340ac5c 6944624f 83407f18 84f6ef70 5cf4b14f
8340ac6c 000f0000 06060203 6d4e624f 006f0043

kd> ln 81b3a105
(81b3a105) nt!ExpPcwHostCallback | (81b3b2c7) nt!PcwRegister
Exact matches:
nt!ExpPcwHostCallback ()

kd> dd 8340abe0+2c
8340ac0c 82ff7070 0a04020e 6e54624f 06030208
8340ac1c 6944624f 8340ac60 84f81ec0 1f8c7605
8340ac2c 00001000 06050203 6d4e624f 00700054
8340ac3c 006f0057 006b0072 00720065 00610046
8340ac4c 00740063 0072006f 00000079 06030205
8340ac5c 6944624f 83407f18 84f6ef70 5cf4b14f
8340ac6c 000f0000 06060203 6d4e624f 006f0043
8340ac7c 0070006d 0073006f 00740069 006f0069

kd> dps 82ff7070
82ff7070 82ff4678 pcw!PcwRegister
82ff7074 82ff46e0 pcw!PcwUnregister
82ff7078 82ff46f8 pcw!PcwCreateInstance
82ff707c 82ff475c pcw!PcwCloseInstance
82ff7080 82ff4772 pcw!PcwAddInstance
...

Add more callbacks #1

KdRegisterPowerHandler (+)
HalDispatchTable (+)
HalPrivateDispatchTable (+)
DbgkLkmdRegisterCallback (WINDOWS 7+) (+)
IoRegisterIoTracking (IopPerfIoTrackingListHead) (+)
EmpCallbackListHead(+)
CrashdmpCallTable (+)
ObRegisterCallbacks (+)

build error

1>------ Build started: Project: dummypdb, Configuration: Release x64 ------
1> Building 'dummypdb' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform.
1> Generating code
1> Finished generating code
1> dummypdb.vcxproj -> C:\Users\Administrator\Documents\GitHub\wdbgark\dummypdb_build\x64\Release\dummypdb_x64.sys
1> dummypdb.vcxproj -> C:\Users\Administrator\Documents\GitHub\wdbgark\dummypdb_build\x64\Release\dummypdb_x64.pdb (Full PDB)
1>SIGNTASK : SignTool error : No certificates were found that met all the given criteria.
2>------ Build started: Project: wdbgark, Configuration: Debug x64 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error MSB8036: The Windows SDK version 10.0.15063.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

How to solve it?:)

ide : vs2015 up3

Write good Wiki

Add real world malware examples. Various scenarios and so on.

!wa_objtypecb fails

kd> !wa_objtypecb
[+] Displaying callbacks registered with ObRegisterCallbacks with type *
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|           Address|                                                                Name|                                                              Symbol|                    Module|Suspicious|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|0xfffffa80018d6d60|                                                             Process|                                                                    |                          |          |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
ERROR: !wa_objtypecb: extension exception 0x80004005.
    "Unable to get type ID of 'dummypdb_1888!_OBJECT_CALLBACK_ENTRY_COMMON'"
kd> vertarget
Windows 7 Kernel Version 7601 (Service Pack 1) MP (1 procs) Free x64

Running WinDbg:10.0.14321.1024 AMD64 on Windows 7 x64.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.