mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-24 18:16:24 +01:00

The 'common' library has been removed. The only project that actually used it was metsrv, so the code that metsrv required from common is now directly compiled in as part of that project. The common folder now contains files that are importanta cross all of the projects, with a primary focus on the new "API" style function. What this means is that MetSrv has an API that it exposes through a function pointer that is passed to the extension when it's initialised. This pointer references a structure with all the API functions wired in. This means that: * Extensions don't need to know anything about metsrv at compile time. * The delay loading code can be removed, which was one of the last instances of "metsrv.dll" as a string. * Metsrv.dll no longer exports any functions. More to come.
31 lines
1.2 KiB
C
31 lines
1.2 KiB
C
#include "metsrv.h"
|
|
#include "pivot_packet_dispatch.h"
|
|
|
|
DWORD THREADCALL pivot_packet_dispatch_thread(THREAD* thread)
|
|
{
|
|
dprintf("[PIVOTPACKETTHREAD] Dispatching packet on thread %p", thread);
|
|
PivotContext* pivotCtx = (PivotContext*)thread->parameter1;
|
|
LPBYTE packetBuffer = (LPBYTE)thread->parameter2;
|
|
DWORD packetSize = (DWORD)(DWORD_PTR)thread->parameter3;
|
|
DWORD result = pivotCtx->packet_write(pivotCtx->state, packetBuffer, packetSize);
|
|
dprintf("[PIVOTPACKETTHREAD] Packet dispatched: %u (%x)", result, result);
|
|
free(packetBuffer);
|
|
dprintf("[PIVOTPACKETTHREAD] Cleaning up the thread");
|
|
thread_destroy(thread);
|
|
dprintf("[PIVOTPACKETTHREAD] Done");
|
|
return result;
|
|
}
|
|
|
|
DWORD pivot_packet_dispatch(PivotContext* pivotCtx, LPBYTE packetBuffer, DWORD packetSize)
|
|
{
|
|
THREAD* thread = thread_create(pivot_packet_dispatch_thread, pivotCtx, packetBuffer, (LPVOID)(DWORD_PTR)packetSize);
|
|
if (thread)
|
|
{
|
|
dprintf("[PIVOTPACKET] Dispatching packet on new thread %p", thread);
|
|
thread_run(thread);
|
|
dprintf("[PIVOTPACKET] Thread invoked %p", thread);
|
|
return ERROR_SUCCESS;
|
|
}
|
|
dprintf("[PIVOTPACKET] Failed to create packet dispatch thread");
|
|
return ERROR_OUTOFMEMORY;
|
|
} |