506a4d9e67
As per discussion on the github issue, the following changes were made: * Project renamed from elevate to kitrap0d, implying that this is not intended to be a generic local priv esc exploit container. * Container DLL no longer generic, always calls the kitrap0d exploit. * Removal of all x64 code and project configurations. * Invocation of the exploit changed so that the address of the payload is passed in to the exploit entry point. The exploit is now responsible for executing the payload if the exploit is successful. This removes the possibility of the payload getting executed when the exploit fails. * Source moved to the appropriate CVE folder. * Binary moved to the appropriate CVE folder. * Little bit of source rejigging to tidy things up.
46 lines
2.1 KiB
C
46 lines
2.1 KiB
C
#ifndef _ESCALATE_COMMON_H
|
|
#define _ESCALATE_COMMON_H
|
|
|
|
/*! @brief When defined, debug output is enabled on Windows builds. */
|
|
//#define DEBUGTRACE 1
|
|
|
|
#ifdef DEBUGTRACE
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#define dprintf(...) real_dprintf(__VA_ARGS__)
|
|
#else
|
|
#define dprintf(...) do{}while(0);
|
|
#endif
|
|
|
|
/*! @brief Sets `dwResult` to the return value of `GetLastError()`, prints debug output, then does `break;` */
|
|
#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }
|
|
/*! @brief Sets `dwResult` to `error`, prints debug output, then `break;` */
|
|
#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d", str, dwResult ); break; }
|
|
/*! @brief Sets `dwResult` to the return value of `WASGetLastError()`, prints debug output, then does `break;` */
|
|
#define BREAK_ON_WSAERROR( str ) { dwResult = WSAGetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }
|
|
/*! @brief Sets `dwResult` to the return value of `GetLastError()`, prints debug output, then does `continue;` */
|
|
#define CONTINUE_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); continue; }
|
|
|
|
/*! @brief Close a service handle if not already closed and set the handle to NULL. */
|
|
#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; }
|
|
|
|
#ifdef DEBUGTRACE
|
|
/*!
|
|
* @brief Output a debug string to the debug console.
|
|
* @details The function emits debug strings via `OutputDebugStringA`, hence all messages can be viewed
|
|
* using Visual Studio's _Output_ window, _DebugView_ from _SysInternals_, or _Windbg_.
|
|
*/
|
|
static 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);
|
|
}
|
|
#endif
|
|
|
|
#endif |