mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-02-28 06:13:03 +01:00
Land #129 : real_printf rework
This commit is contained in:
commit
aab29f8605
@ -17,7 +17,7 @@ int current_unix_timestamp(void) {
|
||||
|
||||
GetSystemTime(&system_time);
|
||||
SystemTimeToFileTime(&system_time, &file_time);
|
||||
|
||||
|
||||
ularge.LowPart = file_time.dwLowDateTime;
|
||||
ularge.HighPart = file_time.dwHighDateTime;
|
||||
return (long)((ularge.QuadPart - 116444736000000000) / 10000000L);
|
||||
@ -47,11 +47,7 @@ int current_unix_timestamp(void) {
|
||||
int debugging_enabled;
|
||||
|
||||
/*!
|
||||
* @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_.
|
||||
* @remark If we supply real_dprintf in the common.h, each .o file will have a private copy of that symbol.
|
||||
* This leads to bloat. Defining it here means that there will only be a single implementation of it.
|
||||
* @brief Writes debug to a temporary file based on the current PID.
|
||||
*/
|
||||
void real_dprintf(char *filename, int line, const char *function, char *format, ...)
|
||||
{
|
||||
@ -73,9 +69,9 @@ retry_log:
|
||||
if(fd <= 0) {
|
||||
char filename[128];
|
||||
sprintf(filename, "/tmp/meterpreter.log.%d%s", getpid(), retried ? ".retry" : "" );
|
||||
|
||||
|
||||
fd = open(filename, O_RDWR|O_TRUNC|O_CREAT|O_SYNC, 0644);
|
||||
|
||||
|
||||
if(fd <= 0) return;
|
||||
}
|
||||
|
||||
|
@ -190,13 +190,12 @@ void real_dprintf(char *filename, int line, const char *function, char *format,
|
||||
/*! @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, ...) {
|
||||
static _inline void real_dprintf(char *format, ...) {
|
||||
va_list args;
|
||||
char buffer[1024];
|
||||
va_start(args,format);
|
||||
@ -204,7 +203,6 @@ static void real_dprintf(char *format, ...) {
|
||||
strcat_s(buffer, sizeof(buffer), "\r\n");
|
||||
OutputDebugStringA(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define dprintf(...) do{}while(0);
|
||||
#endif
|
||||
|
||||
static void real_dprintf(char *format, ...) {
|
||||
static _inline void real_dprintf(char *format, ...) {
|
||||
va_list args;
|
||||
char buffer[1024];
|
||||
va_start(args,format);
|
||||
@ -32,4 +32,4 @@ static void real_dprintf(char *format, ...) {
|
||||
typedef BOOL (WINAPI * CHECKTOKENMEMBERSHIP)( HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember );
|
||||
typedef HANDLE (WINAPI * OPENTHREAD)( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId );
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -22,8 +22,7 @@
|
||||
/*! @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 KIWIDEBUGTRACE
|
||||
static void real_dprintf(wchar_t *format, ...) {
|
||||
static _inline void real_dprintf(wchar_t *format, ...) {
|
||||
va_list args;
|
||||
wchar_t buffer[1024];
|
||||
va_start(args,format);
|
||||
@ -31,5 +30,3 @@ static void real_dprintf(wchar_t *format, ...) {
|
||||
wcscat_s(buffer, sizeof(buffer), L"\r\n");
|
||||
OutputDebugStringW(buffer);
|
||||
}
|
||||
|
||||
#endif
|
@ -14,7 +14,7 @@
|
||||
#define dprintf(...) do{}while(0);
|
||||
#endif
|
||||
|
||||
static void real_dprintf(char *format, ...) {
|
||||
static _inline void real_dprintf(char *format, ...) {
|
||||
va_list args;
|
||||
char buffer[1024];
|
||||
va_start(args,format);
|
||||
@ -32,4 +32,4 @@ static void real_dprintf(char *format, ...) {
|
||||
typedef BOOL (WINAPI * CHECKTOKENMEMBERSHIP)( HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember );
|
||||
typedef HANDLE (WINAPI * OPENTHREAD)( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId );
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user