From ab3e0581c443eeceefeefd1facd73b4da7169b53 Mon Sep 17 00:00:00 2001 From: its-a-feature Date: Sat, 20 Jan 2024 21:17:32 -0600 Subject: [PATCH] updating mythic-cli to reflect .env changes for 3rd party services --- Mythic_CLI/src/cmd/internal/serviceExecution.go | 11 ++++++++++- Mythic_CLI/src/cmd/internal/serviceMetadata.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Mythic_CLI/src/cmd/internal/serviceExecution.go b/Mythic_CLI/src/cmd/internal/serviceExecution.go index 42a0bc97f..29098c2d6 100644 --- a/Mythic_CLI/src/cmd/internal/serviceExecution.go +++ b/Mythic_CLI/src/cmd/internal/serviceExecution.go @@ -67,9 +67,12 @@ func ServiceStart(containers []string) error { finalContainers = append(finalContainers, val) } } + // make sure we always update the config when starting in case .env variables changed for _, service := range finalContainers { if utils.StringInSlice(service, config.MythicPossibleServices) { AddMythicService(service) + } else { + Add3rdPartyService(service, map[string]interface{}{}) } } manager.GetManager().TestPorts(finalContainers) @@ -90,13 +93,19 @@ func ServiceStop(containers []string) error { return manager.GetManager().StopServices(containers, config.GetMythicEnv().GetBool("REBUILD_ON_START")) } func ServiceBuild(containers []string) error { + composeServices, err := manager.GetManager().GetAllInstalled3rdPartyServiceNames() + if err != nil { + log.Fatalf("[-] Failed to get installed service list: %v", err) + } for _, container := range containers { if utils.StringInSlice(container, config.MythicPossibleServices) { // update the necessary docker compose entries for mythic services AddMythicService(container) + } else if utils.StringInSlice(container, composeServices) { + Add3rdPartyService(container, map[string]interface{}{}) } } - err := manager.GetManager().BuildServices(containers) + err = manager.GetManager().BuildServices(containers) if err != nil { return err } diff --git a/Mythic_CLI/src/cmd/internal/serviceMetadata.go b/Mythic_CLI/src/cmd/internal/serviceMetadata.go index f1cb54fee..3b7ca0fd4 100644 --- a/Mythic_CLI/src/cmd/internal/serviceMetadata.go +++ b/Mythic_CLI/src/cmd/internal/serviceMetadata.go @@ -562,8 +562,8 @@ func Add3rdPartyService(service string, additionalConfigs map[string]interface{} if useBuildContext, ok := agentConfigs[agentUseBuildContextKey]; ok { if useBuildContext == "false" { delete(pStruct, "build") + pStruct["image"] = agentConfigs[agentRemoteImageKey] } - pStruct["image"] = agentConfigs[agentRemoteImageKey] } if useVolume, ok := agentConfigs[agentUseVolumeKey]; ok { if useVolume == "true" {