mirror of https://github.com/wh1te909/rmmagent.git
software and rebootnow nats
This commit is contained in:
parent
21ea111b1e
commit
b5b5297350
|
@ -163,6 +163,24 @@ func (a *WindowsAgent) RunRPC() {
|
|||
msg.Respond(resp)
|
||||
}()
|
||||
|
||||
case "softwarelist":
|
||||
go func() {
|
||||
var resp []byte
|
||||
ret := codec.NewEncoderBytes(&resp, new(codec.MsgpackHandle))
|
||||
sw := a.GetInstalledSoftware()
|
||||
ret.Encode(sw)
|
||||
msg.Respond(resp)
|
||||
}()
|
||||
|
||||
case "rebootnow":
|
||||
go func() {
|
||||
var resp []byte
|
||||
ret := codec.NewEncoderBytes(&resp, new(codec.MsgpackHandle))
|
||||
ret.Encode("ok")
|
||||
msg.Respond(resp)
|
||||
_, _ = CMD("shutdown.exe", []string{"/r", "/t", "5", "/f"}, 15, false)
|
||||
}()
|
||||
|
||||
case "uninstall":
|
||||
go func() {
|
||||
var resp []byte
|
||||
|
|
|
@ -7,6 +7,17 @@ import (
|
|||
wapf "github.com/wh1te909/go-win64api"
|
||||
)
|
||||
|
||||
type SoftwareList struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Publisher string `json:"publisher"`
|
||||
InstallDate string `json:"install_date"`
|
||||
Size string `json:"size"`
|
||||
Source string `json:"source"`
|
||||
Location string `json:"location"`
|
||||
Uninstall string `json:"uninstall"`
|
||||
}
|
||||
|
||||
// GetProgramVersion loops through the registry for software
|
||||
// and if found, returns its version
|
||||
func (a *WindowsAgent) GetProgramVersion(name string) string {
|
||||
|
@ -34,3 +45,26 @@ func installedSoftwareList() ([]so.Software, error) {
|
|||
|
||||
return sw32, nil
|
||||
}
|
||||
|
||||
func (a *WindowsAgent) GetInstalledSoftware() []SoftwareList {
|
||||
ret := make([]SoftwareList, 0)
|
||||
|
||||
sw, err := installedSoftwareList()
|
||||
if err != nil {
|
||||
return ret
|
||||
}
|
||||
|
||||
for _, s := range sw {
|
||||
ret = append(ret, SoftwareList{
|
||||
Name: s.Name(),
|
||||
Version: s.Version(),
|
||||
Publisher: s.Publisher,
|
||||
InstallDate: s.InstallDate.String(),
|
||||
Size: ByteCountSI(s.EstimatedSize * 1024),
|
||||
Source: s.InstallSource,
|
||||
Location: s.InstallLocation,
|
||||
Uninstall: s.UninstallString,
|
||||
})
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
|
@ -6,6 +6,17 @@ import (
|
|||
wapi "github.com/iamacarpet/go-win64api"
|
||||
)
|
||||
|
||||
type SoftwareList struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Publisher string `json:"publisher"`
|
||||
InstallDate string `json:"install_date"`
|
||||
Size string `json:"size"`
|
||||
Source string `json:"source"`
|
||||
Location string `json:"location"`
|
||||
Uninstall string `json:"uninstall"`
|
||||
}
|
||||
|
||||
// GetProgramVersion loops through the registry for software
|
||||
// and if found, returns its version
|
||||
func (a *WindowsAgent) GetProgramVersion(name string) string {
|
||||
|
@ -24,3 +35,26 @@ func (a *WindowsAgent) GetProgramVersion(name string) string {
|
|||
}
|
||||
return "0.0.0"
|
||||
}
|
||||
|
||||
func (a *WindowsAgent) GetInstalledSoftware() []SoftwareList {
|
||||
ret := make([]SoftwareList, 0)
|
||||
|
||||
sw, err := wapi.InstalledSoftwareList()
|
||||
if err != nil {
|
||||
return ret
|
||||
}
|
||||
|
||||
for _, s := range sw {
|
||||
ret = append(ret, SoftwareList{
|
||||
Name: s.Name(),
|
||||
Version: s.Version(),
|
||||
Publisher: s.Publisher,
|
||||
InstallDate: s.InstallDate.String(),
|
||||
Size: ByteCountSI(s.EstimatedSize * 1024),
|
||||
Source: s.InstallSource,
|
||||
Location: s.InstallLocation,
|
||||
Uninstall: s.UninstallString,
|
||||
})
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue