From 8bfc904dc61f3bc2761db0e3e78f102ed0359e9b Mon Sep 17 00:00:00 2001 From: its-a-feature Date: Fri, 5 Apr 2024 17:55:17 -0500 Subject: [PATCH] v3.2.20-rc8 fixing MythicRPC issue for generating payloads from scratch --- CHANGELOG.MD | 6 +++ VERSION | 2 +- ..._mythic_rpc_payload_create_from_scratch.go | 40 ++++++++++--------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 0b59d44f..fbd9f3ca 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.20-rc8] - 2024-04-05 + +### Changed + +- Fixed an RPC call for generating a new payload that wasn't calling the right function + ## [3.2.20-rc7] - 2024-03-29 ### Changed diff --git a/VERSION b/VERSION index 9e1c8355..7303c411 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.20-rc7 \ No newline at end of file +3.2.20-rc8 \ No newline at end of file diff --git a/mythic-docker/src/rabbitmq/recv_mythic_rpc_payload_create_from_scratch.go b/mythic-docker/src/rabbitmq/recv_mythic_rpc_payload_create_from_scratch.go index 76936b0c..41cecdf1 100644 --- a/mythic-docker/src/rabbitmq/recv_mythic_rpc_payload_create_from_scratch.go +++ b/mythic-docker/src/rabbitmq/recv_mythic_rpc_payload_create_from_scratch.go @@ -26,9 +26,9 @@ type MythicRPCPayloadCreateFromScratchMessageResponse struct { func init() { RabbitMQConnection.AddRPCQueue(RPCQueueStruct{ Exchange: MYTHIC_EXCHANGE, - Queue: MYTHIC_RPC_PAYLOAD_CREATE_FROM_SCRATCH, // swap out with queue in rabbitmq.constants.go file - RoutingKey: MYTHIC_RPC_PAYLOAD_CREATE_FROM_SCRATCH, // swap out with routing key in rabbitmq.constants.go file - Handler: processMythicRPCPayloadCreateFromUUID, // points to function that takes in amqp.Delivery and returns interface{} + Queue: MYTHIC_RPC_PAYLOAD_CREATE_FROM_SCRATCH, // swap out with queue in rabbitmq.constants.go file + RoutingKey: MYTHIC_RPC_PAYLOAD_CREATE_FROM_SCRATCH, // swap out with routing key in rabbitmq.constants.go file + Handler: processMythicRPCPayloadCreateFromScratch, // points to function that takes in amqp.Delivery and returns interface{} }) } @@ -38,38 +38,40 @@ func MythicRPCPayloadCreateFromScratch(input MythicRPCPayloadCreateFromScratchMe Success: false, } task := databaseStructs.Task{} - if err := database.DB.Get(&task, `SELECT operator_id, - callback.operation_id "callback.operation_id" + if err := database.DB.Get(&task, `SELECT + operator_id, operation_id FROM task - JOIN callback ON task.callback_id = callback.id WHERE id=$1`, input.TaskID); err != nil { logging.LogError(err, "Failed to get operator_id from task when generating payload") response.Error = err.Error() return response } - if newUUID, newID, err := RegisterNewPayload(input.PayloadConfiguration, &databaseStructs.Operatoroperation{ - CurrentOperation: databaseStructs.Operation{ID: task.Callback.OperationID}, + newUUID, newID, err := RegisterNewPayload(input.PayloadConfiguration, &databaseStructs.Operatoroperation{ + CurrentOperation: databaseStructs.Operation{ID: task.OperationID}, CurrentOperator: databaseStructs.Operator{ID: task.OperatorID}, - }); err != nil { + }) + if err != nil { response.Error = err.Error() return response - } else if _, err := database.DB.Exec(`UPDATE payload SET auto_generated=true WHERE id=$1`, newID); err != nil { + } + _, err = database.DB.Exec(`UPDATE payload SET auto_generated=true WHERE id=$1`, newID) + if err != nil { logging.LogError(err, "failed to update payload auto_generated status") response.Error = err.Error() return response - } else { - if input.RemoteHost != nil { - if _, err := database.DB.Exec(`INSERT INTO payloadonhost + } + if input.RemoteHost != nil { + if _, err := database.DB.Exec(`INSERT INTO payloadonhost (host, payload_id, operation_id, task_id) VALUES - ($1, $2, $3, $4)`, strings.ToUpper(*input.RemoteHost), newID, task.Callback.OperationID, input.TaskID); err != nil { - logging.LogError(err, "Failed to register payload on host") - } + ($1, $2, $3, $4)`, strings.ToUpper(*input.RemoteHost), newID, task.OperationID, input.TaskID); err != nil { + logging.LogError(err, "Failed to register payload on host") } - response.NewPayloadUUID = newUUID - response.Success = true - return response } + response.NewPayloadUUID = newUUID + response.Success = true + return response + } func processMythicRPCPayloadCreateFromScratch(msg amqp.Delivery) interface{} { incomingMessage := MythicRPCPayloadCreateFromScratchMessage{}