From 293151ea0a87489cc9df481166672c9ba29b9ecb Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 11 Dec 2022 23:47:16 -0800 Subject: [PATCH 1/6] fix choco not found in path --- agent/choco_windows.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/agent/choco_windows.go b/agent/choco_windows.go index 1ba6058..5053f09 100644 --- a/agent/choco_windows.go +++ b/agent/choco_windows.go @@ -12,6 +12,9 @@ https://license.tacticalrmm.com package agent import ( + "os" + "os/exec" + "path/filepath" "time" rmm "github.com/amidaware/rmmagent/shared" @@ -59,7 +62,14 @@ func (a *Agent) InstallChoco() { } func (a *Agent) InstallWithChoco(name string) (string, error) { - out, err := CMD("choco.exe", []string{"install", name, "--yes", "--force", "--force-dependencies", "--no-progress"}, 1200, false) + var exe string + choco, err := exec.LookPath("choco.exe") + if err != nil || choco == "" { + exe = filepath.Join(os.Getenv("PROGRAMDATA"), `chocolatey\bin\choco.exe`) + } else { + exe = choco + } + out, err := CMD(exe, []string{"install", name, "--yes", "--force", "--force-dependencies", "--no-progress"}, 1200, false) if err != nil { a.Logger.Errorln(err) return err.Error(), err From c3e33a6def6ee4d12bfa88e814c53d436d674a8f Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 11 Dec 2022 23:50:00 -0800 Subject: [PATCH 2/6] fix path on exchange servers fixes amidaware/tacticalrmm#1359 --- agent/agent_windows.go | 14 ++++++++------ agent/utils.go | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/agent/agent_windows.go b/agent/agent_windows.go index f211987..b19a185 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -132,7 +132,7 @@ func (a *Agent) RunScript(code string, shell string, args []string, timeout int, switch shell { case "powershell": - exe = "Powershell" + exe = getPowershellExe() cmdArgs = []string{"-NonInteractive", "-NoProfile", "-ExecutionPolicy", "Bypass", tmpfn.Name()} case "python": exe = a.PyBin @@ -260,23 +260,25 @@ func CMDShell(shell string, cmdArgs []string, command string, timeout int, detac defer cancel() sysProcAttr := &windows.SysProcAttr{} + cmdExe := getCMDExe() + powershell := getPowershellExe() if len(cmdArgs) > 0 && command == "" { switch shell { case "cmd": cmdArgs = append([]string{"/C"}, cmdArgs...) - cmd = exec.Command("cmd.exe", cmdArgs...) + cmd = exec.Command(cmdExe, cmdArgs...) case "powershell": cmdArgs = append([]string{"-NonInteractive", "-NoProfile"}, cmdArgs...) - cmd = exec.Command("powershell.exe", cmdArgs...) + cmd = exec.Command(powershell, cmdArgs...) } } else { switch shell { case "cmd": - cmd = exec.Command("cmd.exe") - sysProcAttr.CmdLine = fmt.Sprintf("cmd.exe /C %s", command) + cmd = exec.Command(cmdExe) + sysProcAttr.CmdLine = fmt.Sprintf("%s /C %s", cmdExe, command) case "powershell": - cmd = exec.Command("Powershell", "-NonInteractive", "-NoProfile", command) + cmd = exec.Command(powershell, "-NonInteractive", "-NoProfile", command) } } diff --git a/agent/utils.go b/agent/utils.go index 3e84288..093fa1b 100644 --- a/agent/utils.go +++ b/agent/utils.go @@ -20,6 +20,7 @@ import ( "math/rand" "net" "os" + "os/exec" "path/filepath" "runtime" goDebug "runtime/debug" @@ -339,3 +340,19 @@ func regRangeToInt(s string) int { max, _ := strconv.Atoi(split[1]) return randRange(min, max) } + +func getPowershellExe() string { + powershell, err := exec.LookPath("powershell.exe") + if err != nil || powershell == "" { + return filepath.Join(os.Getenv("WINDIR"), `System32\WindowsPowerShell\v1.0\powershell.exe`) + } + return powershell +} + +func getCMDExe() string { + cmdExe, err := exec.LookPath("cmd.exe") + if err != nil || cmdExe == "" { + return filepath.Join(os.Getenv("WINDIR"), `System32\cmd.exe`) + } + return cmdExe +} From 4b1f993a7633c3f69d49cd6ee4ae509c3896d19b Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 11 Dec 2022 23:52:06 -0800 Subject: [PATCH 3/6] fix ping check fixes amidaware/tacticalrmm#812 --- agent/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/utils.go b/agent/utils.go index 093fa1b..41715bd 100644 --- a/agent/utils.go +++ b/agent/utils.go @@ -61,7 +61,7 @@ func DoPing(host string) (PingResponse, error) { } pinger.Count = 3 - pinger.Size = 24 + pinger.Size = 548 pinger.Interval = time.Second pinger.Timeout = 5 * time.Second pinger.SetPrivileged(true) From ff75a8eb8995716cb696f547312314b1b48a6aa4 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 20 Dec 2022 16:07:42 -0800 Subject: [PATCH 4/6] update nats --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 361ae4a..c41cae6 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( github.com/go-resty/resty/v2 v2.7.0 github.com/gonutz/w32/v2 v2.4.0 github.com/iamacarpet/go-win64api v0.0.0-20220531131246-e84054eb584d - github.com/nats-io/nats-server/v2 v2.9.8 // indirect - github.com/nats-io/nats.go v1.20.0 + github.com/nats-io/nats-server/v2 v2.9.10 // indirect + github.com/nats-io/nats.go v1.22.0 github.com/rickb777/date v1.19.1 github.com/shirou/gopsutil/v3 v3.22.10 github.com/sirupsen/logrus v1.9.0 diff --git a/go.sum b/go.sum index bc6b194..306b47c 100644 --- a/go.sum +++ b/go.sum @@ -212,10 +212,10 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/nats-io/jwt/v2 v2.3.0 h1:z2mA1a7tIf5ShggOFlR1oBPgd6hGqcDYsISxZByUzdI= -github.com/nats-io/nats-server/v2 v2.9.8 h1:jgxZsv+A3Reb3MgwxaINcNq/za8xZInKhDg9Q0cGN1o= -github.com/nats-io/nats-server/v2 v2.9.8/go.mod h1:AB6hAnGZDlYfqb7CTAm66ZKMZy9DpfierY1/PbpvI2g= -github.com/nats-io/nats.go v1.20.0 h1:T8JJnQfVSdh1CzGiwAOv5hEobYCBho/0EupGznYw0oM= -github.com/nats-io/nats.go v1.20.0/go.mod h1:tLqubohF7t4z3du1QDPYJIQQyhb4wl6DhjxEajSI7UA= +github.com/nats-io/nats-server/v2 v2.9.10 h1:LMC46Oi9E6BUx/xBsaCVZgofliAqKQzRPU6eKWkN8jE= +github.com/nats-io/nats-server/v2 v2.9.10/go.mod h1:AB6hAnGZDlYfqb7CTAm66ZKMZy9DpfierY1/PbpvI2g= +github.com/nats-io/nats.go v1.22.0 h1:3dxyVf+S449DbMriqQV27HgSbXklxT9SUKbDKIxhrV0= +github.com/nats-io/nats.go v1.22.0/go.mod h1:tLqubohF7t4z3du1QDPYJIQQyhb4wl6DhjxEajSI7UA= github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= From d3b7d4090b369b9782a0ceb4971f4ed731d38823 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 20 Dec 2022 16:08:18 -0800 Subject: [PATCH 5/6] retry on failed auth --- agent/agent.go | 1 + 1 file changed, 1 insertion(+) diff --git a/agent/agent.go b/agent/agent.go index d9e573b..f3cbadc 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -418,6 +418,7 @@ func (a *Agent) setupNatsOptions() []nats.Option { opts = append(opts, nats.UserInfo(a.AgentID, a.Token)) opts = append(opts, nats.ReconnectWait(time.Duration(reconnectWait)*time.Second)) opts = append(opts, nats.RetryOnFailedConnect(true)) + opts = append(opts, nats.IgnoreAuthErrorAbort()) opts = append(opts, nats.PingInterval(time.Duration(a.NatsPingInterval)*time.Second)) opts = append(opts, nats.Compression(a.NatsWSCompression)) opts = append(opts, nats.MaxReconnects(-1)) From 396d7db8353b572d09ed0bde12faa4e04d284ab2 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 21 Dec 2022 11:10:18 -0800 Subject: [PATCH 6/6] bump version --- build/rmm.exe.manifest | 2 +- build/setup.iss | 2 +- main.go | 2 +- versioninfo.json | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/rmm.exe.manifest b/build/rmm.exe.manifest index 56445b7..1d2abaf 100644 --- a/build/rmm.exe.manifest +++ b/build/rmm.exe.manifest @@ -3,7 +3,7 @@ diff --git a/build/setup.iss b/build/setup.iss index 1c1b1e3..892f905 100644 --- a/build/setup.iss +++ b/build/setup.iss @@ -1,5 +1,5 @@ #define MyAppName "Tactical RMM Agent" -#define MyAppVersion "2.4.3" +#define MyAppVersion "2.4.4" #define MyAppPublisher "AmidaWare LLC" #define MyAppURL "https://github.com/amidaware" #define MyAppExeName "tacticalrmm.exe" diff --git a/main.go b/main.go index 1e2c402..e4f68ab 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ import ( ) var ( - version = "2.4.3" + version = "2.4.4" log = logrus.New() logFile *os.File ) diff --git a/versioninfo.json b/versioninfo.json index 695415b..c65e363 100644 --- a/versioninfo.json +++ b/versioninfo.json @@ -3,13 +3,13 @@ "FileVersion": { "Major": 2, "Minor": 4, - "Patch": 3, + "Patch": 4, "Build": 0 }, "ProductVersion": { "Major": 2, "Minor": 4, - "Patch": 3, + "Patch": 4, "Build": 0 }, "FileFlagsMask": "3f", @@ -22,14 +22,14 @@ "Comments": "", "CompanyName": "AmidaWare LLC", "FileDescription": "Tactical RMM Agent", - "FileVersion": "v2.4.3.0", + "FileVersion": "v2.4.4.0", "InternalName": "tacticalrmm.exe", "LegalCopyright": "Copyright (c) 2022 AmidaWare LLC", "LegalTrademarks": "", "OriginalFilename": "tacticalrmm.exe", "PrivateBuild": "", "ProductName": "Tactical RMM Agent", - "ProductVersion": "v2.4.3.0", + "ProductVersion": "v2.4.4.0", "SpecialBuild": "" }, "VarFileInfo": {