Giter VIP home page Giter VIP logo

colinsenner / kworld Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 25.6 MB

KWorld is a kernel driver for removing the anti-debugging technique ThreadHideFromDebugger from processes.

Home Page: https://www.colinsenner.com/blog

License: MIT License

C++ 29.25% Batchfile 5.29% C 2.00% C# 60.19% PowerShell 3.27%
anti-debug anti-debugging debugging ntsetinformationthread reverse-engineering x64dbg

kworld's Introduction

KWorld

KWorld is a kernel driver for removing the anti-debugging technique ThreadHideFromDebugger from processes.

Demo.mp4

More reverse engineering at https://www.colinsenner.com/blog.

Tested on

  • Windows 11 Pro, 64-bit (Build 22631.3155) 10.0.22631 (Fully-patched 2/19/2024)
  • VMWare Workstation 17 Pro (17.5.0 build-22583795)

How it works

ThreadHideFromDebugger is a technique used by malware to hide from debuggers. It works by calling NtSetInformationThread with an undocumented argument ThreadHideFromDebugger (0x11) information class. This causes the thread to be hidden from debuggers. This makes the process crash immediately because the debugger is unable to handle the exception.

KWorld goes through all threads in the process and removes the ThreadHideFromDebugger flag from each thread. This allows the process to be debugged without crashing.

Usage

KWorld comes with the following projects

  • KmdWorld - Kernel driver (C)
  • KThreadUnhide - User-mode application (C# WPF .NET 8.0)
  • KThreadUnhideCLI - Console user-mode application (C++)
  • NoBreakpointsAllowed - Test application (C++)

You can run NoBreakpointsAllowed.exe and attempt to attach a debugger to it (It calls Kernel32!Sleep once per second). Then run .\KThreadUnhideCLI.exe <pid> and attempt to attach a debugger to NoBreakpointsAllowed.exe again. You will see that the process does not crash and you can debug it.

You can run DebugView from SysInternals to see the all debug output from the KmdWorld driver.

Detailed explanation

Since offsets in the _ETHREAD and _EPROCESS structures can differ between Windows versions, I lookup the offsets once at runtime. We need to find the offset of the ThreadHideFromDebugger flag in the _ETHREAD structure. I do this by finding the function PsIsThreadTerminating in ntoskrnl.exe. The first instruction of this function is

PsIsThreadTerminating

Where 560h is the offset of the CrossThreadFlags in the _ETHREAD structure. Bit 3 of CrossThreadFlags is the HideFromDebugger flag.

CrossThreadFlags

Setup instructions for VMWare

VMWare Setup for Kernel Debugging

WinDBG command reference

WinDBG command reference

kworld's People

Contributors

colinsenner avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

kworld's Issues

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.