mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-24 18:16:24 +01:00
winpmem failing to compile
This commit is contained in:
parent
31901e0eb1
commit
9dfa3ec1fc
c/meterpreter
source
common
extensions/stdapi/server
metsrv
workspace
ext_server_espia
ext_server_extapi
ext_server_incognito
ext_server_kiwi
ext_server_lanattacks
ext_server_peinjector
ext_server_powershell
ext_server_priv
ext_server_python
ext_server_sniffer
ext_server_stdapi
ext_server_unhook
ext_server_winpmem
meterpreter.slnmetsrv
2
c/meterpreter/source/common/common.h
Executable file → Normal file
2
c/meterpreter/source/common/common.h
Executable file → Normal file
@ -94,6 +94,7 @@ typedef struct ___u128 {
|
||||
#define CLOSE_SERVICE_HANDLE( h ) if( h ) { CloseServiceHandle( h ); h = NULL; }
|
||||
/*! @brief Close a handle if not already closed and set the handle to NULL. */
|
||||
#define CLOSE_HANDLE( h ) if( h ) { DWORD dwHandleFlags; if(GetHandleInformation( h , &dwHandleFlags)) CloseHandle( h ); h = NULL; }
|
||||
#include "common_logging.h"
|
||||
|
||||
/*!
|
||||
* @brief Output a debug string to the debug console.
|
||||
@ -111,6 +112,7 @@ static _inline void real_dprintf(char *format, ...)
|
||||
vsnprintf_s(buffer + len, sizeof(buffer)-len, sizeof(buffer)-len - 3, format, args);
|
||||
strcat_s(buffer, sizeof(buffer), "\r\n");
|
||||
OutputDebugStringA(buffer);
|
||||
logToFile(buffer);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define PROXY_HOST_SIZE 128
|
||||
#define PROXY_USER_SIZE 64
|
||||
#define PROXY_PASS_SIZE 64
|
||||
#define LOG_PATH_SIZE 260 // https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd
|
||||
|
||||
typedef wchar_t CHARTYPE;
|
||||
|
||||
@ -33,6 +34,7 @@ typedef struct _MetsrvSession
|
||||
int expiry; ///! The total number of seconds to wait before killing off the session.
|
||||
BYTE uuid[UUID_SIZE]; ///! UUID
|
||||
BYTE session_guid[sizeof(GUID)]; ///! Current session GUID
|
||||
CHARTYPE logPath[LOG_PATH_SIZE]; ///! Location to place the log file.
|
||||
} MetsrvSession;
|
||||
|
||||
typedef struct _MetsrvTransportCommon
|
||||
|
42
c/meterpreter/source/common/common_logging.c
Normal file
42
c/meterpreter/source/common/common_logging.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include "common.h"
|
||||
HANDLE lock = NULL;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
HANDLE initLogging(wchar_t* filePath) {
|
||||
hFile = CreateFileW(filePath, // name of the write
|
||||
GENERIC_WRITE, // open for writing
|
||||
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, // do share (7)
|
||||
NULL, // default security
|
||||
CREATE_ALWAYS, // create new file always
|
||||
FILE_ATTRIBUTE_NORMAL, // normal file
|
||||
NULL); // no attr. template
|
||||
lock = CreateMutex(NULL, FALSE, NULL);
|
||||
|
||||
if (hFile == NULL) {
|
||||
dprintf("[LOGGING] Logging to file failed to initialize")
|
||||
}
|
||||
return hFile;
|
||||
}
|
||||
|
||||
void logToFile(char* buffer) {
|
||||
if (hFile) {
|
||||
DWORD x = WaitForSingleObject(lock, INFINITE);
|
||||
|
||||
DWORD bytesWritten = 0;
|
||||
WriteFile(hFile, buffer, strlen(buffer), &bytesWritten, NULL);
|
||||
ReleaseMutex(lock);
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE getLoggingContext() {
|
||||
return hFile;
|
||||
}
|
||||
|
||||
HANDLE getLock() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
void setLoggingContext(HANDLE ctx, HANDLE lock1) {
|
||||
hFile = ctx;
|
||||
lock = lock1;
|
||||
}
|
11
c/meterpreter/source/common/common_logging.h
Normal file
11
c/meterpreter/source/common/common_logging.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _METERPRETER_COMMON_LOGGING_H
|
||||
#define _METERPRETER_COMMON_LOGGING_H
|
||||
#include "common_config.h"
|
||||
|
||||
HANDLE initLogging(wchar_t* filePath);
|
||||
HANDLE getLoggingContext();
|
||||
HANDLE getLock();
|
||||
void setLoggingContext(HANDLE ctx, HANDLE lock1);
|
||||
void logToFile(char* buffer);
|
||||
|
||||
#endif
|
@ -159,6 +159,12 @@ typedef struct _ListApi
|
||||
VOID(*destroy)(PLIST pList);
|
||||
} ListApi;
|
||||
|
||||
typedef struct _LoggingApi
|
||||
{
|
||||
HANDLE(*get_context)();
|
||||
HANDLE(*get_lock)();
|
||||
} LoggingApi;
|
||||
|
||||
typedef struct _MetApi
|
||||
{
|
||||
PacketApi packet;
|
||||
@ -172,6 +178,7 @@ typedef struct _MetApi
|
||||
InjectApi inject;
|
||||
DesktopApi desktop;
|
||||
ListApi list;
|
||||
LoggingApi logging;
|
||||
} MetApi;
|
||||
|
||||
extern MetApi* met_api;
|
||||
|
@ -177,7 +177,7 @@ Command customCommands[] =
|
||||
DWORD InitServerExtension(MetApi* api, Remote *remote)
|
||||
{
|
||||
met_api = api;
|
||||
|
||||
setLoggingContext(met_api->logging.get_context(), met_api->logging.get_lock());
|
||||
met_api->command.register_all( customCommands );
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
|
@ -1368,3 +1368,13 @@ DWORD packet_transmit(Remote* remote, Packet* packet, PacketRequestCompletion* c
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
HANDLE get_context()
|
||||
{
|
||||
return getLoggingContext();
|
||||
}
|
||||
|
||||
HANDLE get_lock()
|
||||
{
|
||||
return getLock();
|
||||
}
|
@ -71,4 +71,11 @@ DWORD packet_remove_completion_handler(LPCSTR requestId);
|
||||
HANDLE core_update_thread_token( Remote *remote, HANDLE token );
|
||||
VOID core_update_desktop( Remote * remote, DWORD dwSessionID, char * cpStationName, char * cpDesktopName );
|
||||
|
||||
/*
|
||||
* Logging API
|
||||
*/
|
||||
HANDLE get_context();
|
||||
HANDLE get_lock();
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -147,6 +147,11 @@ MetApi api_instance = {
|
||||
list_shift,
|
||||
list_destroy,
|
||||
},
|
||||
// LoggingApi
|
||||
{
|
||||
get_context,
|
||||
get_lock,
|
||||
},
|
||||
};
|
||||
|
||||
MetApi* met_api = &api_instance;
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
DWORD Init(MetsrvConfig* metConfig)
|
||||
{
|
||||
initLogging(metConfig->session.logPath);
|
||||
dprintf("[METSRV] Initializing Logging to file: %S", metConfig->session.logPath);
|
||||
|
||||
// if hAppInstance is still == NULL it means that we havent been
|
||||
// reflectivly loaded so we must patch in the hAppInstance value
|
||||
// for use with loading server extensions later.
|
||||
|
@ -231,6 +231,7 @@ static void config_create(Remote* remote, LPBYTE uuid, MetsrvConfig** config, LP
|
||||
memcpy(sess->uuid, uuid == NULL ? remote->orig_config->session.uuid : uuid, UUID_SIZE);
|
||||
// session GUID should persist across migration
|
||||
memcpy(sess->session_guid, remote->orig_config->session.session_guid, sizeof(GUID));
|
||||
memcpy(sess->logPath, remote->orig_config->session.logPath, LOG_PATH_SIZE);
|
||||
if (remote->sess_expiry_end)
|
||||
{
|
||||
sess->expiry = remote->sess_expiry_end - current_unix_timestamp();
|
||||
|
@ -451,6 +451,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\source\extensions\espia\espia.c" />
|
||||
<ClCompile Include="..\..\source\extensions\espia\screen.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\espia\espia.h" />
|
||||
|
@ -450,6 +450,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\extapi\wmi.c" />
|
||||
<ClCompile Include="..\..\source\extensions\extapi\wmi_interface.cpp" />
|
||||
<ClCompile Include="..\..\source\extensions\extapi\wshelpers.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\extapi\adsi.h" />
|
||||
|
@ -454,6 +454,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\incognito\list_tokens.c" />
|
||||
<ClCompile Include="..\..\source\extensions\incognito\token_info.c" />
|
||||
<ClCompile Include="..\..\source\extensions\incognito\user_management.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(Platform)'=='Win32'" />
|
||||
|
@ -613,6 +613,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='r7_release|x64'">4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\kiwi\main.h" />
|
||||
|
@ -413,6 +413,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\lanattacks\dhcpserv.cpp" />
|
||||
<ClCompile Include="..\..\source\extensions\lanattacks\TFTPserv.cpp" />
|
||||
<ClCompile Include="..\..\source\extensions\lanattacks\lanattacks.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\lanattacks\dhcpserv.h" />
|
||||
|
@ -441,6 +441,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\peinjector\libpetool.c" />
|
||||
<ClCompile Include="..\..\source\extensions\peinjector\peinjector.c" />
|
||||
<ClCompile Include="..\..\source\extensions\peinjector\peinjector_bridge.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\peinjector\headers.h" />
|
||||
|
@ -445,6 +445,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\powershell\powershell_bindings.cpp" />
|
||||
<ClCompile Include="..\..\source\extensions\powershell\powershell_bridge.cpp" />
|
||||
<ClCompile Include="..\..\source\extensions\powershell\powershell_runner.cpp" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\powershell\powershell.h" />
|
||||
|
@ -545,6 +545,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\priv\priv.c" />
|
||||
<ClCompile Include="..\..\source\extensions\priv\service.c" />
|
||||
<ClCompile Include="..\..\source\extensions\priv\tokendup.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -662,6 +662,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\python\python_commands.c" />
|
||||
<ClCompile Include="..\..\source\extensions\python\python_main.c" />
|
||||
<ClCompile Include="..\..\source\extensions\python\python_meterpreter_binding.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\python\Include\abstract.h" />
|
||||
|
@ -354,6 +354,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\$(TargetName)
|
||||
<ClCompile Include="..\..\source\extensions\sniffer\sniffer.c">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\sniffer\precomp.h" />
|
||||
|
@ -558,6 +558,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\stdapi\server\webcam\audio.c" />
|
||||
<ClCompile Include="..\..\source\extensions\stdapi\server\webcam\bmp2jpeg.c" />
|
||||
<ClCompile Include="..\..\source\extensions\stdapi\server\webcam\webcam.cpp" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\source\extensions\stdapi\server\resource\stdapi.rc" />
|
||||
|
@ -435,6 +435,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\extensions\unhook\apisetmap.c" />
|
||||
<ClCompile Include="..\..\source\extensions\unhook\refresh.c" />
|
||||
<ClCompile Include="..\..\source\extensions\unhook\unhook.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\unhook\apisetmap.h" />
|
||||
|
@ -431,6 +431,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\source\extensions\winpmem\winpmem.cpp" />
|
||||
<ClCompile Include="..\..\source\extensions\winpmem\winpmem_meterpreter.cpp" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\source\extensions\winpmem\elf.h" />
|
||||
|
2
c/meterpreter/workspace/meterpreter.sln
Executable file → Normal file
2
c/meterpreter/workspace/meterpreter.sln
Executable file → Normal file
@ -56,6 +56,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{EDE086
|
||||
..\source\common\common_core.h = ..\source\common\common_core.h
|
||||
..\source\common\common_exports.h = ..\source\common\common_exports.h
|
||||
..\source\common\common_list.h = ..\source\common\common_list.h
|
||||
..\source\common\common_logging.c = ..\source\common\common_logging.c
|
||||
..\source\common\common_logging.h = ..\source\common\common_logging.h
|
||||
..\source\common\common_metapi.h = ..\source\common\common_metapi.h
|
||||
..\source\common\common_pivot_tree.h = ..\source\common\common_pivot_tree.h
|
||||
..\source\common\common_remote.h = ..\source\common\common_remote.h
|
||||
|
@ -587,6 +587,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
|
||||
<ClCompile Include="..\..\source\metsrv\thread.c" />
|
||||
<ClCompile Include="..\..\source\metsrv\unicode.c" />
|
||||
<ClCompile Include="..\..\source\metsrv\zlib.c" />
|
||||
<ClCompile Include="..\..\source\common\common_logging.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
Loading…
x
Reference in New Issue
Block a user