GithubHelp home page GithubHelp logo

anthrax3 / elusivemice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mgeeky/elusivemice

0.0 1.0 0.0 77 KB

Cobalt Strike User-Defined Reflective Loader with AV/EDR Evasion in mind

Batchfile 1.85% C 98.15%

elusivemice's Introduction

ElusiveMice - custom Cobalt Strike User-Defined Reflective Loader

This is a fork of Cobalt Strike's User-Defined Reflective Loader which in turn is a fork of Stephen Fewer's ReflectiveDLLInjection implementation, but with a slight plot twist - it adds a few well-known AV/EDR evasion hooks/patches!

Whenever we issue execute-assembly or perform any other Cobalt-Strike native action that injects capability into a sacrificial process, the Cobalt Strike will utilize its Reflective Loader to inject DLL into a remote process, instantiate it and execute our action. The thing is though, that sometimes we might come across EDR triggering alerts not during the mere process-injection but afterwards, as soon as the injected .NET assembly or our keylogger/screenshot capability invokes monitored API, or issues unsafe script.

We can attempt to combat these detections by pre-pending our injected capabilities with some preliminary hot-patches.

At the end of the day, we Red Teamers are getting paid for raising the bar, aren't we? :)

Features

  • Avoids use of RWX pages wherever possible, sticks to RX+RW instead. Also, sets per-section permissions
  • Wipes own PE Headers and most of the ReflectiveLoader's function code by zeroing them out.
  • AMSI Bypass through amsi!AmsiScanBuffer one-byte memory patch incrementing 'AMSI' constant in assembly
  • ETW Bypass through ntdll!EtwEventWrite memory patch (return 0 technique)
  • (Temporarily not used) WLDP Bypass through wdlp!WldpQueryDynamicCodeTrust memory patch
  • utilizes changed API/module name dynamic resolution hashes to avoid simple signature detections

Usage

  1. Load rdll_loader.cna script into Cobalt Strike
  2. Generate your beacon via Attacks -> Packages -> Windows Executable (S) or any other sort of Beacon's shellcode.
  3. (Optionally) observe output in View -> Script Console

The CNA script may have $debug mode enabled by flipping the variable:

# Enable Debug of PE content
# The generated PE content will be displayed in the script console if debug is true

#$debug = "true";
$debug = "false";

Which will dump PE headers of newly generated Reflective DLL containing Beacon's codebase.

TODO

Most of these features are going to be possible to be added when Cobalt Strike increase it's bytes limit for UDRLs (that's currently 5KB)...

  • Refactoring dumb memory patches into more subtle hooked implementations of routine wrappers for AmsiScanBuffer or EtwEventWrite
  • Implement ETW unregistration instead of brutal memory patching.
  • Introduce typical anti-emulation/anti-sandboxing guardrails - delaying execution, validating safe environments (am I, the ReflectiveLoader, running inside of an emulator?)
  • Add Raphael's unhook-bof implementation to Reflective Loader
  • Add memory scanning routine eliminating dangling allocations with previous Cobalt Strike stagers
  • Hook Sleep to introduce Heap encryption

Known Issues

  • x86 Reflective Loader does not work at the moment! (that's why it is not available in this repository)

Other work

So far there aren't many publicly available implementations of User-Defined Reflective Loaders, but the ones of a great quality that I'm aware of include:

  • boku7's CobaltStrikeReflectiveLoader - reimplemting the idea in pure inline Assembly, thwarting naive static signatures (and oh, it too comes with AMSI and ETW patches!)
  • SecIdiot TitanLdr - Reflective Loader written in C and assembly for Cobalt Strike. Redirects DNS Beacon over DoH

Author

   Mariusz B. / mgeeky, 21
   <mb [at] binary-offensive.com>
   (https://github.com/mgeeky)

elusivemice's People

Contributors

mgeeky avatar

Watchers

 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.