GithubHelp home page GithubHelp logo

gavz / gpusleep Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oxis/gpusleep

0.0 0.0 0.0 164 KB

Move CS beacon to GPU memory when sleeping

License: GNU General Public License v3.0

C++ 64.16% C 35.84%

gpusleep's Introduction

Blog post

Tested on Windows 21H1, Visual Studio 2019 (v142) and an NVIDIA GTX860M.

GPUSleep

GPUSleep moves the beacon image to GPU memory before the beacon sleeps, and move it back to main memory after sleeping.

The idea is to hook HeapAlloc and Sleep. Encrypt (XOR) the heap allocated by the beacon and move all PE sections + heap segments to GPU memory using nvcuda.dll imports.

Comes with a pre-compiled libMinHook.x64.lib, you night want to compile your own.

HeapEncrypt

Using the technique described by waldo-irc, heap segments allocated by the beacon are XOR encrypted before moving them to GPU memory.

Cobalt Strike beacon uses malloc instead of HeapAlloc or RtlHeapAlloc. So the functions that are doing the actual allocation are inside msvcrt.dll or ucrtbase.dll (I didn't really looked into it...)
The line if (!strcmp(lpBaseName, "msvcrt.dll") || !strcmp(lpBaseName, "ucrtbase.dll")) filters which allocations are going to be encrypted.

BasicDLL

A basic test DLL is provided. Modify code to use.

	printf("LoadingBeacon\n");
	//dll = LoadLibraryA("beacon.dll");

	//Test DLL
	run1(heapMap);

Cobalt Strike

GPUSleep will load an unstaged beacon.dll file with LoadLibraryA. The code has not been tested with reflective loading or other in memory loading techniques but if HMODULE dll points to a valid PE image everything should work.

Bugs

Pretty sure it's full of bugs... Like, you need to refresh cuda context every time HookedSleep is called and I don't know why...

void HookedSleep(DWORD dwMilliseconds) {

	std::cout << "Hooked Sleep!\n";
	// so Context cannot be init before CS beacon is fired up, I dunno why... If init before, cuda returns error 201
	Context = initCuda(&Api, &Context);
    [...]

Credit

Big thanks to @smelly__vx, it's actually his code that gave me the idea.

References

LockdExeDemo by @waldo-irc
GpuMemoryAbuse.cpp by @smelly__vx
minihook by @TsudaKageyu

gpusleep's People

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.