-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ssh, ifconfig, and caffeinate commands
- Loading branch information
1 parent
be53514
commit 988128f
Showing
14 changed files
with
777 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Payload_Type/poseidon/poseidon/agent_code/caffeinate/caffeinate.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package caffeinate | ||
|
||
import ( | ||
// Standard | ||
"encoding/json" | ||
|
||
// Poseidon | ||
|
||
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs" | ||
) | ||
|
||
type CaffeinateRun interface { | ||
Success() bool | ||
Result() string | ||
} | ||
|
||
type Arguments struct { | ||
Enable bool `json:"enable"` | ||
} | ||
|
||
func Run(task structs.Task) { | ||
msg := task.NewResponse() | ||
args := Arguments{} | ||
err := json.Unmarshal([]byte(task.Params), &args) | ||
if err != nil { | ||
msg.SetError(err.Error()) | ||
task.Job.SendResponses <- msg | ||
return | ||
} | ||
r, err := runCommand(args.Enable) | ||
if err != nil { | ||
msg.SetError(err.Error()) | ||
task.Job.SendResponses <- msg | ||
return | ||
} | ||
msg.UserOutput = r.Result() | ||
msg.Completed = true | ||
task.Job.SendResponses <- msg | ||
return | ||
} |
38 changes: 38 additions & 0 deletions
38
Payload_Type/poseidon/poseidon/agent_code/caffeinate/caffeinate_darwin.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//go:build darwin | ||
// +build darwin | ||
|
||
package caffeinate | ||
|
||
/* | ||
#cgo CFLAGS: -x objective-c -fmacro-backtrace-limit=0 -std=gnu11 -Wobjc-property-no-attribute -Wunguarded-availability-new | ||
#cgo LDFLAGS: -framework Foundation -framework IOKit | ||
#include "caffeinate_wrapper_darwin.h" | ||
*/ | ||
import "C" | ||
|
||
type CaffeinateRunDarwin struct { | ||
Successful bool | ||
Results string | ||
} | ||
|
||
func (j *CaffeinateRunDarwin) Success() bool { | ||
return j.Successful | ||
} | ||
|
||
func (j *CaffeinateRunDarwin) Result() string { | ||
return j.Results | ||
} | ||
|
||
func runCommand(enable bool) (CaffeinateRunDarwin, error) { | ||
enableInt := 0 | ||
if enable { | ||
enableInt = 1 | ||
} | ||
cEnable := C.int(enableInt) | ||
cresult := C.caffeinate(cEnable) | ||
result := C.GoString(cresult) | ||
r := CaffeinateRunDarwin{} | ||
r.Successful = true | ||
r.Results = result | ||
return r, nil | ||
} |
28 changes: 28 additions & 0 deletions
28
Payload_Type/poseidon/poseidon/agent_code/caffeinate/caffeinate_linux.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package caffeinate | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
type CaffeinateRunLinux struct { | ||
Successful bool | ||
Resultstring string | ||
} | ||
|
||
func (j *CaffeinateRunLinux) Success() bool { | ||
return j.Successful | ||
} | ||
|
||
func (j *CaffeinateRunLinux) Result() string { | ||
return j.Resultstring | ||
} | ||
|
||
func runCommand(enable bool) (CaffeinateRunLinux, error) { | ||
n := CaffeinateRunLinux{} | ||
n.Resultstring = "" | ||
n.Successful = false | ||
return n, errors.New("Not implemented") | ||
} |
7 changes: 7 additions & 0 deletions
7
Payload_Type/poseidon/poseidon/agent_code/caffeinate/caffeinate_wrapper_darwin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
#ifndef main_h | ||
#define main_h | ||
|
||
extern char* caffeinate(int enable); | ||
|
||
#endif /* main_h */ |
24 changes: 24 additions & 0 deletions
24
Payload_Type/poseidon/poseidon/agent_code/caffeinate/caffeinate_wrapper_darwin.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <IOKit/pwr_mgt/IOPMLib.h> | ||
#include "caffeinate_wrapper_darwin.h" | ||
|
||
char* caffeinate(int enable) { | ||
@try { | ||
IOPMAssertionLevel newLevel = kIOPMAssertionLevelOn; | ||
if(enable == 0){ | ||
newLevel = kIOPMAssertionLevelOff; | ||
} | ||
CFStringRef assertionName = CFStringCreateWithCString(NULL, "caffeinate", kCFStringEncodingUTF8); | ||
IOPMAssertionID assertionID; | ||
IOReturn status = IOPMAssertionCreateWithName(kIOPMAssertionTypePreventSystemSleep, newLevel, assertionName, &assertionID); | ||
if(status == kIOReturnSuccess){ | ||
return "Successfully adjusted caffeinate status"; | ||
} else { | ||
NSString* fmtString = [NSString stringWithFormat:@"Failed to set status: %d", status]; | ||
return [fmtString UTF8String]; | ||
} | ||
} @catch (NSException *exception) { | ||
return [[exception reason] UTF8String]; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
Payload_Type/poseidon/poseidon/agent_code/ifconfig/ifconfig.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ifconfig | ||
|
||
import ( | ||
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/functions" | ||
|
||
"strings" | ||
|
||
// Poseidon | ||
|
||
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs" | ||
) | ||
|
||
// Run - Function that executes | ||
func Run(task structs.Task) { | ||
msg := task.NewResponse() | ||
ips := functions.GetCurrentIPAddress() | ||
msg.UserOutput = strings.Join(ips, "\n") | ||
msg.Completed = true | ||
task.Job.SendResponses <- msg | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.