Need help with BOF.NET?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

166 Stars 17 Forks 19 Commits 0 Opened issues


A .NET Runtime for Cobalt Strike's Beacon Object Files

Services available


Need anything else?

Contributors list

# 137,058
19 commits

BOF.NET - A .NET Runtime for Cobalt Strike's Beacon Object Files


BOF.NET is a small native BOF object combined with the BOF.NET managed runtime that enables the development of Cobalt Strike BOFs directly in .NET. BOF.NET removes the complexity of native compilation along with the headaches of manually importing native API. Testing BOF.NET assemblies is also generally much easier, since the .NET assemblies can be debugged using a traditional managed debugger.

Getting started

Implementing you first BOF.NET class is simple. Add a reference to the BOF.NET runtime DLL from the dist folder and create a class that inherits from

. A mandatory constructor with a
object as the only parameter is needed. This should be passed along to the
base constructor.

Finally override the

function. Arguments will be pre-processed for you exactly how a
function behaves inside a normal .NET assembly.
namespace BOFNET.Bofs {
    public class HelloWorld : BeaconObject {
        public HelloWorld(BeaconApi api) : base(api) { }
        public override void Go(string[] args) {
            BeaconConsole.WriteLine($"[+] Welcome to BOF.NET { (args.Length > 0 ? args[0] : "anonymous" )}");

Once you have compiled your BOF.NET assembly, you can load the bofnet.cna aggresor script from the dist folder into Cobalt Strike and being using your BOF.NET class.

Before any BOF.NET class can be used, the BOF.NET runtime needs to be initialised within the beacon instance.


Once the runtime has loaded, you can proceed to load further .NET assemblies including other BOF.NET classes. BOF.NET now chunks the loading of Assemblies, therefore large assemblies can also be loaded (1M+)

bofnet_load /path/to/bofnet/HelloWorld.dll

You can confirm the library has been loaded using the

alias. A complete list of classes that implmements
can be shows by executing the

Finally, once you have confirmed your assembly is loaded and the BOF.NET class is available you can execute it

bofnet_execute BOFNET.Bofs.HelloWorld @_EthicalChaos_

You can also use the shorthand method of just the class name, but this will only work if there is only one BOF.NET class present with that name.

bofnet_execute HelloWorld @_EthicalChaos_

Beacon Command Reference

| Command | Description | |----------------------------------------|--------------------------------------------------------------------------| | bofnetinit | Initialises the BOF.NET runtime inside the beacon process | | bofnetlist | List's all executable BOF.NET classes | | bofnetlistassembiles | List assemblies currently loaded into the BOF.NET runtime | | bofnetexecute bof_name [args] | Execute a BOF.NET class, supplying optional arguments | | bofnetload *assemblypath* | Load an additional .NET assembly from memory into the BOF.NET runtime. | | bofnetshutdown | Shutdown the BOF.NET runtime | | bofnetjob bof_name [args] | Execute a BOF.NET class as a background job (thread) | | bofnetjobs | List all currently active BOF.NET jobs | | bofnetjobstatus job_id | Dump any pending console buffer from the background job | | bofnetjobkill *jobid* | Dump any pending console buffer from the background job then kill it. Warning, can cause deadlocks when terminating a thread that have transitioned into native code | | bofnet_boo | Compile and execute Boo script in seperate temporary AppDomain |


Depending on the target operating system will depend on which distribution should be used (net35/net40). The runtime will attempt to create a .NET v4 CLR using the

function that was made available as part of .NET v4. If the function cannot be found, the older mechanism is used to initialise .NET v2. Currently the native component cannot determine which managed runtime to load dynamically, so make sure you use the correct distribution folder. A fully up to date Windows 7 will generally have .NET 4 installed, so on most occasions you will need the net40 folder from inside the dist folder. Older operating systems like XP will depend on what is installed.

BOF.NET will follow the same restrictions as it's native BOF counterpart. Execution of a BOF.NET class internally uses the

functionality. Therefore, any BOF.NET invocations will block beacon until it finishes.

BOF.NET does have the added benefit that loaded assemblies remain persistent. This facilitates the use of threads within your BOF.NET class without the worry of the assembly being unloaded after the

function finishes. But you cannot write to the beacon console or use any other beacon BOF API's since these are long gone and released by Cobalt Strike after the BOF returns.

If you want to execute your BOF.NET class as a background job using a thread, use the

command. This wraps the invocation in a separate thread and handles
writes transparently for you. Be careful with long running jobs and lots of console output, since the console buffer will cached until a call to
is invoked.

How BOF.NET Works?

BOF.NET contains a small native BOF that acts as a bridge into the managed world. When

is called, this will start the managed CLR runtime within the process that beacon is running from. Once the CLR is started, a separate .NET AppDomain is created to host all assemblies loaded by BOF.NET. Following on from this, the BOF.NET runtime assembly is loaded into the AppDomain from memory to facilitate the remaining features of BOF.NET. No .NET assemblies are loaded from disk.

All future BOF.NET calls from here on out are typically handled by the

method from the
class. This keeps the native BOF code small and concise and pushes all runtime logic into the managed BOF.NET runtime.


BOF.NET uses the CMake build system along with MinGW GCC compiler for generating BOF files and uses msbuild for building the managed runtime. So prior to building, all these prerequisites need to be satisfied and available on the PATH.

From the checkout directory, issue the following commands

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -G "MinGW Makefiles" ..
cmake --build .
cmake --install .

Once the steps are complete, the

folder should contain the artifacts of the build and should be ready to use within Cobalt Strike


  • - CLR creation using native raw COM interfaces
  • - Great trick for declaring BOF imports

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.