BOF / COFF

Beacon Object Files / Common Object File Format

Argument types for bof_pack:

Type

Description

Unpack With (C)

b

binary data

BeaconDataExtract

i

4-byte integer

BeaconDataInt

s

2-byte short integer

BeaconDataShort

z

zero-terminated+encoded string

BeaconDataExtract

Z

zero-terminated wide-char string

(wchar_t *)BeaconDataExtract

A basic BOF example:

msgbox.c
// curl -sS https://download.cobaltstrike.com/downloads/beacon.h -o beacon.h
// x86_64-w64-mingw32-gcc -c msgbox.c -o msgbox.o

#include <windows.h>
#include "beacon.h"

void go(char* args, int alen)
{
    DECLSPEC_IMPORT INT WINAPI USER32$MessageBoxA(HWND, LPCSTR, LPCSTR, UINT);

    datap parser;
    BeaconDataParse(&parser, args, alen);

    char* message;
    message = BeaconDataExtract(&parser, NULL);

    USER32$MessageBoxA(NULL, message, "Hello from BOF!", 0);
}

Run BOFs outside of C2

RunOF

An example of running the nanodump.x64.o BOF via RunOF fork from memory:

  • Compile RunOF.exe assembly and convert it to a PowerShell invoker (see .NET Reflective Assembly)

  • Search for argument types that the target BOF uses (usually located in accompanying Aggressor scripts):

  • Load the invoker into memory, fetch the BOF (-u option) and run it providing necessary arguments with their types like this:

Last updated