Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rid of huge switch statement #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions Payload_Type/poseidon/poseidon/agent_code/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
HTTP_UUID=80844d19-9bfc-47f9-b9af-c6b9144c0fdc
HTTP_UUID=abd41870-7d6a-47ee-a11e-be026be4a005
HTTP_AGENT_CONFIG_FILE=test_agent_config_http.json
HTTP_CONFIG=$(shell base64 -i ${HTTP_AGENT_CONFIG_FILE})
HTTP_CONFIG=$(shell base64 -w0 -i ${HTTP_AGENT_CONFIG_FILE})

WEBSOCKET_UUID=80844d19-9bfc-47f9-b9af-c6b9144c0fdc
WEBSOCKET_AGENT_CONFIG_FILE=test_agent_config_websocket.json
Expand Down Expand Up @@ -133,4 +133,4 @@ clean_http:
go clean
rm ${BINARY_NAME}_${C2_HTTP}.bin
rm ${BINARY_NAME}_${C2_TCP}.bin
rm ${BINARY_NAME}_${C2_WEBSOCKET}.bin
rm ${BINARY_NAME}_${C2_WEBSOCKET}.bin
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("caffeinate", Run)
}

type CaffeinateRun interface {
Success() bool
Result() string
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/cat/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("cat", Run)
}

// Run - package function to run cat
func Run(task structs.Task) {
msg := task.NewResponse()
Expand Down
6 changes: 6 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/cd/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)


func init() {
library.RegisterTask("cd", Run)
}

// Run - package function to run cd
func Run(task structs.Task) {
err := os.Chdir(task.Params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("clipboard", Run)
}

type Arguments struct {
ReadTypes []string `json:"read"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import (

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/functions"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

type Arguments struct {
Duration int `json:"duration"`
}

func init() {
library.RegisterTask("clipboard_monitor", Run)
}

func Run(task structs.Task) {
msg := task.NewResponse()
params := Arguments{}
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ import (
"encoding/json"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/functions"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("config", Run)
}

// Run - Function that executes the shell command
func Run(task structs.Task) {
msg := task.NewResponse()
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/cp/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("cp", Run)
}

type Arguments struct {
SourceFile string `json:"source"`
DestinationFile string `json:"destination"`
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/curl/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("curl", Run)
}

type Arguments struct {
Url string `json:"url"`
Method string `json:"method"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("curl", Run)
}

// Run - Function that executes the shell command
func Run(task structs.Task) {
//File download
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/drives/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("drives", Run)
}

type Drive struct {
Name string `json:"name"`
Description string `json:"description"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("execute_library", Run)
}

type executeLibraryArgs struct {
FileID string `json:"file_id"`
FilePath string `json:"file_path"`
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/getenv/getenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("getenv", Run)
}

// Run - Function that executes the shell command
func Run(task structs.Task) {
msg := task.NewResponse()
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/getuser/getuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("getuser", Run)
}

type SerializableUser struct {
// Uid is the user ID.
// On POSIX systems, this is a decimal number representing the uid.
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/head/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ import (
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"io"
"os"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("head", Run)
}

type headArgs struct {
FilePath string `json:"path"`
Lines int `json:"lines"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("ifconfig", Run)
}

// Run - Function that executes
func Run(task structs.Task) {
msg := task.NewResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("jsimport", Run)
}

// initial .m code pulled from https://github.com/its-a-feature/macos_execute_from_memory
// and https://github.com/opensource-apple/dyld/tree/master/unit-tests/test-cases/bundle-memory-load

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("jsimport_call", Run)
}

type JxaRun interface {
Success() bool
Result() string
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/jxa/jxa.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("jxa", Run)
}

type JxaRun interface {
Success() bool
Result() string
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/keylog/keylog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (
// Poseidon
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/keylog/keystate"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("keylog", Run)
}

// Run - Function that executes the shell command
func Run(task structs.Task) {

Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("keys", Run)
}

// KeyInformation - interface for key data
type KeyInformation interface {
KeyType() string
Expand Down
5 changes: 5 additions & 0 deletions Payload_Type/poseidon/poseidon/agent_code/kill/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("kill", Run)
}

// Run - Function that executes the shell command
func Run(task structs.Task) {
msg := task.NewResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("libinject", Run)
}

// Inject C source taken from: http://www.newosxbook.com/src.jl?tree=listings&file=inject.c
type Injection interface {
TargetPid() int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("link_tcp", Run)
}

type Arguments struct {
Port int `json:"port"`
Address string `json:"address"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("link_webshell", Run)
}

type Arguments struct {
CookieValue string `json:"cookie_value"`
CookieName string `json:"cookie_name"`
Expand All @@ -22,6 +27,7 @@ type Arguments struct {
TargetUUID string `json:"target_uuid"`
}


// Run - package function to run link_tcp
func Run(task structs.Task) {
msg := task.NewResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/ps"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("list_entitlements", Run)
}

type Arguments struct {
PID int `json:"pid"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
// Poseidon

"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/tasks/library"
)

func init() {
library.RegisterTask("listtasks", Run)
}

type Listtasks interface {
Result() map[string]interface{}
}
Expand Down
Loading