Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/nslookup/nslookup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package nslookup

import (
"encoding/json"
"errors"
"net"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
)

type Arguments struct {
Type string `json:"type"`
Address string `json:"address"`
}

func Run(task structs.Task) {
msg := task.NewResponse()
var args Arguments

err := json.Unmarshal([]byte(task.Params), &args)
if err != nil {
msg.SetError(err.Error())
task.Job.SendResponses <- msg
return
}
address := args.Address
reqType := args.Type

var result any

if reqType == "A" {
result, err = net.LookupHost(address)
} else if reqType == "PTR" {
result, err = net.LookupAddr(address)
} else if reqType == "TXT" {
result, err = net.LookupTXT(address)
} else if reqType == "MX" {
result, err = net.LookupMX(address)
} else if reqType == "CNAME" {
result, err = net.LookupCNAME(address)
} else if reqType == "NS" {
result, err = net.LookupNS(address)
} else {
err = errors.New("invalid request type")
}

if err != nil {
msg.SetError(err.Error())
} else {
data, _ := json.Marshal(result)
msg.UserOutput = string(data)
msg.Completed = true
}
task.Job.SendResponses <- msg
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/lsopen"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/mkdir"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/mv"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/nslookup"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/persist_launchd"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/persist_loginitem"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/runtimeMainThread"
Expand Down Expand Up @@ -201,6 +202,8 @@ func listenForNewTask() {
go ifconfig.Run(task)
case "caffeinate":
go caffeinate.Run(task)
case "nslookup":
go nslookup.Run(task)
case "lsopen":
go lsopen.Run(task)
case "chmod":
Expand Down
67 changes: 67 additions & 0 deletions Payload_Type/poseidon/poseidon/agentfunctions/nslookup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package agentfunctions

import (
"errors"

agentstructs "github.com/MythicMeta/MythicContainer/agent_structs"
)

func init() {
agentstructs.AllPayloadData.Get("poseidon").AddCommand(agentstructs.Command{
Name: "nslookup",
Description: "resolve using the local resolver",
HelpString: "nslookup A domain.local",
Version: 1,
Author: "",
MitreAttackMappings: []string{},
SupportedUIFeatures: []string{},
CommandAttributes: agentstructs.CommandAttribute{
SupportedOS: []string{},
},
CommandParameters: []agentstructs.CommandParameter{
{
Name: "address",
ModalDisplayName: "Hostname or address to resolve",
ParameterType: agentstructs.COMMAND_PARAMETER_TYPE_STRING,
ParameterGroupInformation: []agentstructs.ParameterGroupInfo{
{
ParameterIsRequired: true,
UIModalPosition: 1,
},
},
Description: "Hostname or address to resolve",
},
{
Name: "type",
DefaultValue: "A",
ModalDisplayName: "Type of request",
ParameterType: agentstructs.COMMAND_PARAMETER_TYPE_CHOOSE_ONE,
Choices: []string{"A", "PTR", "MX", "TXT", "CNAME", "NS"},
ParameterGroupInformation: []agentstructs.ParameterGroupInfo{
{
ParameterIsRequired: false,
UIModalPosition: 2,
},
},
Description: "Type of request",
},
},
TaskFunctionCreateTasking: func(taskData *agentstructs.PTTaskMessageAllData) agentstructs.PTTaskCreateTaskingMessageResponse {
response := agentstructs.PTTaskCreateTaskingMessageResponse{
Success: true,
TaskID: taskData.Task.ID,
}
return response
},
TaskFunctionParseArgDictionary: func(args *agentstructs.PTTaskMessageArgsData, input map[string]interface{}) error {
return args.LoadArgsFromDictionary(input)
},
TaskFunctionParseArgString: func(args *agentstructs.PTTaskMessageArgsData, input string) error {
if len(input) > 0 {
return args.LoadArgsFromJSONString(input)
} else {
return errors.New("Must supply arguments")
}
},
})
}