Skip to content

Commit

Permalink
DACL and Owner for Scheduled Task executables
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Mar 28, 2022
1 parent 6f7022a commit 2ee1f2c
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 105 deletions.
2 changes: 1 addition & 1 deletion modules/integrations/localmachine/collect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ func Collect(outputpath string) error {
ownersid, dacl, err := windowssecurity.GetOwnerAndDACL(shareinfo.Path, windows.SE_FILE_OBJECT)
if err == nil {
shareinfo.PathOwner = ownersid.String()
shareinfo.PathDACL = dacl
}
shareinfo.PathDACL = dacl
}

// if stype >= 16 {
Expand Down
11 changes: 11 additions & 0 deletions modules/integrations/localmachine/collect/taskmaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package collect
import (
"github.com/amidaware/taskmaster"
"github.com/lkarlslund/adalanche/modules/integrations/localmachine"
"github.com/lkarlslund/adalanche/modules/windowssecurity"
"golang.org/x/sys/windows"
)

func ConvertRegisteredTask(rt taskmaster.RegisteredTask) localmachine.RegisteredTask {
Expand All @@ -18,6 +20,15 @@ func ConvertRegisteredTask(rt taskmaster.RegisteredTask) localmachine.Registered
a[i].Path = e.Path
a[i].Args = e.Args
a[i].WorkingDir = e.WorkingDir

if e.Path != "" {
executable := resolvepath(e.Path)
ownersid, dacl, err := windowssecurity.GetOwnerAndDACL(executable, windows.SE_FILE_OBJECT)
if err == nil {
a[i].PathOwner = ownersid.String()
a[i].PathDACL = dacl
}
}
}
}
return a
Expand Down
2 changes: 2 additions & 0 deletions modules/integrations/localmachine/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ type TaskDefinition struct {

type TaskAction struct {
Type string `json:",omitempty"`
PathDACL []byte `json:",omitempty"`
PathOwner string `json:",omitempty"`
Path string `json:",omitempty"`
Args string `json:",omitempty"`
WorkingDir string `json:",omitempty"`
Expand Down
Loading

0 comments on commit 2ee1f2c

Please sign in to comment.