From 96563b2978e56b9097b3c497da4c57a3b6d75a7c Mon Sep 17 00:00:00 2001 From: its-a-feature Date: Sun, 28 Jan 2024 16:46:12 -0800 Subject: [PATCH] updated mythic-cli better mythic-cli support for mythic_graphql volumes --- Mythic_CLI/Changelog.md | 14 +++++++++++++ Mythic_CLI/src/cmd/config/vars.go | 2 +- .../src/cmd/internal/serviceMetadata.go | 21 ++++++++++++------- .../src/cmd/manager/dockerComposeManager.go | 20 ++++++++++++++++-- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/Mythic_CLI/Changelog.md b/Mythic_CLI/Changelog.md index dac352c20..06a217bf2 100644 --- a/Mythic_CLI/Changelog.md +++ b/Mythic_CLI/Changelog.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.2.5 - 2024-01-28 + +### Changed + +- Removed the usage of the volume container for `mythic_graphql` + - Existing volumes for mythic_graphql break new updates since the old volume information is used + +## 0.2.4 - 2024-01-28 + +### Changed + +- Refactored to allow multiple kinds of managers for Mythic (defaults to `Docker`) +- Added volume support + ## 0.2.3 - 2023-12-27 ### Changed diff --git a/Mythic_CLI/src/cmd/config/vars.go b/Mythic_CLI/src/cmd/config/vars.go index 8c01d12c1..a3e511d14 100644 --- a/Mythic_CLI/src/cmd/config/vars.go +++ b/Mythic_CLI/src/cmd/config/vars.go @@ -4,5 +4,5 @@ package config var ( // Version Mythic CLI version - Version = "v0.2.4" + Version = "v0.2.5" ) diff --git a/Mythic_CLI/src/cmd/internal/serviceMetadata.go b/Mythic_CLI/src/cmd/internal/serviceMetadata.go index 5c1635425..0e67c69c9 100644 --- a/Mythic_CLI/src/cmd/internal/serviceMetadata.go +++ b/Mythic_CLI/src/cmd/internal/serviceMetadata.go @@ -157,15 +157,22 @@ func AddMythicService(service string) { "./hasura-docker/metadata:/metadata", } } else { - pStruct["volumes"] = []string{ - "mythic_graphql_volume:/metadata", - } + delete(pStruct, "volumes") + /* + pStruct["volumes"] = []string{ + "mythic_graphql_volume:/metadata", + } + + */ } - if _, ok := volumes["mythic_graphql"]; !ok { - volumes["mythic_graphql_volume"] = map[string]interface{}{ - "name": "mythic_graphql_volume", + /* + if _, ok := volumes["mythic_graphql"]; !ok { + volumes["mythic_graphql_volume"] = map[string]interface{}{ + "name": "mythic_graphql_volume", + } } - } + + */ case "mythic_nginx": if mythicEnv.GetBool("nginx_use_build_context") { pStruct["build"] = map[string]interface{}{ diff --git a/Mythic_CLI/src/cmd/manager/dockerComposeManager.go b/Mythic_CLI/src/cmd/manager/dockerComposeManager.go index 88b234419..01354c9e5 100644 --- a/Mythic_CLI/src/cmd/manager/dockerComposeManager.go +++ b/Mythic_CLI/src/cmd/manager/dockerComposeManager.go @@ -927,12 +927,28 @@ func (d *DockerComposeManager) RemoveVolume(volumeName string) error { } for _, currentVolume := range volumes.Volumes { if currentVolume.Name == volumeName { - err = cli.VolumeRemove(ctx, currentVolume.Name, true) + containers, err := cli.ContainerList(ctx, types.ContainerListOptions{Size: true}) if err != nil { - return err + log.Fatalf("[-] Failed to get container list: %v\n", err) } + for _, c := range containers { + for _, m := range c.Mounts { + if m.Name == volumeName { + containerName := c.Labels["name"] + err = cli.ContainerRemove(ctx, c.ID, types.ContainerRemoveOptions{Force: true}) + if err != nil { + log.Printf(fmt.Sprintf("[!] Failed to remove container that's using the volume: %v\n", err)) + } else { + log.Printf("[+] Removed container %s, which was using that container", containerName) + } + } + } + } + err = cli.VolumeRemove(ctx, currentVolume.Name, true) + return err } } + log.Printf("[*] Volume not found") return nil } func (d *DockerComposeManager) CopyIntoVolume(sourceFile io.Reader, destinationFileName string, destinationVolume string) {