mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-18 15:14:10 +01:00
Slight make tweak and removal of some verbose debug stuff
This commit is contained in:
parent
f54c8e2ccb
commit
4f8544cfca
@ -80,12 +80,12 @@ IF "%BUILD_64%" == "Y" (
|
|||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
@ECHO == Generating "%VS_TITLE%" w/ %PTS_VER% on x64 ^(Trace: %TRACE_MSG%^)
|
@ECHO == Generating "%VS_TITLE%" w/ %PTS_VER% on x64 ^(Trace: %TRACE_MSG%^)
|
||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
cmake -G "%VS_TITLE%" -A x64 -T %PTS_VER% -S workspace -B workspace\build\%VS_VER%\x64 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% -DDBGTRACE=%DBGTRACE% -DDBGTRACE_VERBOSE=%DBGTRACE_VERBOSE%
|
cmake -G "%VS_TITLE%" -A x64 -T %PTS_VER% -S workspace -B workspace\build\%VS_VER%_%PTS_VER%\x64 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% -DDBGTRACE=%DBGTRACE% -DDBGTRACE_VERBOSE=%DBGTRACE_VERBOSE%
|
||||||
if "%DO_BUILD%" == "Y" (
|
if "%DO_BUILD%" == "Y" (
|
||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
@ECHO == Building "%VS_TITLE%" w/ %PTS_VER% on x64
|
@ECHO == Building "%VS_TITLE%" w/ %PTS_VER% on x64
|
||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
cmake --build workspace\build\%VS_VER%\x64 --config Release --clean-first -- /p:XPDeprecationWarning=false
|
cmake --build workspace\build\%VS_VER%_%PTS_VER%\x64 --config Release --clean-first -- /p:XPDeprecationWarning=false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,12 +93,12 @@ IF "%BUILD_86%" == "Y" (
|
|||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
@ECHO == Generating "%VS_TITLE%" w/ %PTS_VER% on x86 ^(Trace: %TRACE_MSG%^)
|
@ECHO == Generating "%VS_TITLE%" w/ %PTS_VER% on x86 ^(Trace: %TRACE_MSG%^)
|
||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
cmake -G "%VS_TITLE%" -A Win32 -T %PTS_VER% -S workspace -B workspace\build\%VS_VER%\Win32 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% -DDBGTRACE=%DBGTRACE% -DDBGTRACE_VERBOSE=%DBGTRACE_VERBOSE%
|
cmake -G "%VS_TITLE%" -A Win32 -T %PTS_VER% -S workspace -B workspace\build\%VS_VER%_%PTS_VER%\Win32 -Wno-dev -DBUILD_SNIFFER=%SNIFFER% -DDBGTRACE=%DBGTRACE% -DDBGTRACE_VERBOSE=%DBGTRACE_VERBOSE%
|
||||||
if "%DO_BUILD%" == "Y" (
|
if "%DO_BUILD%" == "Y" (
|
||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
@ECHO == Building "%VS_TITLE%" w/ %PTS_VER% on x86
|
@ECHO == Building "%VS_TITLE%" w/ %PTS_VER% on x86
|
||||||
@ECHO ====================================================================================
|
@ECHO ====================================================================================
|
||||||
cmake --build workspace\build\%VS_VER%\Win32 --config Release --clean-first -- /p:XPDeprecationWarning=false
|
cmake --build workspace\build\%VS_VER%_%PTS_VER%\Win32 --config Release --clean-first -- /p:XPDeprecationWarning=false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -745,8 +745,6 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j
|
|||||||
cClrBits = 24;
|
cClrBits = 24;
|
||||||
else cClrBits = 32;
|
else cClrBits = 32;
|
||||||
|
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 1");
|
|
||||||
|
|
||||||
// Allocate memory for the BITMAPINFO structure. (This structure
|
// Allocate memory for the BITMAPINFO structure. (This structure
|
||||||
// contains a BITMAPINFOHEADER structure and an array of RGBQUAD
|
// contains a BITMAPINFOHEADER structure and an array of RGBQUAD
|
||||||
// data structures.)
|
// data structures.)
|
||||||
@ -800,7 +798,6 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 2");
|
|
||||||
hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
|
hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
|
||||||
// Compute the size of the entire file.
|
// Compute the size of the entire file.
|
||||||
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
|
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
|
||||||
@ -837,7 +834,6 @@ 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.
|
* We need to provide some value for jpeg_set_defaults() to work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 3");
|
|
||||||
cinfo.err = jpeg_std_error(&jerr);
|
cinfo.err = jpeg_std_error(&jerr);
|
||||||
jpeg_create_compress(&cinfo);
|
jpeg_create_compress(&cinfo);
|
||||||
cinfo.in_color_space = JCS_RGB; /* arbitrary guess */
|
cinfo.in_color_space = JCS_RGB; /* arbitrary guess */
|
||||||
@ -850,7 +846,6 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j
|
|||||||
/* Read the input file header to obtain file size & colorspace. */
|
/* Read the input file header to obtain file size & colorspace. */
|
||||||
|
|
||||||
start_input_bmp(&cinfo, src_mgr);
|
start_input_bmp(&cinfo, src_mgr);
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 4");
|
|
||||||
|
|
||||||
jpeg_default_colorspace(&cinfo);
|
jpeg_default_colorspace(&cinfo);
|
||||||
|
|
||||||
@ -858,18 +853,14 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j
|
|||||||
/* Go GRAYSCALE */
|
/* Go GRAYSCALE */
|
||||||
//jpeg_set_colorspace(&cinfo, JCS_GRAYSCALE);
|
//jpeg_set_colorspace(&cinfo, JCS_GRAYSCALE);
|
||||||
/* Quality */
|
/* Quality */
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 4A");
|
|
||||||
jpeg_set_quality(&cinfo, quality, FALSE);
|
jpeg_set_quality(&cinfo, quality, FALSE);
|
||||||
|
|
||||||
// Write the compressed JPEG to memory: bug_jpeg
|
// Write the compressed JPEG to memory: bug_jpeg
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 4B");
|
|
||||||
jpeg_mem_dest(&cinfo, buf_jpeg, buf_jpeg_size);
|
jpeg_mem_dest(&cinfo, buf_jpeg, buf_jpeg_size);
|
||||||
|
|
||||||
/* Start compressor */
|
/* Start compressor */
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 4C");
|
|
||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 5");
|
|
||||||
/* Process data */
|
/* Process data */
|
||||||
while (cinfo.next_scanline < cinfo.image_height) {
|
while (cinfo.next_scanline < cinfo.image_height) {
|
||||||
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
|
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
|
||||||
@ -877,13 +868,9 @@ int bmp2jpeg(HBITMAP hBmp, HDC hDC, int quality, BYTE ** buf_jpeg, DWORD * buf_j
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Finish compression and release memory */
|
/* Finish compression and release memory */
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 6");
|
|
||||||
(*src_mgr->finish_input) (&cinfo, src_mgr);
|
(*src_mgr->finish_input) (&cinfo, src_mgr);
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 7");
|
|
||||||
jpeg_finish_compress(&cinfo);
|
jpeg_finish_compress(&cinfo);
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 8");
|
|
||||||
jpeg_destroy_compress(&cinfo);
|
jpeg_destroy_compress(&cinfo);
|
||||||
dprintf("[SCREENSHOT bmptojpeg] Debug 9");
|
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
GlobalFree((HGLOBAL)lpBits);
|
GlobalFree((HGLOBAL)lpBits);
|
||||||
|
@ -83,9 +83,7 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
dprintf("[SCREENSHOT] Debug 1");
|
|
||||||
_snprintf_s(cNamedPipe, sizeof(cNamedPipe), MAX_PATH, "\\\\.\\pipe\\%08X", dwPipeName);
|
_snprintf_s(cNamedPipe, sizeof(cNamedPipe), MAX_PATH, "\\\\.\\pipe\\%08X", dwPipeName);
|
||||||
dprintf("[SCREENSHOT] Debug 2");
|
|
||||||
|
|
||||||
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
|
||||||
@ -93,7 +91,6 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
{
|
{
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot: GetVersionEx failed")
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot: GetVersionEx failed")
|
||||||
}
|
}
|
||||||
dprintf("[SCREENSHOT] Debug 3");
|
|
||||||
|
|
||||||
// On NT we cant use SM_CXVIRTUALSCREEN/SM_CYVIRTUALSCREEN.
|
// On NT we cant use SM_CXVIRTUALSCREEN/SM_CYVIRTUALSCREEN.
|
||||||
if (os.dwMajorVersion <= 4)
|
if (os.dwMajorVersion <= 4)
|
||||||
@ -102,15 +99,12 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
ymetric = SM_CYSCREEN;
|
ymetric = SM_CYSCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf("[SCREENSHOT] Debug 4");
|
|
||||||
// open the WinSta0 as some services are attached to a different window station.
|
// open the WinSta0 as some services are attached to a different window station.
|
||||||
hWindowStation = OpenWindowStationA("WinSta0", FALSE, WINSTA_ALL_ACCESS);
|
hWindowStation = OpenWindowStationA("WinSta0", FALSE, WINSTA_ALL_ACCESS);
|
||||||
dprintf("[SCREENSHOT] Debug 5");
|
|
||||||
if (!hWindowStation)
|
if (!hWindowStation)
|
||||||
{
|
{
|
||||||
if (RevertToSelf())
|
if (RevertToSelf())
|
||||||
{
|
{
|
||||||
dprintf("[SCREENSHOT] Debug 6");
|
|
||||||
hWindowStation = OpenWindowStationA("WinSta0", FALSE, WINSTA_ALL_ACCESS);
|
hWindowStation = OpenWindowStationA("WinSta0", FALSE, WINSTA_ALL_ACCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,44 +117,36 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
|
|
||||||
// get the current process's window station so we can restore it later on.
|
// get the current process's window station so we can restore it later on.
|
||||||
hOrigWindowStation = GetProcessWindowStation();
|
hOrigWindowStation = GetProcessWindowStation();
|
||||||
dprintf("[SCREENSHOT] Debug 7");
|
|
||||||
|
|
||||||
// set the host process's window station to this sessions default input station we opened
|
// set the host process's window station to this sessions default input station we opened
|
||||||
if (!SetProcessWindowStation(hWindowStation))
|
if (!SetProcessWindowStation(hWindowStation))
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot: SetProcessWindowStation failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot: SetProcessWindowStation failed");
|
||||||
|
|
||||||
// grab a handle to the default input desktop (e.g. Default or WinLogon)
|
// grab a handle to the default input desktop (e.g. Default or WinLogon)
|
||||||
dprintf("[SCREENSHOT] Debug 8");
|
|
||||||
hInputDesktop = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED);
|
hInputDesktop = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED);
|
||||||
if (!hInputDesktop)
|
if (!hInputDesktop)
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot: OpenInputDesktop failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot: OpenInputDesktop failed");
|
||||||
|
|
||||||
// get the threads current desktop so we can restore it later on
|
// get the threads current desktop so we can restore it later on
|
||||||
dprintf("[SCREENSHOT] Debug 9");
|
|
||||||
hOrigDesktop = GetThreadDesktop(GetCurrentThreadId());
|
hOrigDesktop = GetThreadDesktop(GetCurrentThreadId());
|
||||||
|
|
||||||
// set this threads desktop to that of this sessions default input desktop on WinSta0
|
// set this threads desktop to that of this sessions default input desktop on WinSta0
|
||||||
dprintf("[SCREENSHOT] Debug 10");
|
|
||||||
SetThreadDesktop(hInputDesktop);
|
SetThreadDesktop(hInputDesktop);
|
||||||
|
|
||||||
// and now we can grab a handle to this input desktop
|
// and now we can grab a handle to this input desktop
|
||||||
dprintf("[SCREENSHOT] Debug 11");
|
|
||||||
hDesktopWnd = GetDesktopWindow();
|
hDesktopWnd = GetDesktopWindow();
|
||||||
|
|
||||||
// and get a DC from it so we can read its pixels!
|
// and get a DC from it so we can read its pixels!
|
||||||
dprintf("[SCREENSHOT] Debug 12");
|
|
||||||
hdc = GetDC(hDesktopWnd);
|
hdc = GetDC(hDesktopWnd);
|
||||||
if (!hdc)
|
if (!hdc)
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot. GetDC failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot. GetDC failed");
|
||||||
|
|
||||||
// back up this DC with a memory DC
|
// back up this DC with a memory DC
|
||||||
dprintf("[SCREENSHOT] Debug 13");
|
|
||||||
hmemdc = CreateCompatibleDC(hdc);
|
hmemdc = CreateCompatibleDC(hdc);
|
||||||
if (!hmemdc)
|
if (!hmemdc)
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot. CreateCompatibleDC failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot. CreateCompatibleDC failed");
|
||||||
|
|
||||||
// calculate the width and height
|
// calculate the width and height
|
||||||
dprintf("[SCREENSHOT] Debug 14");
|
|
||||||
sx = GetSystemMetrics(xmetric);
|
sx = GetSystemMetrics(xmetric);
|
||||||
sy = GetSystemMetrics(ymetric);
|
sy = GetSystemMetrics(ymetric);
|
||||||
|
|
||||||
@ -168,20 +154,17 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
// prevent breaking functionality on <= NT 4.0
|
// prevent breaking functionality on <= NT 4.0
|
||||||
if (os.dwMajorVersion >= 4)
|
if (os.dwMajorVersion >= 4)
|
||||||
{
|
{
|
||||||
dprintf("[SCREENSHOT] Debug 14");
|
|
||||||
sxpos = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
sxpos = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
sypos = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
sypos = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// and create a bitmap
|
// and create a bitmap
|
||||||
dprintf("[SCREENSHOT] Debug 15");
|
|
||||||
hbmp = CreateCompatibleBitmap(hdc, sx, sy);
|
hbmp = CreateCompatibleBitmap(hdc, sx, sy);
|
||||||
if (!hbmp)
|
if (!hbmp)
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot. CreateCompatibleBitmap failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot. CreateCompatibleBitmap failed");
|
||||||
|
|
||||||
// this bitmap is backed by the memory DC
|
// this bitmap is backed by the memory DC
|
||||||
dprintf("[SCREENSHOT] Debug 16");
|
|
||||||
if (!SelectObject(hmemdc, hbmp))
|
if (!SelectObject(hmemdc, hbmp))
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot. SelectObject failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot. SelectObject failed");
|
||||||
|
|
||||||
@ -189,11 +172,9 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
// screenshot all available monitors by default
|
// screenshot all available monitors by default
|
||||||
|
|
||||||
HMODULE user32 = NULL;
|
HMODULE user32 = NULL;
|
||||||
dprintf("[SCREENSHOT] Debug 17");
|
|
||||||
if ((user32 = LoadLibraryA("user32")))
|
if ((user32 = LoadLibraryA("user32")))
|
||||||
{
|
{
|
||||||
|
|
||||||
dprintf("[SCREENSHOT] Debug 18");
|
|
||||||
FARPROC SPDA = GetProcAddress(user32, "SetProcessDPIAware");
|
FARPROC SPDA = GetProcAddress(user32, "SetProcessDPIAware");
|
||||||
if (SPDA)
|
if (SPDA)
|
||||||
{
|
{
|
||||||
@ -201,16 +182,13 @@ DWORD screenshot(int quality, DWORD dwPipeName)
|
|||||||
}
|
}
|
||||||
FreeLibrary(user32);
|
FreeLibrary(user32);
|
||||||
}
|
}
|
||||||
dprintf("[SCREENSHOT] Debug 19");
|
|
||||||
if (!StretchBlt(hmemdc, 0, 0, sx, sy, hdc, sxpos, sypos, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN), SRCCOPY))
|
if (!StretchBlt(hmemdc, 0, 0, sx, sy, hdc, sxpos, sypos, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN), SRCCOPY))
|
||||||
BREAK_ON_ERROR("[SCREENSHOT] screenshot. StretchBlt failed");
|
BREAK_ON_ERROR("[SCREENSHOT] screenshot. StretchBlt failed");
|
||||||
|
|
||||||
// finally convert the BMP we just made into a JPEG...
|
// finally convert the BMP we just made into a JPEG...
|
||||||
dprintf("[SCREENSHOT] Debug 20");
|
|
||||||
if (bmp2jpeg(hbmp, hmemdc, quality, &pJpegBuffer, &dwJpegSize) != 1)
|
if (bmp2jpeg(hbmp, hmemdc, quality, &pJpegBuffer, &dwJpegSize) != 1)
|
||||||
BREAK_WITH_ERROR("[SCREENSHOT] screenshot. bmp2jpeg failed", ERROR_INVALID_HANDLE);
|
BREAK_WITH_ERROR("[SCREENSHOT] screenshot. bmp2jpeg failed", ERROR_INVALID_HANDLE);
|
||||||
|
|
||||||
dprintf("[SCREENSHOT] Debug 21");
|
|
||||||
// we have succeded
|
// we have succeded
|
||||||
dwResult = ERROR_SUCCESS;
|
dwResult = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user