aboutsummaryrefslogtreecommitdiff
path: root/pkg/exec/tsch/module.go
blob: 3112902e2337e3fedbf28d3569de8ce84a4a08e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package tschexec

import (
	"context"
	"github.com/FalconOpsLLC/goexec/pkg/client/dcerpc"
	"github.com/bryanmcnulty/adauth"
	"github.com/oiweiwei/go-msrpc/msrpc/tsch/itaskschedulerservice/v1"
	"github.com/rs/zerolog"
	"time"
)

type Step struct {
	Name   string                                                      // Name of the step
	Status string                                                      // Status indicates whether the task succeeded, failed, etc.
	Call   func(context.Context, *Module, ...any) (interface{}, error) // Call will invoke the procedure
	Match  func(context.Context, *Module, ...any) (bool, error)        // Match will make an assertion to determine whether the step was successful
}

type Module struct {
	creds  *adauth.Credential
	target *adauth.Target

	log  zerolog.Logger
	dce  *dcerpc.DCEClient
	tsch itaskschedulerservice.TaskSchedulerServiceClient
}

type MethodRegisterConfig struct {
	NoDelete    bool
	CallDelete  bool
	TaskName    string
	TaskPath    string
	StartDelay  time.Duration
	StopDelay   time.Duration
	DeleteDelay time.Duration
}

type MethodDemandConfig struct {
	NoDelete    bool
	CallDelete  bool
	TaskName    string
	TaskPath    string
	StopDelay   time.Duration
	DeleteDelay time.Duration
}

type MethodDeleteConfig struct {
	TaskPath string
}

const (
	MethodRegister string = "register"
	MethodDemand   string = "demand"
	MethodDelete   string = "delete"
	MethodChange   string = "update"
)