• Stars
    star
    410
  • Rank 105,468 (Top 3 %)
  • Language
    C++
  • Created over 1 year ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimental Windows x64 Kernel Rootkit.

Banshee

Banshee

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

This is not ready to use as the code is bad and I am just learning about kernel driver development, so this is for educational purposes mainly.

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.Install(driverPath);
banshee.Initialize();

int targetPid = GetDefenderPID();    // this would be your implementation
banshee.IoCtlKillProcess(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.

Testing & debugging the driver

You need to enable testsigning to load the driver. I also recommend to enable debugging for the kernel.

Run the following from an administrative prompt and reboot afterwards:

bcdedit /set testsigning on
bcdedit /debug on

Afterwards you can run the client, after compiling the solution, with e.g.:

.\x64\Debug\BansheeClient.exe C:\Users\eversinc33\source\repos\Banshee\x64\Debug\Banshee.sys

Run this in a VM and create a snapshot. You will probably Bluescreen a lot when developing and can corrupt your system. Be warned.

Features

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

Kill any process by PID

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

"Bury" a Process

Terminating processes, but they come back alive? Bury a process to avoid it to restart by setting a kernel callback to process creation.

If the target process is created, Banshee will set the CreationStatus of the target process to STATUS_ACCESS_DENIED.

The match is case insensitive on a substring - e.g. to block defender, run bury with defender, then kill <defender pid> and it won't come back anymore, since all process creation events with defender in the image full path will be blocked.

For this feature, INTEGRITYCHECK has to be specified when linking (https://learn.microsoft.com/en-us/cpp/build/reference/integritycheck-require-signature-check?view=msvc-170).

Change protection level of any process by PID

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

On my machine, that value can be found at offset 0x87a. Since that offset is dynamic, we can dynamically parse it from PspIsProtectedProcessLight instead of hardcoding it (thanks @never_unsealed for the trick):

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

The values for the different protection levels can be found e.g. in Windows Internals Part 1 (page 115 in the 7th edition (english)).

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.

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.

Enumerating 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. This is WIP code.

TODO

Credits

More Repositories

1

BouncyGate

Indirect Syscalls: HellsGate in Nim, but making sure that all syscalls go through NTDLL (as in RecycledGate).
Nim
176
star
2

unKover

PoC Anti-Rootkit to uncover Windows Drivers/Rootkits mapped to Kernel Memory.
C++
106
star
3

Red-Team-Advent-of-Code

Red Teaming / Pentesting challenges for my Advent-Of-Code 2021.
Nim
99
star
4

GpuDecryptShellcode

XOR decrypting shellcode using the GPU with OpenCL.
C++
82
star
5

MalwareAdventurez

My adventures in learning about different userland malware techniques, such as syscalls, injection, unhooking or sandbox evasion.
C++
67
star
6

Invoke-Pre2kSpray

Enumerate domain machine accounts and perform pre2k password spraying.
PowerShell
61
star
7

SharpStartWebclient

Programmatically start WebClient from an unprivileged session to enable that juicy privesc.
C#
60
star
8

Godmode

Tool for playing with Windows Access Token manipulation.
C
51
star
9

CredGuess

Generate password spraying lists based on the pwdLastSet-attribute of users.
Python
49
star
10

1.6-C2

Using the Counter Strike 1.6 RCON protocol as a C2 Channel.
C++
49
star
11

Papaya

NoSQL Injection Tool to bypass login forms & extract usernames/passwords using regular expressions.
Python
30
star
12

NimNightmare

CVE-2021-1675 LPE PoC in Nim (PrintNightmare Local Privilege Escalation)
Nim
20
star
13

deepsea

Deepsearch leak database client, as an alternative for pwndb
Python
15
star
14

Talks

Repository for slide decks of public talks I've given.
14
star
15

OffensiveHolyC

Red-Teaming TempleOS.
HolyC
13
star
16

crystalc2

My attempt at a C2 framework and post-exploitation agent.
C#
11
star
17

JailWhale

Docker container escape enumeration tool.
Shell
8
star
18

Web-Windows-Login-Phishing

Web based fake Windows Login Screen Phishing.
HTML
8
star
19

urlExtract

Recursively extract urls from a web page for reconnaissance.
Go
8
star
20

scim

WIP raw socket packet manipulation library
Nim
6
star
21

lunarfuzz

WIP: Directory fuzzer for single page apps that require a browser to render content, with an interface similar to ffuf
Go
6
star
22

nim-monero-rpc

Nim library for interacting with Monero wallets & nodes via RPC.
Nim
5
star
23

Black-Metal-Lyric-Database

Database of Black Metal lyrics and additional metadata in .JSON-format for computer assisted text analysis projects.
Python
5
star
24

QuickShell

Generates quick one liner reverse shell payloads for lazy people.
Shell
4
star
25

YA-PSX-EMU

Playstation (PSX) Emulator (WIP).
C++
3
star
26

UwuRatel

Pink BRC4 skin/theme.
3
star
27

Malware_Analysis_Scripts

Scripts used for malware analysis / reversing.
Python
2
star
28

ghidra-WDF-gdt

Ghidra .gdt files for parts of the Kernel Mode Driver Framework (KMDF) part of WDF
C
2
star
29

OpenGL-Voxel-Engine

Voxel Game-Engine using OpenGL, created as a project to practice C++ and graphics programming.
C
2
star
30

CrystalCastle

Your automated network enumeration watchtower.
Ruby
2
star
31

PSX-DEV

PSX homebrew development stuff.
C
1
star
32

eversinc33.github.io

HTML
1
star
33

PyCheeseOunce

Another coercion method, using MS-EVEN ElfrOpenBELW.
Python
1
star