Skip to content

Commit 95aabd2

Browse files
author
Christopher Graham (Cobalt Strike)
committed
Merge branch 'feat/412-changes' into 'main'
Update template with 4.12 changes See merge request cobalt-strike-research/bof-vs!12
2 parents 0fca1ea + dd6addd commit 95aabd2

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

BOF-Template/base/mock.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -350,29 +350,24 @@ namespace bof {
350350
}
351351
}
352352

353-
std::vector<bof::output::OutputEntry> runMockedSleepMask(SLEEPMASK_FUNC sleepMaskFunc, PSLEEPMASK_INFO sleepMaskInfo, PFUNCTION_CALL functionCall) {
353+
std::vector<bof::output::OutputEntry> runMockedSleepMask(SLEEPMASK_FUNC sleepMaskFunc, PBEACON_INFO beaconInfo, PFUNCTION_CALL functionCall) {
354354
// Reset the global output container
355355
bof::output::reset();
356356
// Execute the entrypoint
357-
sleepMaskFunc(sleepMaskInfo, functionCall);
357+
sleepMaskFunc(beaconInfo, functionCall);
358358
// Return the stored outputs
359359
return bof::output::getOutputs();
360360
}
361361

362362
std::vector<bof::output::OutputEntry> runMockedSleepMask(SLEEPMASK_FUNC sleepMaskFunc, const bof::profile::Stage& stage, const bof::mock::MockSleepMaskConfig& config) {
363363
BEACON_INFO beaconInfo = bof::mock::setupMockBeacon(stage);
364-
SLEEPMASK_INFO sleepmaskInfo = {
365-
.version = bof::CsVersion,
366-
.reason = DEFAULT_SLEEP,
367-
.sleep_time = config.sleepTimeMs,
368-
.beacon_info = beaconInfo,
369-
};
370-
bof::mock::resolveMockUpSleepmaskLocation(sleepmaskInfo.beacon_info);
364+
FUNCTION_CALL functionCall = bof::mock::createFunctionCallStructure(Sleep, SLEEP, TRUE, 1, config.sleepTimeMs);
365+
bof::mock::resolveMockUpSleepmaskLocation(beaconInfo);
371366
bof::mock::setBeaconInfo(beaconInfo);
372367

373368
std::vector<bof::output::OutputEntry> output;
374369
do {
375-
output = runMockedSleepMask(sleepMaskFunc, &sleepmaskInfo, NULL);
370+
output = runMockedSleepMask(sleepMaskFunc, &beaconInfo, &functionCall);
376371
} while (config.runForever);
377372

378373
return output;
@@ -393,15 +388,9 @@ namespace bof {
393388

394389
std::vector<bof::output::OutputEntry> runMockedBeaconGate(SLEEPMASK_FUNC sleepMaskFunc, PFUNCTION_CALL functionCall, const bof::profile::Stage& stage) {
395390
BEACON_INFO beaconInfo = bof::mock::setupMockBeacon(stage);
396-
SLEEPMASK_INFO sleepmaskInfo = {
397-
.version = bof::CsVersion,
398-
.reason = BEACON_GATE,
399-
.sleep_time = 0,
400-
.beacon_info = beaconInfo,
401-
};
402-
bof::mock::resolveMockUpSleepmaskLocation(sleepmaskInfo.beacon_info);
391+
bof::mock::resolveMockUpSleepmaskLocation(beaconInfo);
403392
bof::mock::setBeaconInfo(beaconInfo);
404-
return runMockedSleepMask(sleepMaskFunc, &sleepmaskInfo, functionCall);
393+
return runMockedSleepMask(sleepMaskFunc, &beaconInfo, functionCall);
405394
}
406395

407396
std::vector<bof::output::OutputEntry> runMockedBeaconGate(SLEEPMASK_FUNC sleepMaskFunc, PFUNCTION_CALL functionCall) {
@@ -430,6 +419,11 @@ extern "C"
430419
va_end(args);
431420
}
432421

422+
BOOL BeaconDownload(const char* filename, const char* buffer, unsigned int length) {
423+
std::cerr << "Not implemented: " << __FUNCTION__ << std::endl;
424+
return FALSE;
425+
}
426+
433427
void BeaconOutput(int type, const char *data, int len) {
434428
bof::output::addEntry(type, data, len);
435429
printf("[Output Callback: %s (0x%X)]\n%.*s", bof::utils::typeToStr(type), type, len, data);

BOF-Template/base/mock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../sleepmask.h"
55

66
namespace bof {
7-
const DWORD CsVersion = 0x041000;
7+
const DWORD CsVersion = 0x041200;
88

99
namespace profile {
1010
/**
@@ -276,7 +276,7 @@ namespace bof {
276276
* @param functionCall the pointer to the FUNCTION_CALL structure
277277
* @return A vector of OutputEntry objects
278278
*/
279-
std::vector<bof::output::OutputEntry> runMockedSleepMask(SLEEPMASK_FUNC sleepMaskFunc, PSLEEPMASK_INFO sleepMaskInfo, PFUNCTION_CALL functionCall);
279+
std::vector<bof::output::OutputEntry> runMockedSleepMask(SLEEPMASK_FUNC sleepMaskFunc, PBEACON_INFO beaconInfo, PFUNCTION_CALL functionCall);
280280

281281
/**
282282
* Setup a mock-up Beacon and execute the sleepmask function as Beacon Gate with the default stage block.

BOF-Template/beacon_gate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ typedef enum _WinApi {
3232
READPROCESSMEMORY,
3333
WRITEPROCESSMEMORY,
3434
EXITTHREAD,
35+
VIRTUALFREEEX,
36+
VIRTUALQUERYEX,
37+
WAITFORSINGLEOBJECT,
38+
SLEEP
3539
} WinApi;
3640

3741
/**

BOF-Template/bof.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ extern "C" {
4141
}
4242
}
4343

44-
/*
45-
void sleep_mask(PSLEEPMASK_INFO info, PFUNCTION_CALL funcCall) {
46-
}
47-
*/
44+
45+
/*void sleep_mask(PBEACON_INFO info, PFUNCTION_CALL funcCall) {
46+
// BeaconGateWrapper(info, funcCall);
47+
}*/
4848
}
4949

5050
// Define a main function for the bebug build

0 commit comments

Comments
 (0)