From 3dbff1e401f91a3f7ad991445f67748f8151d74f Mon Sep 17 00:00:00 2001 From: OJ Date: Thu, 23 Apr 2020 13:29:20 +1000 Subject: [PATCH] Clean and working builds with CMake --- c/meterpreter/source/elevator/elevator.c | 1 + c/meterpreter/source/elevator/elevator.h | 27 --------- .../source/elevator/namedpipeservice.c | 1 + c/meterpreter/source/elevator/tokendup.c | 5 ++ .../extensions/python/Modules/_elementtree.c | 8 +-- .../stdapi/server/webcam/bmp2jpeg.c | 2 +- .../source/extensions/winpmem/winpmem.h | 2 +- .../winpmem/winpmem_meterpreter.cpp | 1 - c/meterpreter/source/metsrv/server_setup.c | 2 - c/meterpreter/source/screenshot/bmp2jpeg.c | 14 +++++ c/meterpreter/source/screenshot/screenshot.c | 29 +++++++++ c/meterpreter/source/screenshot/screenshot.h | 27 --------- c/meterpreter/workspace/CMakeLists.txt | 20 ++++++- .../workspace/elevator/CMakeLists.txt | 3 + .../workspace/elevator/elevator.vcxproj | 8 +-- .../workspace/ext_server_espia/CMakeLists.txt | 4 +- .../ext_server_extapi/CMakeLists.txt | 3 + .../ext_server_incognito/CMakeLists.txt | 2 + .../workspace/ext_server_kiwi/CMakeLists.txt | 2 + .../ext_server_lanattacks/CMakeLists.txt | 3 + .../ext_server_mimikatz/CMakeLists.txt | 2 + .../ext_server_peinjector/CMakeLists.txt | 2 + .../workspace/ext_server_priv/CMakeLists.txt | 2 + .../ext_server_python/CMakeLists.txt | 3 + .../ext_server_sniffer/CMakeLists.txt | 2 + .../ext_server_stdapi/CMakeLists.txt | 4 ++ .../ext_server_unhook/CMakeLists.txt | 2 + .../ext_server_winpmem/CMakeLists.txt | 2 + c/meterpreter/workspace/jpeg/CMakeLists.txt | 5 +- c/meterpreter/workspace/make.bat | 59 +++++++++++++++---- c/meterpreter/workspace/metsrv/CMakeLists.txt | 3 + .../workspace/screenshot/CMakeLists.txt | 4 +- .../workspace/screenshot/screenshot.vcxproj | 8 +-- 33 files changed, 173 insertions(+), 89 deletions(-) diff --git a/c/meterpreter/source/elevator/elevator.c b/c/meterpreter/source/elevator/elevator.c index 74e84161..efb91f16 100644 --- a/c/meterpreter/source/elevator/elevator.c +++ b/c/meterpreter/source/elevator/elevator.c @@ -8,6 +8,7 @@ #include "elevator.h" #include "namedpipeservice.h" #include "tokendup.h" +#include "common.h" // define this as we are going to be injected via LoadRemoteLibraryR #define REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR diff --git a/c/meterpreter/source/elevator/elevator.h b/c/meterpreter/source/elevator/elevator.h index 2209beb7..0d94e648 100644 --- a/c/meterpreter/source/elevator/elevator.h +++ b/c/meterpreter/source/elevator/elevator.h @@ -6,31 +6,4 @@ #include #include -//#define DEBUGTRACE - -#ifdef DEBUGTRACE -#define dprintf(...) real_dprintf(__VA_ARGS__) -#else -#define dprintf(...) do{}while(0); -#endif - -static _inline void real_dprintf(char *format, ...) { - va_list args; - char buffer[1024]; - va_start(args,format); - vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer)-3, format,args); - strcat_s(buffer, sizeof(buffer), "\r\n"); - OutputDebugString(buffer); - va_end(args); -} - -// Simple macro to close a handle and set the handle to NULL. -#define CLOSE_HANDLE( h ) if( h ) { CloseHandle( h ); h = NULL; } - -#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; } -#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d", str, dwResult ); break; } - -typedef BOOL (WINAPI * CHECKTOKENMEMBERSHIP)( HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember ); -typedef HANDLE (WINAPI * OPENTHREAD)( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId ); - #endif diff --git a/c/meterpreter/source/elevator/namedpipeservice.c b/c/meterpreter/source/elevator/namedpipeservice.c index eeedcfd3..a4a27da2 100644 --- a/c/meterpreter/source/elevator/namedpipeservice.c +++ b/c/meterpreter/source/elevator/namedpipeservice.c @@ -1,5 +1,6 @@ #include "elevator.h" #include "namedpipeservice.h" +#include "common.h" LPSTR lpServiceName = NULL; SERVICE_STATUS_HANDLE hStatus = NULL; diff --git a/c/meterpreter/source/elevator/tokendup.c b/c/meterpreter/source/elevator/tokendup.c index 0d88ed82..eb02cbbc 100644 --- a/c/meterpreter/source/elevator/tokendup.c +++ b/c/meterpreter/source/elevator/tokendup.c @@ -1,5 +1,10 @@ #include "elevator.h" #include "tokendup.h" +#include "common.h" + +typedef BOOL (WINAPI * CHECKTOKENMEMBERSHIP)( HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember ); +typedef HANDLE (WINAPI * OPENTHREAD)( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId ); + /* * Elevate the given thread with our current token if we are running under the required user. diff --git a/c/meterpreter/source/extensions/python/Modules/_elementtree.c b/c/meterpreter/source/extensions/python/Modules/_elementtree.c index ef2a7067..7968bfdf 100644 --- a/c/meterpreter/source/extensions/python/Modules/_elementtree.c +++ b/c/meterpreter/source/extensions/python/Modules/_elementtree.c @@ -693,7 +693,7 @@ element_deepcopy(ElementObject* self, PyObject* args) } /* add object to memo dictionary (so deepcopy won't visit it again) */ - id = PyInt_FromLong((Py_uintptr_t) self); + id = PyInt_FromLong((long)(Py_uintptr_t) self); if (!id) goto error; @@ -1273,7 +1273,7 @@ element_setitem(PyObject* self_, Py_ssize_t index, PyObject* item) self->extra->children[index] = item; } else { self->extra->length--; - for (i = index; i < self->extra->length; i++) + for (i = (int)(INT_PTR)index; i < self->extra->length; i++) self->extra->children[i] = self->extra->children[i+1]; } @@ -1406,7 +1406,7 @@ element_ass_subscr(PyObject* self_, PyObject* item, PyObject* value) /* Resize before creating the recycle bin, to prevent refleaks. */ if (newlen > slicelen) { - if (element_resize(self, newlen - slicelen) < 0) { + if (element_resize(self, (int)(INT_PTR)(newlen - slicelen)) < 0) { if (seq) { Py_DECREF(seq); } @@ -1448,7 +1448,7 @@ element_ass_subscr(PyObject* self_, PyObject* item, PyObject* value) self->extra->children[cur] = element; } - self->extra->length += newlen - slicelen; + self->extra->length += (int)(INT_PTR)(newlen - slicelen); if (seq) { Py_DECREF(seq); diff --git a/c/meterpreter/source/extensions/stdapi/server/webcam/bmp2jpeg.c b/c/meterpreter/source/extensions/stdapi/server/webcam/bmp2jpeg.c index 040ac72e..136912ea 100644 --- a/c/meterpreter/source/extensions/stdapi/server/webcam/bmp2jpeg.c +++ b/c/meterpreter/source/extensions/stdapi/server/webcam/bmp2jpeg.c @@ -132,7 +132,7 @@ int ReadOK(bmp_source_ptr sinfo, char* buffer,int len) */ int read_byte (bmp_source_ptr sinfo) { - return (int)sinfo->pub.input_buf + sinfo->pub.read_offset++; + return (int)(INT_PTR)sinfo->pub.input_buf + sinfo->pub.read_offset++; } /* diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.h b/c/meterpreter/source/extensions/winpmem/winpmem.h index 4a2876f6..1b82f1a4 100755 --- a/c/meterpreter/source/extensions/winpmem/winpmem.h +++ b/c/meterpreter/source/extensions/winpmem/winpmem.h @@ -1,4 +1,4 @@ -#include "../../common/common.h" +#include "common.h" #include diff --git a/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp b/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp index 0c036072..a491b7e4 100644 --- a/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp +++ b/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp @@ -1,4 +1,3 @@ -#define DEBUGTRACE 1 extern "C" { /*! * @file WINPMEM.cpp diff --git a/c/meterpreter/source/metsrv/server_setup.c b/c/meterpreter/source/metsrv/server_setup.c index 9bc38698..13321caf 100644 --- a/c/meterpreter/source/metsrv/server_setup.c +++ b/c/meterpreter/source/metsrv/server_setup.c @@ -325,8 +325,6 @@ DWORD server_setup(MetsrvConfig* config) { do { - dprintf("[SERVER] module loaded at 0x%08X", hAppInstance); - // Open a THREAD item for the servers main thread, we use this to manage migration later. serverThread = thread_open(); diff --git a/c/meterpreter/source/screenshot/bmp2jpeg.c b/c/meterpreter/source/screenshot/bmp2jpeg.c index e970b828..dffbd46d 100644 --- a/c/meterpreter/source/screenshot/bmp2jpeg.c +++ b/c/meterpreter/source/screenshot/bmp2jpeg.c @@ -1,5 +1,6 @@ #include "screenshot.h" #include "bmp2jpeg.h" +#include "common.h" /* * Please Note: bmp2jpeg.c and bmp2jpeg.h have been coppied over from screen.c @@ -743,6 +744,8 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j else if (cClrBits <= 24) cClrBits = 24; else cClrBits = 32; + + dprintf("[SCREENSHOT bmptojpeg] Debug 1"); // Allocate memory for the BITMAPINFO structure. (This structure // contains a BITMAPINFOHEADER structure and an array of RGBQUAD @@ -797,6 +800,7 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j return 0; } + dprintf("[SCREENSHOT bmptojpeg] Debug 2"); hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M" // Compute the size of the entire file. hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + @@ -833,6 +837,7 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j * We need to provide some value for jpeg_set_defaults() to work. */ + dprintf("[SCREENSHOT bmptojpeg] Debug 3"); cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ @@ -845,6 +850,7 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j /* Read the input file header to obtain file size & colorspace. */ start_input_bmp(&cinfo, src_mgr); + dprintf("[SCREENSHOT bmptojpeg] Debug 4"); jpeg_default_colorspace(&cinfo); @@ -852,14 +858,18 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j /* Go GRAYSCALE */ //jpeg_set_colorspace(&cinfo, JCS_GRAYSCALE); /* Quality */ + dprintf("[SCREENSHOT bmptojpeg] Debug 4A"); jpeg_set_quality(&cinfo, quality, FALSE); // Write the compressed JPEG to memory: bug_jpeg + dprintf("[SCREENSHOT bmptojpeg] Debug 4B"); jpeg_mem_dest(&cinfo, buf_jpeg, buf_jpeg_size); /* Start compressor */ + dprintf("[SCREENSHOT bmptojpeg] Debug 4C"); jpeg_start_compress(&cinfo, TRUE); + dprintf("[SCREENSHOT bmptojpeg] Debug 5"); /* Process data */ while (cinfo.next_scanline < cinfo.image_height) { num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); @@ -867,9 +877,13 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j } /* Finish compression and release memory */ + dprintf("[SCREENSHOT bmptojpeg] Debug 6"); (*src_mgr->finish_input) (&cinfo, src_mgr); + dprintf("[SCREENSHOT bmptojpeg] Debug 7"); jpeg_finish_compress(&cinfo); + dprintf("[SCREENSHOT bmptojpeg] Debug 8"); jpeg_destroy_compress(&cinfo); + dprintf("[SCREENSHOT bmptojpeg] Debug 9"); // Free memory. GlobalFree((HGLOBAL)lpBits); diff --git a/c/meterpreter/source/screenshot/screenshot.c b/c/meterpreter/source/screenshot/screenshot.c index 1d4510f1..ece08e2e 100644 --- a/c/meterpreter/source/screenshot/screenshot.c +++ b/c/meterpreter/source/screenshot/screenshot.c @@ -1,5 +1,6 @@ #include "screenshot.h" #include "bmp2jpeg.h" +#include "common.h" // define this as we are going to be injected via RDI #define REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR @@ -82,12 +83,17 @@ DWORD screenshot(int quality, DWORD dwPipeName) do { + dprintf("[SCREENSHOT] Debug 1"); _snprintf_s(cNamedPipe, sizeof(cNamedPipe), MAX_PATH, "\\\\.\\pipe\\%08X", dwPipeName); + dprintf("[SCREENSHOT] Debug 2"); os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx(&os)) + { BREAK_ON_ERROR("[SCREENSHOT] screenshot: GetVersionEx failed") + } + dprintf("[SCREENSHOT] Debug 3"); // On NT we cant use SM_CXVIRTUALSCREEN/SM_CYVIRTUALSCREEN. if (os.dwMajorVersion <= 4) @@ -96,50 +102,65 @@ DWORD screenshot(int quality, DWORD dwPipeName) ymetric = SM_CYSCREEN; } + dprintf("[SCREENSHOT] Debug 4"); // open the WinSta0 as some services are attached to a different window station. hWindowStation = OpenWindowStationA("WinSta0", FALSE, WINSTA_ALL_ACCESS); + dprintf("[SCREENSHOT] Debug 5"); if (!hWindowStation) { if (RevertToSelf()) + { + dprintf("[SCREENSHOT] Debug 6"); hWindowStation = OpenWindowStationA("WinSta0", FALSE, WINSTA_ALL_ACCESS); + } } // if we cant open the defaut input station we wont be able to take a screenshot if (!hWindowStation) + { BREAK_WITH_ERROR("[SCREENSHOT] screenshot: Couldnt get the WinSta0 Window Station", ERROR_INVALID_HANDLE); + } // get the current process's window station so we can restore it later on. hOrigWindowStation = GetProcessWindowStation(); + dprintf("[SCREENSHOT] Debug 7"); // set the host process's window station to this sessions default input station we opened if (!SetProcessWindowStation(hWindowStation)) BREAK_ON_ERROR("[SCREENSHOT] screenshot: SetProcessWindowStation failed"); // grab a handle to the default input desktop (e.g. Default or WinLogon) + dprintf("[SCREENSHOT] Debug 8"); hInputDesktop = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED); if (!hInputDesktop) BREAK_ON_ERROR("[SCREENSHOT] screenshot: OpenInputDesktop failed"); // get the threads current desktop so we can restore it later on + dprintf("[SCREENSHOT] Debug 9"); hOrigDesktop = GetThreadDesktop(GetCurrentThreadId()); // set this threads desktop to that of this sessions default input desktop on WinSta0 + dprintf("[SCREENSHOT] Debug 10"); SetThreadDesktop(hInputDesktop); // and now we can grab a handle to this input desktop + dprintf("[SCREENSHOT] Debug 11"); hDesktopWnd = GetDesktopWindow(); // and get a DC from it so we can read its pixels! + dprintf("[SCREENSHOT] Debug 12"); hdc = GetDC(hDesktopWnd); if (!hdc) BREAK_ON_ERROR("[SCREENSHOT] screenshot. GetDC failed"); // back up this DC with a memory DC + dprintf("[SCREENSHOT] Debug 13"); hmemdc = CreateCompatibleDC(hdc); if (!hmemdc) BREAK_ON_ERROR("[SCREENSHOT] screenshot. CreateCompatibleDC failed"); // calculate the width and height + dprintf("[SCREENSHOT] Debug 14"); sx = GetSystemMetrics(xmetric); sy = GetSystemMetrics(ymetric); @@ -147,17 +168,20 @@ DWORD screenshot(int quality, DWORD dwPipeName) // prevent breaking functionality on <= NT 4.0 if (os.dwMajorVersion >= 4) { + dprintf("[SCREENSHOT] Debug 14"); sxpos = GetSystemMetrics(SM_XVIRTUALSCREEN); sypos = GetSystemMetrics(SM_YVIRTUALSCREEN); } // and create a bitmap + dprintf("[SCREENSHOT] Debug 15"); hbmp = CreateCompatibleBitmap(hdc, sx, sy); if (!hbmp) BREAK_ON_ERROR("[SCREENSHOT] screenshot. CreateCompatibleBitmap failed"); // this bitmap is backed by the memory DC + dprintf("[SCREENSHOT] Debug 16"); if (!SelectObject(hmemdc, hbmp)) BREAK_ON_ERROR("[SCREENSHOT] screenshot. SelectObject failed"); @@ -165,9 +189,11 @@ DWORD screenshot(int quality, DWORD dwPipeName) // screenshot all available monitors by default HMODULE user32 = NULL; + dprintf("[SCREENSHOT] Debug 17"); if ((user32 = LoadLibraryA("user32"))) { + dprintf("[SCREENSHOT] Debug 18"); FARPROC SPDA = GetProcAddress(user32, "SetProcessDPIAware"); if (SPDA) { @@ -175,13 +201,16 @@ DWORD screenshot(int quality, DWORD dwPipeName) } FreeLibrary(user32); } + dprintf("[SCREENSHOT] Debug 19"); if (!StretchBlt(hmemdc, 0, 0, sx, sy, hdc, sxpos, sypos, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN), SRCCOPY)) BREAK_ON_ERROR("[SCREENSHOT] screenshot. StretchBlt failed"); // finally convert the BMP we just made into a JPEG... + dprintf("[SCREENSHOT] Debug 20"); if (bmp2jpeg(hbmp, hmemdc, quality, &pJpegBuffer, &dwJpegSize) != 1) BREAK_WITH_ERROR("[SCREENSHOT] screenshot. bmp2jpeg failed", ERROR_INVALID_HANDLE); + dprintf("[SCREENSHOT] Debug 21"); // we have succeded dwResult = ERROR_SUCCESS; diff --git a/c/meterpreter/source/screenshot/screenshot.h b/c/meterpreter/source/screenshot/screenshot.h index 9ad1a3df..0e8f8341 100644 --- a/c/meterpreter/source/screenshot/screenshot.h +++ b/c/meterpreter/source/screenshot/screenshot.h @@ -6,31 +6,4 @@ #include #include -//#define DEBUGTRACE - -#ifdef DEBUGTRACE -#define dprintf(...) real_dprintf(__VA_ARGS__) -#else -#define dprintf(...) do{}while(0); -#endif - -static _inline void real_dprintf(char *format, ...) { - va_list args; - char buffer[1024]; - va_start(args,format); - vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer)-3, format,args); - strcat_s(buffer, sizeof(buffer), "\r\n"); - OutputDebugStringA(buffer); - va_end(args); -} - -// Simple macro to close a handle and set the handle to NULL. -#define CLOSE_HANDLE( h ) if( h ) { CloseHandle( h ); h = NULL; } - -#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; } -#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d", str, dwResult ); break; } - -typedef BOOL (WINAPI * CHECKTOKENMEMBERSHIP)( HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember ); -typedef HANDLE (WINAPI * OPENTHREAD)( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId ); - #endif diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt index 01bd1f79..1bdf9d5e 100644 --- a/c/meterpreter/workspace/CMakeLists.txt +++ b/c/meterpreter/workspace/CMakeLists.txt @@ -5,6 +5,8 @@ set(PROJECT_NAME meterpreter) cmake_policy(SET CMP0091 NEW) project(${PROJECT_NAME} C CXX) +option(DBGTRACE "Enable debug tracing" OFF) +option(DBGTRACE_VERBOSE "Enable verbose debug tracing" OFF) option(BUILD_SNIFFER "Build the sniffer extension (requires PSSDK)" OFF) option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" ON) if( USE_STATIC_MSVC_RUNTIMES ) @@ -29,12 +31,20 @@ endif() if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build Type not speicified, defaulting to 'Release'.") + message(STATUS "Build Type not specified, defaulting to 'Release'.") endif() set(IS_RELEASE true) set(IS_DEBUG false) -if(NOT CMAKE_BUILD_TYPE MATCHES "Release") + +if(CMAKE_BUILD_TYPE MATCHES "Release") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /WX") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX /EHsc") + string(REPLACE "O2" "O1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "Ob2" "Ob1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "O2" "O1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "Ob2" "Ob1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +else() # We only support "Release" or "Debug" set(CMAKE_BUILD_TYPE "Debug") set(IS_RELEASE false) @@ -48,6 +58,12 @@ add_definitions( -DWINVER=0x0501 ) +if(DBGTRACE_VERBOSE) + add_definitions(-DDEBUGTRACE=1) +elseif(DBGTRACE) + add_definitions(-DDEBUGTRACE=0) +endif() + if(IS_X64) add_definitions( -DWIN64 diff --git a/c/meterpreter/workspace/elevator/CMakeLists.txt b/c/meterpreter/workspace/elevator/CMakeLists.txt index b51279b8..6530d8bf 100644 --- a/c/meterpreter/workspace/elevator/CMakeLists.txt +++ b/c/meterpreter/workspace/elevator/CMakeLists.txt @@ -6,8 +6,11 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt) add_definitions( -D_USRDLL + -D_CRT_SECURE_NO_WARNINGS ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/elevator/elevator.vcxproj b/c/meterpreter/workspace/elevator/elevator.vcxproj index 201e6eeb..cd2b8b0a 100644 --- a/c/meterpreter/workspace/elevator/elevator.vcxproj +++ b/c/meterpreter/workspace/elevator/elevator.vcxproj @@ -98,7 +98,7 @@ CompileAsC false true - ..\..\source\ReflectiveDLLInjection\common + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common true @@ -135,7 +135,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\" CompileAsC false true - ..\..\source\ReflectiveDLLInjection\common + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common true @@ -174,7 +174,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\" StdCall CompileAsC true - ..\..\source\ReflectiveDLLInjection\common + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common true @@ -210,7 +210,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\" StdCall CompileAsC true - ..\..\source\ReflectiveDLLInjection\common + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common true diff --git a/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt b/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt index ce4a8c00..5d85adf7 100644 --- a/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt @@ -6,10 +6,10 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt) add_definitions( -D_USRDLL - -DUNICODE - -D_UNICODE ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /Gy- /Oy-") + include_directories(../../source/common) include_directories(../../source/jpeg-8) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt index 155b8d87..716f7d13 100644 --- a/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt @@ -8,6 +8,9 @@ add_definitions( -D_USRDLL ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt b/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt index 36d81048..2f3a73d8 100644 --- a/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt @@ -10,6 +10,8 @@ add_definitions( -D_UNICODE ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt index ab098a63..95f968fe 100644 --- a/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt @@ -11,6 +11,8 @@ add_definitions( -D_POWERKATZ ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) include_directories(../../source/extensions/kiwi/mimikatz/inc) diff --git a/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt b/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt index 6e9af501..7dc29706 100644 --- a/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt @@ -10,6 +10,9 @@ add_definitions( -D_UNICODE ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_mimikatz/CMakeLists.txt b/c/meterpreter/workspace/ext_server_mimikatz/CMakeLists.txt index c0567255..9771c0d4 100644 --- a/c/meterpreter/workspace/ext_server_mimikatz/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_mimikatz/CMakeLists.txt @@ -10,6 +10,8 @@ add_definitions( -D_UNICODE ) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt b/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt index ab3aadb9..2bffd6f6 100644 --- a/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt @@ -10,6 +10,8 @@ add_definitions( -D_UNICODE ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt b/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt index badd01f7..36f2c938 100644 --- a/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt @@ -8,6 +8,8 @@ add_definitions( -D_USRDLL ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_python/CMakeLists.txt b/c/meterpreter/workspace/ext_server_python/CMakeLists.txt index 1b99f32b..9626fa87 100644 --- a/c/meterpreter/workspace/ext_server_python/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_python/CMakeLists.txt @@ -12,8 +12,11 @@ add_definitions( -D_USRDLL -DPy_ENABLE_SHARED -DPy_BUILD_CORE + -D_CRT_SECURE_NO_WARNINGS ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) include_directories(../../source/extensions/python/include) diff --git a/c/meterpreter/workspace/ext_server_sniffer/CMakeLists.txt b/c/meterpreter/workspace/ext_server_sniffer/CMakeLists.txt index ac9601e2..b37fd540 100644 --- a/c/meterpreter/workspace/ext_server_sniffer/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_sniffer/CMakeLists.txt @@ -10,6 +10,8 @@ add_definitions( -D_UNICODE ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) include_directories(${PSSDK_DIR}/_include) diff --git a/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt index 46ce5b82..307ea679 100644 --- a/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt @@ -8,8 +8,12 @@ add_definitions( -D_USRDLL -DCINTERFACE -DCOBJMACROS + -D_CRT_SECURE_NO_WARNINGS ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/jpeg-8) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt b/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt index f02e1e8d..023f63c9 100644 --- a/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt @@ -8,6 +8,8 @@ add_definitions( -D_USRDLL ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt index ffc3b4b4..3d66400f 100644 --- a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt +++ b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt @@ -10,6 +10,8 @@ add_definitions( -D_UNICODE ) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/jpeg/CMakeLists.txt b/c/meterpreter/workspace/jpeg/CMakeLists.txt index 181a3acf..86c09596 100644 --- a/c/meterpreter/workspace/jpeg/CMakeLists.txt +++ b/c/meterpreter/workspace/jpeg/CMakeLists.txt @@ -4,10 +4,11 @@ project(${PROJECT_NAME} C) add_definitions( -D_LIB - -DUNICODE - -D_UNICODE + -D_CRT_SECURE_NO_WARNINGS ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GF /Gy /TP /MP") + set(SRC_DIR ../../source/jpeg-8) set( SRC_FILES diff --git a/c/meterpreter/workspace/make.bat b/c/meterpreter/workspace/make.bat index 5ad33dee..de420399 100644 --- a/c/meterpreter/workspace/make.bat +++ b/c/meterpreter/workspace/make.bat @@ -7,16 +7,29 @@ SET PTS_VER=v141_xp SET BUILD_64=Y SET BUILD_86=Y SET SNIFFER=OFF +SET DBGTRACE=OFF +SET DBGTRACE_VERBOSE=OFF +set DO_BUILD=Y IF EXIST "..\..\..\..\pssdk\PSSDK_VC%PSSDK_VER%_LIB\_Libs\pssdk_vc%PSSDK_VER%_mt.lib" SET SNIFFER=ON +IF "%1" == "NOBUILD" SET DO_BUILD=N +IF "%2" == "NOBUILD" SET DO_BUILD=N +IF "%3" == "NOBUILD" SET DO_BUILD=N +IF "%4" == "NOBUILD" SET DO_BUILD=N +IF "%5" == "NOBUILD" SET DO_BUILD=N + IF "%1" == "v120_xp" SET PTS_VER=%1 IF "%2" == "v120_xp" SET PTS_VER=%2 IF "%3" == "v120_xp" SET PTS_VER=%3 +IF "%4" == "v120_xp" SET PTS_VER=%4 +IF "%5" == "v120_xp" SET PTS_VER=%5 IF "%1" == "VS2013" SET VS_VER=%1 IF "%2" == "VS2013" SET VS_VER=%2 IF "%3" == "VS2013" SET VS_VER=%3 +IF "%4" == "VS2013" SET VS_VER=%4 +IF "%5" == "VS2013" SET VS_VER=%5 REM If VS2013 is used, we have to stick to v121_xp IF "%VS_VER%" == "VS2013" ( @@ -27,23 +40,49 @@ IF "%VS_VER%" == "VS2013" ( IF "%1" == "x86" SET BUILD_64=N IF "%2" == "x86" SET BUILD_64=N IF "%3" == "x86" SET BUILD_64=N +IF "%4" == "x86" SET BUILD_64=N +IF "%5" == "x86" SET BUILD_64=N + IF "%1" == "x64" SET BUILD_86=N IF "%2" == "x64" SET BUILD_86=N IF "%3" == "x64" SET BUILD_86=N +IF "%4" == "x64" SET BUILD_86=N +IF "%5" == "x64" SET BUILD_86=N +IF "%1" == "DBGTRACE" SET DBGTRACE=ON +IF "%2" == "DBGTRACE" SET DBGTRACE=ON +IF "%3" == "DBGTRACE" SET DBGTRACE=ON +IF "%4" == "DBGTRACE" SET DBGTRACE=ON +IF "%5" == "DBGTRACE" SET DBGTRACE=ON + +IF "%1" == "DBGTRACE_VERBOSE" SET DBGTRACE_VERBOSE=ON +IF "%2" == "DBGTRACE_VERBOSE" SET DBGTRACE_VERBOSE=ON +IF "%3" == "DBGTRACE_VERBOSE" SET DBGTRACE_VERBOSE=ON +IF "%4" == "DBGTRACE_VERBOSE" SET DBGTRACE_VERBOSE=ON +IF "%5" == "DBGTRACE_VERBOSE" SET DBGTRACE_VERBOSE=ON IF "%BUILD_64%" == "Y" ( - @ECHO ========================================================================== - @ECHO == Building for "%VS_TITLE%" with %PTS_VER% for arch x64 - @ECHO ========================================================================== - cmake -G "%VS_TITLE%" -A x64 -T %PTS_VER% -S . -B build\%VS_VER%\x64 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% - cmake --build build\%VS_VER%\x64 --config Release --clean-first -- /p:XPDeprecationWarning=false + @ECHO ==================================================================================== + @ECHO == Generating "%VS_TITLE%" w/ %PTS_VER% on x64 - TRACE "%DBGTRACE%-%DBGTRACE_VERBOSE%" + @ECHO ==================================================================================== + cmake -G "%VS_TITLE%" -A x64 -T %PTS_VER% -S . -B build\%VS_VER%\x64 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% -DDBGTRACE=%DBGTRACE% -DDBGTRACE_VERBOSE=%DBGTRACE_VERBOSE% + if "%DO_BUILD%" == "Y" ( + @ECHO ==================================================================================== + @ECHO == Building "%VS_TITLE%" w/ %PTS_VER% on x64 - TRACE "%DBGTRACE%-%DBGTRACE_VERBOSE%" + @ECHO ==================================================================================== + cmake --build build\%VS_VER%\x64 --config Release --clean-first -- /p:XPDeprecationWarning=false + ) ) IF "%BUILD_86%" == "Y" ( - @ECHO ========================================================================== - @ECHO == Building for "%VS_TITLE%" with %PTS_VER% for arch x86 - @ECHO ========================================================================== - cmake -G "%VS_TITLE%" -A Win32 -T %PTS_VER% -S . -B build\%VS_VER%\Win32 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% - cmake --build build\%VS_VER%\Win32 --config Release --clean-first -- /p:XPDeprecationWarning=false + @ECHO ==================================================================================== + @ECHO == Generating "%VS_TITLE%" w/ %PTS_VER% on x86 - TRACE "%DBGTRACE%-%DBGTRACE_VERBOSE%" + @ECHO ==================================================================================== + cmake -G "%VS_TITLE%" -A Win32 -T %PTS_VER% -S . -B build\%VS_VER%\Win32 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% -DDBGTRACE=%DBGTRACE% -DDBGTRACE_VERBOSE=%DBGTRACE_VERBOSE% + if "%DO_BUILD%" == "Y" ( + @ECHO ==================================================================================== + @ECHO == Building "%VS_TITLE%" w/ %PTS_VER% on x86 - TRACE "%DBGTRACE%-%DBGTRACE_VERBOSE%" + @ECHO ==================================================================================== + cmake --build build\%VS_VER%\Win32 --config Release --clean-first -- /p:XPDeprecationWarning=false + ) ) diff --git a/c/meterpreter/workspace/metsrv/CMakeLists.txt b/c/meterpreter/workspace/metsrv/CMakeLists.txt index 66f9c7b7..d8bc016d 100644 --- a/c/meterpreter/workspace/metsrv/CMakeLists.txt +++ b/c/meterpreter/workspace/metsrv/CMakeLists.txt @@ -8,8 +8,11 @@ add_definitions( -D_USRDLL -DUNICODE -D_UNICODE + -D_CRT_SECURE_NO_WARNINGS ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/screenshot/CMakeLists.txt b/c/meterpreter/workspace/screenshot/CMakeLists.txt index a606de5a..38ad3089 100644 --- a/c/meterpreter/workspace/screenshot/CMakeLists.txt +++ b/c/meterpreter/workspace/screenshot/CMakeLists.txt @@ -6,10 +6,10 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt) add_definitions( -D_USRDLL - -DUNICODE - -D_UNICODE ) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + include_directories(../../source/common) include_directories(../../source/jpeg-8) include_directories(../../source/ReflectiveDllInjection/common) diff --git a/c/meterpreter/workspace/screenshot/screenshot.vcxproj b/c/meterpreter/workspace/screenshot/screenshot.vcxproj index fe583765..e5b795dc 100644 --- a/c/meterpreter/workspace/screenshot/screenshot.vcxproj +++ b/c/meterpreter/workspace/screenshot/screenshot.vcxproj @@ -87,7 +87,7 @@ OnlyExplicitInline false Size - ..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SCREENSHOT_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded @@ -130,7 +130,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\" OnlyExplicitInline false Size - ..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SCREENSHOT_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded @@ -176,7 +176,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\" OnlyExplicitInline false Size - ..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SCREENSHOT_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded @@ -221,7 +221,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\" OnlyExplicitInline false Size - ..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) + ..\..\source\common;..\..\source\ReflectiveDLLInjection\common;..\..\source\jpeg-8;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;SCREENSHOT_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded