beacon.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /* data API */
  15. typedef struct {
  16. char * original; /* the original buffer [so we can free it] */
  17. char * buffer; /* current pointer into our buffer */
  18. int length; /* remaining length of data */
  19. int size; /* total size of this buffer */
  20. } datap;
  21. DECLSPEC_IMPORT void BeaconDataParse(datap * parser, char * buffer, int size);
  22. DECLSPEC_IMPORT char * BeaconDataPtr(datap * parser, int size);
  23. DECLSPEC_IMPORT int BeaconDataInt(datap * parser);
  24. DECLSPEC_IMPORT short BeaconDataShort(datap * parser);
  25. DECLSPEC_IMPORT int BeaconDataLength(datap * parser);
  26. DECLSPEC_IMPORT char * BeaconDataExtract(datap * parser, int * size);
  27. /* format API */
  28. typedef struct {
  29. char * original; /* the original buffer [so we can free it] */
  30. char * buffer; /* current pointer into our buffer */
  31. int length; /* remaining length of data */
  32. int size; /* total size of this buffer */
  33. } formatp;
  34. DECLSPEC_IMPORT void BeaconFormatAlloc(formatp * format, int maxsz);
  35. DECLSPEC_IMPORT void BeaconFormatReset(formatp * format);
  36. DECLSPEC_IMPORT void BeaconFormatAppend(formatp * format, char * text, int len);
  37. DECLSPEC_IMPORT void BeaconFormatPrintf(formatp * format, char * fmt, ...);
  38. DECLSPEC_IMPORT char * BeaconFormatToString(formatp * format, int * size);
  39. DECLSPEC_IMPORT void BeaconFormatFree(formatp * format);
  40. DECLSPEC_IMPORT void BeaconFormatInt(formatp * format, int value);
  41. /* Output Functions */
  42. #define CALLBACK_OUTPUT 0x0
  43. #define CALLBACK_OUTPUT_OEM 0x1e
  44. #define CALLBACK_OUTPUT_UTF8 0x20
  45. #define CALLBACK_ERROR 0x0d
  46. DECLSPEC_IMPORT void BeaconOutput(int type, char * data, int len);
  47. DECLSPEC_IMPORT void BeaconPrintf(int type, char * fmt, ...);
  48. /* Token Functions */
  49. DECLSPEC_IMPORT BOOL BeaconUseToken(HANDLE token);
  50. DECLSPEC_IMPORT void BeaconRevertToken();
  51. DECLSPEC_IMPORT BOOL BeaconIsAdmin();
  52. /* Spawn+Inject Functions */
  53. DECLSPEC_IMPORT void BeaconGetSpawnTo(BOOL x86, char * buffer, int length);
  54. DECLSPEC_IMPORT void BeaconInjectProcess(HANDLE hProc, int pid, char * payload, int p_len, int p_offset, char * arg, int a_len);
  55. DECLSPEC_IMPORT void BeaconInjectTemporaryProcess(PROCESS_INFORMATION * pInfo, char * payload, int p_len, int p_offset, char * arg, int a_len);
  56. DECLSPEC_IMPORT BOOL BeaconSpawnTemporaryProcess(BOOL x86, BOOL ignoreToken, STARTUPINFO * si, PROCESS_INFORMATION * pInfo);
  57. DECLSPEC_IMPORT void BeaconCleanupProcess(PROCESS_INFORMATION * pInfo);
  58. /* Utility Functions */
  59. DECLSPEC_IMPORT BOOL toWideChar(char * src, wchar_t * dst, int max);