Giter Site home page Giter Site logo

banshee's Introduction

Banshee

Banshee

Learning about Windows rootkits lately, so here is my own implementation of some techniques. For an overview, see Features below.

Banshee is meant to be used with kdmapper or a similar driver mapper.

I am just learning about kernel driver development, so this is for educational purposes mainly.

A few blogposts on Banshee:

What is a Rootkit?

http://phrack.org/issues/55/5.html

Usage

You can integrate Banshee into your tooling, by including the Banshee.hpp file in your project, e.g.:

Banshee banshee = Banshee();
banshee.Initialize();

int targetPid = GetDefenderPID(); // this would be your implementation
banshee.KillProcess(targetPid);   // instruct banshee to kill the targetprocess

An example implementation of all the features in a command line client is found in ./BansheeClient/BansheeClient.cpp:

Banshee CLI

Features

Get in everyone, we're going to Kernel Land!

Kill processes

ZwTerminateProcess is simply called from kernel land to terminate any process.

Change protection levels

This is done by modifying the EPROCESS structure, which is an kernel object that describes a processes attributes. It also holds a value that specifies the protection level of the process.

We can directly modify this value (aka Direct Kernel Object Modification or DKOM), since we are operating in Ring 0.

Elevate any process token to SYSTEM

EPROCESS also holds a pointer to the current access token, so we can just make it point to e.g. the token of process 4 (SYSTEM) to elevate any process to SYSTEM.

Enumerating and erasing kernel callbacks

For now, only Process- and Thread-Creation kernel callbacks are enumerated, by parsing the PsSetCreateNotifyProcess/ThreadRoutine routine to reach the private Psp* routine and then parsing the address of the array, where kernel callbacks are stored. With erase, callbacks can be erased by overwriting the function pointer to point to an empty function in Banshee instead.

Protecting the driver file

By hooking the NTFS filesystem's IRP_MJ_CREATE handler, we can block any process from opening a handle to our driver file (This will probably change to a filter driver concept soon).

Keylogging from the Kernel

Using the undocumented gafAsyncKeyState function we can parse keystrokes from a session without using any API calls besides reading memory (https://www.unknowncheats.me/forum/c-and-c-/327461-kernel-mode-key-input.html).

Misc

Communication over SharedMemory

Banshee does not communicate over IOCTLs as most drivers do, but rather over shared memory. This way no DriverObject needs to be registered, which would point to our unbacked memory region (if mapped to memory) and would lead anti-rootkit software directly onto us. We can still get clapped with NMI callbacks, but hopefully, a custom mapper I have planned should solve that (WIP).

Patchguard triggering features

These should only be used with a patchguard bypass or in a lab environment as they trigger BSOD.

Hide Process by PID

Again, EPROCESS comes to help here - it contains a LIST_ENTRY of a doubly linked list called ActiveProcessLink which is queried by Windows to enumerate running processes. If we simply unlink an entry here, we can hide our process from tools like Process Monitor or Task Manager. This can cause Bluescreens, e.g. when the process is closed while being hidden or due to patchguard scanning the kernel memory. While the former can be fixed by not being so lazy when programming, the latter can not be as easily bypassed from within the driver.

Testing & debugging the driver

I recommend to enable debugging for the kernel. Run the following from an administrative prompt and reboot afterwards:

bcdedit /debug on

Afterwards load the driver with kdmapper.

You can then run the client, after compiling the solution, with e.g.:

.\x64\Debug\BansheeClient.exe

Run this in a VM, debug this VM with WinDbg and create a snapshot before. You will probably Bluescreen a lot when developing.

TODO

Credits

banshee's People

Contributors

eversinc33 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

banshee's Issues

Communication issue

Hello mate! Nice job!
I tested your project and found some troubles with communication.
Driver create objects:

BeCreateNamedEvent(&commandEvent, &commandEventName, FALSE);
BeCreateNamedEvent(&answerEvent, &answerEventName, FALSE);
BeCreateSharedMemory(&hSharedMemory, &pSharedMemory);

with SYSTEM token integrity.
So Client need to have SYSTEM token for communicate with driver.
Why I can't to use local administrator token for communication?
I think that is possible to make low integrity HANDLEs in Driver.
In user-space if Driver is load, you can open Driver's HANDLE with low integrity token.

Cannot open include file 'ntifs.h'

Hi, thanks for sharing the project, i can manage to compile fine the bansheeclient but i get this error with banshee

Error | C1083 | Cannot open include file: 'ntifs.h': No such file or directory | Banshee | C:\temp\Banshee\Banshee\Driver.cpp | 1 |  

using windows 10 22h2 build 19045.3086
and
Microsoft Visual Studio Community 2022
Version 17.6.3
VisualStudio.17.Release/17.6.3+33801.468
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA404
Microsoft Visual C++ 2022
ASP.NET and Web Tools 17.6.326.62524
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.6.326.62524
Azure App Service Tools v3.0.0
C# Tools 4.6.0-3.23259.8+c3cc1d0ceeab1a65da0217e403851a1e8a30086a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Cookiecutter 17.0.23087.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.
Dotfuscator Community Edition 6.5.3+7f0b0a9d18
PreEmptive Protection - Dotfuscator CE
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
NuGet Package Manager 6.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Python - Profiling support 17.0.23087.1
Profiling support for Python projects.
Python with Pylance 17.0.23087.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.
Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
TypeScript Tools 17.0.20329.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.6.0-3.23259.8+c3cc1d0ceeab1a65da0217e403851a1e8a30086a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.6.0-beta.23174.5+0207bea1afae48d9351ac26fb51afc8260de0a97
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

any ideas ? i do something wrong ?
thanks

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.