testing and generate
This commit is contained in:
parent
9743d7ee22
commit
3841aee4b2
24 changed files with 1087 additions and 610 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/amidaware/rmmagent/agent/tactical/shared"
|
||||
"github.com/amidaware/rmmagent/agent/utils"
|
||||
ps "github.com/elastic/go-sysinfo"
|
||||
gocmd "github.com/go-cmd/cmd"
|
||||
|
|
@ -144,7 +145,7 @@ func RunPythonCode(code string, timeout int, args []string) (string, error) {
|
|||
}
|
||||
|
||||
//a.Logger.Debugln(cmdArgs)
|
||||
cmd := exec.CommandContext(ctx, GetPythonBin(), cmdArgs...)
|
||||
cmd := exec.CommandContext(ctx, shared.GetPythonBin(), cmdArgs...)
|
||||
cmd.Stdout = &outb
|
||||
cmd.Stderr = &errb
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/amidaware/rmmagent/agent/tactical/shared"
|
||||
"github.com/amidaware/rmmagent/agent/utils"
|
||||
ps "github.com/elastic/go-sysinfo"
|
||||
"github.com/go-ole/go-ole"
|
||||
|
|
@ -25,11 +25,6 @@ import (
|
|||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
const (
|
||||
ProgFilesName = "TacticalAgent"
|
||||
winExeName = "tacticalrmm.exe"
|
||||
)
|
||||
|
||||
func RunScript(code string, shell string, args []string, timeout int) (stdout, stderr string, exitcode int, e error) {
|
||||
content := []byte(code)
|
||||
dir := filepath.Join(os.TempDir(), "trmm")
|
||||
|
|
@ -74,7 +69,7 @@ func RunScript(code string, shell string, args []string, timeout int) (stdout, s
|
|||
exe = "Powershell"
|
||||
cmdArgs = []string{"-NonInteractive", "-NoProfile", "-ExecutionPolicy", "Bypass", tmpfn.Name()}
|
||||
case "python":
|
||||
exe = GetPythonBin()
|
||||
exe = shared.GetPythonBin()
|
||||
cmdArgs = []string{tmpfn.Name()}
|
||||
case "cmd":
|
||||
exe = tmpfn.Name()
|
||||
|
|
@ -250,28 +245,6 @@ func CMDShell(shell string, cmdArgs []string, command string, timeout int, detac
|
|||
nil
|
||||
}
|
||||
|
||||
func GetProgramDirectory() string {
|
||||
pd := filepath.Join(os.Getenv("ProgramFiles"), ProgFilesName)
|
||||
return pd
|
||||
}
|
||||
|
||||
func GetProgramBin() string {
|
||||
exe := filepath.Join(GetProgramDirectory(), winExeName)
|
||||
return exe
|
||||
}
|
||||
|
||||
func GetPythonBin() string {
|
||||
var pybin string
|
||||
switch runtime.GOARCH {
|
||||
case "amd64":
|
||||
pybin = filepath.Join(GetProgramDirectory(), "py38-x64", "python.exe")
|
||||
case "386":
|
||||
pybin = filepath.Join(GetProgramDirectory(), "py38-x32", "python.exe")
|
||||
}
|
||||
|
||||
return pybin
|
||||
}
|
||||
|
||||
// LoggedOnUser returns the first logged on user it finds
|
||||
func LoggedOnUser() string {
|
||||
pyCode := `
|
||||
|
|
@ -471,7 +444,7 @@ func OsString() string {
|
|||
return osFullName
|
||||
}
|
||||
|
||||
func AddDefenderExlusions() error {
|
||||
func AddDefenderExclusions() error {
|
||||
code := `
|
||||
Add-MpPreference -ExclusionPath 'C:\Program Files\TacticalAgent\*'
|
||||
Add-MpPreference -ExclusionPath 'C:\Windows\Temp\winagent-v*.exe'
|
||||
|
|
@ -507,4 +480,4 @@ func KillProc(pid int32) error {
|
|||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue