Giter Site home page Giter Site logo

m0chae1 / csharp-alt-shellcode-callbacks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wsummerhill/csharp-alt-shellcode-callbacks

0.0 0.0 0.0 83 KB

A collection of (even more) alternative shellcode callback methods in CSharp

C++ 25.72% C 6.14% C# 68.14%

csharp-alt-shellcode-callbacks's Introduction

CSharp Alternative Shellcode Callbacks

Alternative shellcode execution techniques using Windows callback functions

Each CSharp file contains code to execute shellcode using native Windows callbacks. I tried to use much less common callback techniques that weren't typically documented online as far as I could tell. This way they should be more evasive.

NOTE: The shellcode samples used in every C# file will execute Windows 64-bit Calculator.exe
NOTE 2: I've also included the C/C++ code samples from VX-Underground which some of these were based off of

The C# malware samples contain the following execution flows:

  • Base64 decode 64-bit shellcode
  • XOR decrypt shellcode
  • Allocate memory with VirtualAlloc()
  • Copy shellcode to memory with Marshal.Copy()
  • Execute shellcode with callback function

For each code sample, any decrypting/decoding routines could be changed to fit your needs. Also, use D/Invoke, obfuscation, junk code, etc!

It's also possible to replace the some functions in the code with alternatives such as:

  • Use RtlMoveMemory() instead of Marshal.Copy()
  • WriteProcessMemory() instead of Marshal.Copy()
  • Use the managed function Marshal.AllocHGlobal() to allocate space instead of VirtualAlloc()

Compiling intructions with csc.exe:

// Compile EXE
csc.exe /target:exe /out:TestExecutable.exe CSharp-Callback_[FILENAME].cs

// Compile DLL
csc.exe /target:library /out:TestLibrary.dll CSharp-Callback_[FILENAME].cs

Enjoy the CSharp samples and good luck! Please povide any feedback if you'd like additional callback functions to be implemented.

Blog post: https://wsummerhill.github.io/malware/2022/12/09/CSharp-Alt-Shellcode-Callbacks.html


Reference

Thanks to DamonMohammadbagher/NativePayload_CBT for the inspiration.
Thanks to VX Underground for the Windows malware templates in C.

csharp-alt-shellcode-callbacks's People

Contributors

wsummerhill 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.