git clone https://github.com/The-Z-Labs/bof-launcher.git
cd bof-launcher
zig build
zig build test
wget https://raw.githubusercontent.com/The-Z-Labs/bof-launcher/main/utils/zigupdate.sh
chmod +x zigupdate.sh; ./zigupdate.sh
<update PATH>
git clone https://github.com/The-Z-Labs/bof-launcher
cd bof-launcher
zig build
zig build test
C API基础使用
// 加载对象文件(COFF或ELF)并获得一个对应的句柄
BofObjectHandle bof_handle;
if (bofObjectInitFromMemory(obj_file_data, obj_file_data_size, &bof_handle) < 0) {
// handle the error
}
// 执行
BofContext* context = NULL;
if (bofObjectRun(bof_handle, NULL, 0, &context) < 0) {
// handle the error
}
// 获取输出
const char* output = bofContextGetOutput(context, NULL);
if (output) {
// 处理BOF输出
}
bofContextRelease(context);
cli4bofs.exe exec .zig-outbinwWinver.coff.x64.o
cli4bofs.exe exec .zig-outbinudpScanner.coff.x64.o str:162.159.200.1-5:123,88
qemu-aarch64 -L /usr/aarch64-linux-gnu ./zig-out/bin/cli4bofs exec zig-out/bin/test_obj0.elf.aarch64.o
qemu-arm -L /usr/arm-linux-gnueabihf ./zig-out/bin/cli4bofs exec zig-out/bin/test_obj0.elf.arm.o
const w32 = @import("bof_api").win32;
const beacon = @import("bof_api").beacon;
extern fn @"ntdll$RtlGetVersion"(
lpVersionInformation: *w32.RTL_OSVERSIONINFOW,
) callconv(w32.WINAPI) w32.NTSTATUS;
const RtlGetVersion = @"ntdll$RtlGetVersion";
pub export fn go(_: ?[*]u8, _: i32) callconv(.C) u8 {
var version_info: w32.OSVERSIONINFOW = undefined;
version_info.dwOSVersionInfoSize = @sizeOf(@TypeOf(version_info));
if (RtlGetVersion(&version_info) != .SUCCESS)
return 1;
_ = beacon.printf(
0,
"Windows version: %d.%d, OS build number: %dn",
version_info.dwMajorVersion,
version_info.dwMinorVersion,
version_info.dwBuildNumber,
);
return 0;
}
#include <windows.h>
#include "beacon.h"
NTSYSAPI NTSTATUS NTAPI NTDLL$RtlGetVersion(OSVERSIONINFOW* lpVersionInformation);
unsigned char go(unsigned char* arg_data, int arg_len) {
OSVERSIONINFOW version_info;
version_info.dwOSVersionInfoSize = sizeof(version_info);
if (NTDLL$RtlGetVersion(&version_info) != 0)
return 1;
BeaconPrintf(
0,
"Windows version: %d.%d, OS build number: %dn",
version_info.dwMajorVersion,
version_info.dwMinorVersion,
version_info.dwBuildNumber
);
return 0;
}
#include <windows.h>
#include "beacon.h"
NTSYSAPI NTSTATUS NTAPI NTDLL$RtlGetVersion(OSVERSIONINFOW* lpVersionInformation);
unsigned char go(unsigned char* arg_data, int arg_len) {
OSVERSIONINFOW version_info;
version_info.dwOSVersionInfoSize = sizeof(version_info);
if (NTDLL$RtlGetVersion(&version_info) != 0)
return 1;
BeaconPrintf(
0,
"Windows version: %d.%d, OS build number: %dn",
version_info.dwMajorVersion,
version_info.dwMinorVersion,
version_info.dwBuildNumber
);
return 0;
}
原文始发于微信公众号(FreeBuf):如何使用bof-launcher在CC++Zig应用程序中执行Beacon对象文件(BOF)
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论