Giter Site home page Giter Site logo

axactt / callstack-spoofer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from barracudach/callstack-spoofer

0.0 0.0 0.0 167 KB

This tool will allow you to spoof the return addresses of your functions as well as system functions.

License: Apache License 2.0

C++ 100.00%

callstack-spoofer's Introduction

CallStack-Spoofer

A simple tool that will make it harder to find your code by stackwalker or other stack analyze.
This works both in the kernel-mode and in the user-mode.
Safe with runtime exceptions.

PoC

example in user-mode

SPOOF_FUNC;//spoof current function
SPOOF_CALL(Beep)(500, 500);//spoof system call

example in kernel-mode

SPOOF_FUNC;//spoof current function
SPOOF_CALL(NTSTATUS,NtClose)(handle);//spoof system call

call by pointer

BOOL (WINAPI * beep)(_In_ DWORD dwFreq,_In_ DWORD dwDuration)=&Beep;
SPOOF_CALL(beep)(500,500);

presetting

  • For kernel- disable Control Flow Guard (CFG) (/guard:cf in msvc)
  • Developed for the x64 platform.
  • Requires changes for x32.

c++ standart

  • Usermode c++17 and above
  • Kernelmode c++14 and above

PoC

Call stack with spoofer disabled Call stack with spoofer enabled

There are 2 modes of operation:

  1. Erase the return address of the current function and restore it when the destructor is called during the return of the function. Since we are using a class with a local scope, we will call the destructor anyway. This also works with exceptions.
  2. Generate a shellcode that will proxy our system calls, as a result of which the return address will not point to our code.

While the first case is simple, the second case is a bit more complicated. What should we know? The function template generates a function at compile time with certain parameters that we call it with in the code. Subsequent calls will use the already generated function. Therefore, we can get the address of the generated function like this:

PVOID self_addr = static_cast<PVOID>(&ShellCodeGenerator<RetType, Func*, Args&&...>);

With each subsequent same call, the address will match. Therefore, we can cache our matched shellcode and template function address pairs so that we only allocate the shellcode once and then use it. For backwards compatibility with the kernel, no standard containers are used.

It is important to understand that no function calls should be used in the shellcode, except for calls via direct addresses, because the calls use nearcall, and we will get an invalid relative call. We also encrypt our return address with xor , because it will still be stored on the stack.

It was written in a hurry, so there are flaws here.

callstack-spoofer's People

Contributors

barracudach avatar

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.