|
| 1 | +/* |
| 2 | + * Beacon Object Files (BOF) |
| 3 | + * ------------------------- |
| 4 | + * A Beacon Object File is a light-weight post exploitation tool that runs |
| 5 | + * with Beacon's inline-execute command. |
| 6 | + * |
| 7 | + * Additional BOF resources are available here: |
| 8 | + * - https://github.com/Cobalt-Strike/bof_template |
| 9 | + * |
| 10 | + * Cobalt Strike 4.x |
| 11 | + * ChangeLog: |
| 12 | + * 1/25/2022: updated for 4.5 |
| 13 | + */ |
| 14 | + |
| 15 | +#ifndef DECLSPEC_IMPORT |
| 16 | +#ifdef _WIN32 |
| 17 | +#define DECLSPEC_IMPORT __declspec(dllimport) |
| 18 | +#else |
| 19 | +#define DECLSPEC_IMPORT |
| 20 | +#endif |
| 21 | +#endif |
| 22 | + |
| 23 | +/* data API */ |
| 24 | +typedef struct { |
| 25 | + char * original; /* the original buffer [so we can free it] */ |
| 26 | + char * buffer; /* current pointer into our buffer */ |
| 27 | + int length; /* remaining length of data */ |
| 28 | + int size; /* total size of this buffer */ |
| 29 | +} datap; |
| 30 | + |
| 31 | +DECLSPEC_IMPORT void BeaconDataParse(datap * parser, char * buffer, int size); |
| 32 | +DECLSPEC_IMPORT char * BeaconDataPtr(datap * parser, int size); |
| 33 | +DECLSPEC_IMPORT int BeaconDataInt(datap * parser); |
| 34 | +DECLSPEC_IMPORT short BeaconDataShort(datap * parser); |
| 35 | +DECLSPEC_IMPORT int BeaconDataLength(datap * parser); |
| 36 | +DECLSPEC_IMPORT char * BeaconDataExtract(datap * parser, int * size); |
| 37 | + |
| 38 | +/* format API */ |
| 39 | +typedef struct { |
| 40 | + char * original; /* the original buffer [so we can free it] */ |
| 41 | + char * buffer; /* current pointer into our buffer */ |
| 42 | + int length; /* remaining length of data */ |
| 43 | + int size; /* total size of this buffer */ |
| 44 | +} formatp; |
| 45 | + |
| 46 | +DECLSPEC_IMPORT void BeaconFormatAlloc(formatp * format, int maxsz); |
| 47 | +DECLSPEC_IMPORT void BeaconFormatReset(formatp * format); |
| 48 | +DECLSPEC_IMPORT void BeaconFormatAppend(formatp * format, char * text, int len); |
| 49 | +DECLSPEC_IMPORT void BeaconFormatPrintf(formatp * format, char * fmt, ...); |
| 50 | +DECLSPEC_IMPORT char * BeaconFormatToString(formatp * format, int * size); |
| 51 | +DECLSPEC_IMPORT void BeaconFormatFree(formatp * format); |
| 52 | +DECLSPEC_IMPORT void BeaconFormatInt(formatp * format, int value); |
| 53 | + |
| 54 | +/* Output Functions */ |
| 55 | +#define CALLBACK_OUTPUT 0x0 |
| 56 | +#define CALLBACK_OUTPUT_OEM 0x1e |
| 57 | +#define CALLBACK_OUTPUT_UTF8 0x20 |
| 58 | +#define CALLBACK_ERROR 0x0d |
| 59 | + |
| 60 | +DECLSPEC_IMPORT void BeaconOutput(int type, char * data, int len); |
| 61 | +DECLSPEC_IMPORT void BeaconPrintf(int type, char * fmt, ...); |
| 62 | + |
| 63 | + |
| 64 | +/* Token Functions */ |
| 65 | +DECLSPEC_IMPORT BOOL BeaconUseToken(HANDLE token); |
| 66 | +DECLSPEC_IMPORT void BeaconRevertToken(); |
| 67 | +DECLSPEC_IMPORT BOOL BeaconIsAdmin(); |
| 68 | + |
| 69 | +/* Spawn+Inject Functions */ |
| 70 | +DECLSPEC_IMPORT void BeaconGetSpawnTo(BOOL x86, char * buffer, int length); |
| 71 | +DECLSPEC_IMPORT void BeaconInjectProcess(HANDLE hProc, int pid, char * payload, int p_len, int p_offset, char * arg, int a_len); |
| 72 | +DECLSPEC_IMPORT void BeaconInjectTemporaryProcess(PROCESS_INFORMATION * pInfo, char * payload, int p_len, int p_offset, char * arg, int a_len); |
| 73 | +DECLSPEC_IMPORT BOOL BeaconSpawnTemporaryProcess(BOOL x86, BOOL ignoreToken, STARTUPINFO * si, PROCESS_INFORMATION * pInfo); |
| 74 | +DECLSPEC_IMPORT void BeaconCleanupProcess(PROCESS_INFORMATION * pInfo); |
| 75 | + |
| 76 | +/* Utility Functions */ |
| 77 | +DECLSPEC_IMPORT BOOL toWideChar(char * src, wchar_t * dst, int max); |
| 78 | + |
0 commit comments