diff --git a/docs/CHANGELOG.MD b/docs/CHANGELOG.MD index 45f33bce..51a56d87 100644 --- a/docs/CHANGELOG.MD +++ b/docs/CHANGELOG.MD @@ -4,6 +4,13 @@ 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.9.1 - 2020-09-23 + +### Fixed + +- Modules were not sending the first value from the modules commands section +- [Pull 97](https://github.com/Ne0nd0g/merlin/pull/97) - Incorrectly validated the module and agent platforms when the agent was set to "all" + ## 0.9.0 - 2020-09-13 ### Added diff --git a/pkg/api/agents/agents.go b/pkg/api/agents/agents.go index 48b9dbb3..edae617f 100644 --- a/pkg/api/agents/agents.go +++ b/pkg/api/agents/agents.go @@ -59,6 +59,7 @@ func CD(agentID uuid.UUID, Args []string) messages.UserMessage { // CMD is used to send a command to the agent to run a command or execute a program // Args[0] = "cmd" // Args[1:] = program and arguments to be executed on the host OS of the running agent +// Used with `cmd` and `shell` commands as well as through "standard" modules func CMD(agentID uuid.UUID, Args []string) messages.UserMessage { if len(Args) > 0 { job, err := agents.AddJob(agentID, "cmd", Args[1:]) diff --git a/pkg/api/modules/modules.go b/pkg/api/modules/modules.go index 3ebdb9b8..f4a43354 100644 --- a/pkg/api/modules/modules.go +++ b/pkg/api/modules/modules.go @@ -68,7 +68,7 @@ func RunModule(module modules.Module) []messages.UserMessage { } for id := range agents.Agents { // Make sure OS platform match - if strings.EqualFold(agents.Agents[id].Platform, module.Platform) { + if !strings.EqualFold(agents.Agents[id].Platform, module.Platform) { m := fmt.Sprintf("Module platform %s does not match agent %s platform %s. Skipping job...", module.Platform, id, agents.Agents[id].Platform) um := messages.UserMessage{ @@ -82,7 +82,8 @@ func RunModule(module modules.Module) []messages.UserMessage { } switch strings.ToLower(module.Type) { case "standard": - returnMessages = append(returnMessages, agentAPI.CMD(id, r)) + // Standard modules use the `cmd` message type that must be in position 0 + returnMessages = append(returnMessages, agentAPI.CMD(id, append([]string{"cmd"}, r...))) case "extended": // Was using Method: r[0] job, err := agents.AddJob(id, r[0], r[1:]) @@ -98,11 +99,12 @@ func RunModule(module modules.Module) []messages.UserMessage { } } return returnMessages - // Single Agent } + // Single Agent switch strings.ToLower(module.Type) { case "standard": - returnMessages = append(returnMessages, agentAPI.CMD(module.Agent, r)) + // Standard modules use the `cmd` message type that must be in position 0 + returnMessages = append(returnMessages, agentAPI.CMD(module.Agent, append([]string{"cmd"}, r...))) case "extended": job, err := agents.AddJob(module.Agent, r[0], r[1:]) if err != nil { diff --git a/pkg/merlin.go b/pkg/merlin.go index 2b17c420..f563a778 100644 --- a/pkg/merlin.go +++ b/pkg/merlin.go @@ -18,7 +18,7 @@ package merlin // Version is a constant variable containing the version number for the Merlin package -const Version = "0.9.0-beta" +const Version = "0.9.1-beta" // Build is the unique number based off the git commit in which it is compiled against var Build = "nonRelease"