aboutsummaryrefslogtreecommitdiff
path: root/internal/exec/wmi/wmi.go
diff options
context:
space:
mode:
authorBryan McNulty <bryanmcnulty@protonmail.com>2025-03-07 08:52:48 -0600
committerBryan McNulty <bryanmcnulty@protonmail.com>2025-03-07 08:52:48 -0600
commite87dd341dde93c289b6774f636e6767476b84a79 (patch)
tree3181b18f79b587bd04d98ed886f3505f37faeb2d /internal/exec/wmi/wmi.go
parenta5c860b8ab24c198b7390fbde90044754e35c1c5 (diff)
downloadgoexec-e87dd341dde93c289b6774f636e6767476b84a79.tar.gz
goexec-e87dd341dde93c289b6774f636e6767476b84a79.zip
Added wmiexec module + updated TODO
Diffstat (limited to 'internal/exec/wmi/wmi.go')
-rw-r--r--internal/exec/wmi/wmi.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/exec/wmi/wmi.go b/internal/exec/wmi/wmi.go
new file mode 100644
index 0000000..dd003a3
--- /dev/null
+++ b/internal/exec/wmi/wmi.go
@@ -0,0 +1,26 @@
+package wmiexec
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "github.com/oiweiwei/go-msrpc/msrpc/dcom/wmio/query"
+)
+
+func (mod *Module) query(ctx context.Context, class, method string, values map[string]any) (outValues map[string]any, err error) {
+ outValues = make(map[string]any)
+ if mod.sc == nil {
+ err = errors.New("module has not been initialized")
+ return
+ }
+ if out, err := query.NewBuilder(ctx, mod.sc, ComVersion).
+ Spawn(class). // The class to instantiate (i.e. Win32_Process)
+ Method(method). // The method to call (i.e. Create)
+ Values(values). // The values to pass to method
+ Exec().
+ Object(); err == nil {
+ return out.Values(), err
+ }
+ err = fmt.Errorf("(*query.Builder).Spawn: %w", err)
+ return
+}