diff --git a/agent/agent_linux.go b/agent/agent_linux.go deleted file mode 100644 index 4ce4eaf..0000000 --- a/agent/agent_linux.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2022 AmidaWare LLC. - -Licensed under the Tactical RMM License Version 1.0 (the “License”). -You may only use the Licensed Software in accordance with the License. -A copy of the License is available at: - -https://license.tacticalrmm.com - -*/ - -package agent - -import ( - rmm "github.com/amidaware/rmmagent/shared" - "github.com/kardianos/service" - trmm "github.com/wh1te909/trmm-shared" -) - - - -// windows only below TODO add into stub file - - - - - - - - - -func (a *Agent) GetPython(force bool) {} - -type SchedTask struct{ Name string } - -func (a *Agent) PatchMgmnt(enable bool) error { return nil } - -func (a *Agent) CreateSchedTask(st SchedTask) (bool, error) { return false, nil } - -func DeleteSchedTask(name string) error { return nil } - -func ListSchedTasks() []string { return []string{} } - -func (a *Agent) GetEventLog(logName string, searchLastDays int) []rmm.EventLogMsg { - return []rmm.EventLogMsg{} -} - -func (a *Agent) GetServiceDetail(name string) trmm.WindowsService { return trmm.WindowsService{} } - -func (a *Agent) ControlService(name, action string) rmm.WinSvcResp { - return rmm.WinSvcResp{Success: false, ErrorMsg: "/na"} -} - -func (a *Agent) EditService(name, startupType string) rmm.WinSvcResp { - return rmm.WinSvcResp{Success: false, ErrorMsg: "/na"} -} - -func (a *Agent) GetInstalledSoftware() []trmm.WinSoftwareList { return []trmm.WinSoftwareList{} } - -func (a *Agent) ChecksRunning() bool { return false } - -func (a *Agent) RunTask(id int) error { return nil } - -func (a *Agent) InstallChoco() {} - -func (a *Agent) InstallWithChoco(name string) (string, error) { return "", nil } - -func (a *Agent) GetWinUpdates() {} - -func (a *Agent) InstallUpdates(guids []string) {} - -func (a *Agent) installMesh(meshbin, exe, proxy string) (string, error) { - return "not implemented", nil -} - -func CMDShell(shell string, cmdArgs []string, command string, timeout int, detached bool) (output [2]string, e error) { - return [2]string{"", ""}, nil -} - -func CMD(exe string, args []string, timeout int, detached bool) (output [2]string, e error) { - return [2]string{"", ""}, nil -} - -func (a *Agent) GetServices() []trmm.WindowsService { return []trmm.WindowsService{} } - -func (a *Agent) Start(_ service.Service) error { return nil } - -func (a *Agent) Stop(_ service.Service) error { return nil } - -func (a *Agent) InstallService() error { return nil } diff --git a/agent/agent_linux_test.go b/agent/agent_linux_test.go deleted file mode 100644 index 570b881..0000000 --- a/agent/agent_linux_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package agent - -import ( - "bytes" - "io" - "os" - "testing" -) - -func captureOutput(f func()) string { - old := os.Stdout - r, w, _ := os.Pipe() - os.Stdout = w - f() - w.Close() - os.Stdout = old - - var buf bytes.Buffer - io.Copy(&buf, r) - return buf.String() -} - -func TestShowStatus(t *testing.T) { - var ( - version = "2.0.4" - ) - - output := captureOutput(func() { - ShowStatus(version) - }) - - if output != (version + "\n") { - t.Errorf("ShowStatus output not equal to version defined.") - } -} - -func TestOsString(t *testing.T) { - a := New(lg, version) - osString := a.osString() - if osString == "" { - t.Errorf("Could not get OS String") - } else { - t.Logf("Got OS String: %s", osString) - } -} \ No newline at end of file diff --git a/agent/agent_windows.go b/agent/agent_windows.go index 5d75b2d..abdb298 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -46,35 +46,7 @@ var ( getDriveType = windows.NewLazySystemDLL("kernel32.dll").NewProc("GetDriveTypeW") ) -func NewAgentConfig() *rmm.AgentConfig { - k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - if err != nil { - return &rmm.AgentConfig{} - } - - baseurl, _, _ := k.GetStringValue("BaseURL") - agentid, _, _ := k.GetStringValue("AgentID") - apiurl, _, _ := k.GetStringValue("ApiURL") - token, _, _ := k.GetStringValue("Token") - agentpk, _, _ := k.GetStringValue("AgentPK") - pk, _ := strconv.Atoi(agentpk) - cert, _, _ := k.GetStringValue("Cert") - proxy, _, _ := k.GetStringValue("Proxy") - customMeshDir, _, _ := k.GetStringValue("MeshDir") - - return &rmm.AgentConfig{ - BaseURL: baseurl, - AgentID: agentid, - APIURL: apiurl, - Token: token, - AgentPK: agentpk, - PK: pk, - Cert: cert, - Proxy: proxy, - CustomMeshDir: customMeshDir, - } -} func (a *Agent) RunScript(code string, shell string, args []string, timeout int) (stdout, stderr string, exitcode int, e error) { diff --git a/agent/patching/patching_linux.go b/agent/patching/patching_linux.go new file mode 100644 index 0000000..74a9f6d --- /dev/null +++ b/agent/patching/patching_linux.go @@ -0,0 +1,7 @@ +package patching + +func PatchMgmnt(enable bool) error { return nil } + +func GetWinUpdates() {} + +func InstallUpdates(guids []string) {} \ No newline at end of file diff --git a/agent/services/services_linux.go b/agent/services/services_linux.go new file mode 100644 index 0000000..60706cf --- /dev/null +++ b/agent/services/services_linux.go @@ -0,0 +1,25 @@ +package services + +import ( + trmm "github.com/wh1te909/trmm-shared" + rmm "github.com/amidaware/rmmagent/shared" + "github.com/kardianos/service" +) + +func GetServiceDetail(name string) trmm.WindowsService { return trmm.WindowsService{} } + +func ControlService(name, action string) rmm.WinSvcResp { + return rmm.WinSvcResp{Success: false, ErrorMsg: "/na"} +} + +func EditService(name, startupType string) rmm.WinSvcResp { + return rmm.WinSvcResp{Success: false, ErrorMsg: "/na"} +} + +func GetServices() []trmm.WindowsService { return []trmm.WindowsService{} } + +func Start(_ service.Service) error { return nil } + +func Stop(_ service.Service) error { return nil } + +func InstallService() error { return nil } \ No newline at end of file diff --git a/agent/software/software.go b/agent/software/software.go deleted file mode 100644 index 081df6b..0000000 --- a/agent/software/software.go +++ /dev/null @@ -1,3 +0,0 @@ -package software - -func SendSoftware() {} \ No newline at end of file diff --git a/agent/software/software_linux.go b/agent/software/software_linux.go new file mode 100644 index 0000000..81ff929 --- /dev/null +++ b/agent/software/software_linux.go @@ -0,0 +1,13 @@ +package software + +import ( + trmm "github.com/wh1te909/trmm-shared" +) + +func SendSoftware() {} + +func GetInstalledSoftware() []trmm.WinSoftwareList { return []trmm.WinSoftwareList{} } + +func InstallChoco() {} + +func InstallWithChoco(name string) (string, error) { return "", nil } \ No newline at end of file diff --git a/agent/system/structs.go b/agent/system/structs.go index 50bdc9c..60b4e71 100644 --- a/agent/system/structs.go +++ b/agent/system/structs.go @@ -10,4 +10,6 @@ type CmdOptions struct { IsScript bool IsExecutable bool Detached bool -} \ No newline at end of file +} + +type SchedTask struct{ Name string } \ No newline at end of file diff --git a/agent/system/system_linux.go b/agent/system/system_linux.go index 89c5cfb..98cefea 100644 --- a/agent/system/system_linux.go +++ b/agent/system/system_linux.go @@ -15,7 +15,8 @@ import ( "github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/process" psHost "github.com/shirou/gopsutil/v3/host" - "github.com/wh1te909/trmm-shared" + rmm "github.com/amidaware/rmmagent/shared" + trmm "github.com/wh1te909/trmm-shared" ) func NewCMDOpts() *CmdOptions { @@ -267,4 +268,22 @@ func GetWMIInfo() map[string]interface{} { func PlatVer() (string, error) { return "", nil } -func GetServiceStatus(name string) (string, error) { return "", nil } \ No newline at end of file +func GetServiceStatus(name string) (string, error) { return "", nil } + +func CreateSchedTask(st SchedTask) (bool, error) { return false, nil } + +func DeleteSchedTask(name string) error { return nil } + +func ListSchedTasks() []string { return []string{} } + +func GetEventLog(logName string, searchLastDays int) []rmm.EventLogMsg { + return []rmm.EventLogMsg{} +} + +func CMDShell(shell string, cmdArgs []string, command string, timeout int, detached bool) (output [2]string, e error) { + return [2]string{"", ""}, nil +} + +func CMD(exe string, args []string, timeout int, detached bool) (output [2]string, e error) { + return [2]string{"", ""}, nil +} \ No newline at end of file diff --git a/agent/tactical/tactical_linux.go b/agent/tactical/tactical_linux.go index 1ad3c5e..108a73b 100644 --- a/agent/tactical/tactical_linux.go +++ b/agent/tactical/tactical_linux.go @@ -171,4 +171,14 @@ func RecoverMesh(agentID string) { func UninstallCleanup() {} -func RunMigrations() {} \ No newline at end of file +func RunMigrations() {} + +func GetPython(force bool) {} + +func ChecksRunning() bool { return false } + +func RunTask(id int) error { return nil } + +func installMesh(meshbin, exe, proxy string) (string, error) { + return "not implemented", nil +} \ No newline at end of file diff --git a/agent/tactical/tactical_windows.go b/agent/tactical/tactical_windows.go new file mode 100644 index 0000000..5d5376d --- /dev/null +++ b/agent/tactical/tactical_windows.go @@ -0,0 +1,31 @@ +package tactical + +func NewAgentConfig() *rmm.AgentConfig { + k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) + + if err != nil { + return &rmm.AgentConfig{} + } + + baseurl, _, _ := k.GetStringValue("BaseURL") + agentid, _, _ := k.GetStringValue("AgentID") + apiurl, _, _ := k.GetStringValue("ApiURL") + token, _, _ := k.GetStringValue("Token") + agentpk, _, _ := k.GetStringValue("AgentPK") + pk, _ := strconv.Atoi(agentpk) + cert, _, _ := k.GetStringValue("Cert") + proxy, _, _ := k.GetStringValue("Proxy") + customMeshDir, _, _ := k.GetStringValue("MeshDir") + + return &rmm.AgentConfig{ + BaseURL: baseurl, + AgentID: agentid, + APIURL: apiurl, + Token: token, + AgentPK: agentpk, + PK: pk, + Cert: cert, + Proxy: proxy, + CustomMeshDir: customMeshDir, + } +} \ No newline at end of file