mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-08 14:36:22 +01:00
a89d79d139
The goals of this work are: * To fix issue where backgrounding and re-interacting with channels wasn't working. * To fix issue where closing of meterpreter was not closing off background prcoesses (such as cmd.exe). The two things preventing this stuff from working were: * When interactive channels are backgrounded their handles were destroyed along with the context that wraps them up. Making them interactive again had no impact because the handle and context were invalid. If anything, this made meterpreter unstable. Sometimes the session would die when attempting to interact with the channel again. * When closing channels, there was no way of terminating the process that sat behind the scenes because no reference to the process was retained. Channels would close and handles would close, but no process termination was done. To fix these problems: * The interactive thread no longer terminates when backgrounded. Instead its put in a suspended state where it's waiting a signal from a resume handle that's associated with the channel's context. This means that the destruction of the context doesn't happen at all until the termination of the channel, which is exactly when it should happen anyway. * Process handles are stored alongside the input/output handles so that when the time comes, the process can be terminated if required. This means that when the channels are closed, the code has a reference to the associated process which can be terminated. This is only done for interactive processes, non-interactive processes do not have this problem because meterpreter doesn't have to keep track of them.
24 lines
758 B
C
24 lines
758 B
C
#ifndef _METERPRETER_LIB_SCHEDULER_H
|
|
#define _METERPRETER_LIB_SCHEDULER_H
|
|
|
|
#include "linkage.h"
|
|
#include "remote.h"
|
|
|
|
typedef enum
|
|
{
|
|
Pause = 1,
|
|
Resume = 2,
|
|
Stop = 3
|
|
} SchedularSignal;
|
|
|
|
typedef DWORD (*WaitableNotifyRoutine)(Remote *remote, LPVOID context);
|
|
typedef DWORD (*WaitableDestroyRoutine)(HANDLE waitable, LPVOID context);
|
|
|
|
LINKAGE DWORD scheduler_initialize( Remote * remote );
|
|
LINKAGE DWORD scheduler_destroy( VOID );
|
|
LINKAGE DWORD scheduler_insert_waitable( HANDLE waitable, LPVOID context, WaitableNotifyRoutine routine, WaitableDestroyRoutine destroy );
|
|
LINKAGE DWORD scheduler_signal_waitable( HANDLE waitable, SchedularSignal signal );
|
|
LINKAGE DWORD THREADCALL scheduler_waitable_thread( THREAD * thread );
|
|
|
|
#endif
|