Adds a remote shutdown api

git-svn-id: file:///home/svn/framework3/trunk@13050 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2011-06-28 18:11:17 +00:00
parent b53d23ebac
commit 80643cc152
3 changed files with 36 additions and 1 deletions

View File

@ -14,6 +14,8 @@ extern DWORD remote_request_core_channel_interact(Remote *remote, Packet *packet
extern DWORD remote_request_core_crypto_negotiate(Remote *remote, Packet *packet);
extern DWORD remote_request_core_shutdown(Remote *remote, Packet *packet);
extern DWORD remote_request_core_migrate(Remote *remote, Packet *packet);
// Local remote response implementors
@ -100,6 +102,12 @@ Command commands[] =
{ EMPTY_DISPATCH_HANDLER },
},
// Shutdown
{ "core_shutdown",
{ remote_request_core_shutdown, { 0 }, 0 },
{ EMPTY_DISPATCH_HANDLER },
},
// Terminator
{ NULL,
{ NULL, { 0 }, 0 },

View File

@ -1,5 +1,8 @@
#include "common.h"
// An external reference to the meterpreters main server thread, so we can shutdown gracefully after successfull migration.
extern THREAD * serverThread;
/*
* core_channel_open
* -----------------
@ -604,3 +607,27 @@ DWORD remote_request_core_crypto_negotiate(Remote *remote, Packet *packet)
return ERROR_SUCCESS;
}
/*
* core_shutdown
* -----------------
*
*/
DWORD remote_request_core_shutdown(Remote *remote, Packet *packet)
{
Channel *channel = NULL;
Packet *response = packet_create_response(packet);
DWORD result = ERROR_SUCCESS;
// Acknowledge the shutdown request
packet_add_tlv_bool(response, TLV_TYPE_BOOL, TRUE);
// Transmit the response
packet_transmit_response(result, remote, response);
dprintf("[SHUTDOWN] Shutting down the Meterpreter thread 1 (killing the main thread)...");
thread_kill( serverThread );
return result;
}

View File

@ -75,7 +75,7 @@ void real_dprintf(char *filename, int line, const char *function, char *format,
#define METERPRETER_TRANSPORT_HTTPS 2
// Enable debugging
//#define DEBUGTRACE 1
// #define DEBUGTRACE 1
#ifdef DEBUGTRACE
#define dprintf(...) real_dprintf(__VA_ARGS__)