Skip to content

Commit

Permalink
SYSTEM32 env var not available when running flare, use WINDIR instead
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Nov 14, 2023
1 parent 99b5e2a commit 0ce1ec4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/allowedcmd/cmd_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
)

func CommandPrompt(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "cmd.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "cmd.exe"), arg...)
}

func Dism(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "Dism.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "Dism.exe"), arg...)
}

func Dsregcmd(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "dsregcmd.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "dsregcmd.exe"), arg...)
}

func Echo(ctx context.Context, arg ...string) (*exec.Cmd, error) {
Expand All @@ -28,27 +28,27 @@ func Echo(ctx context.Context, arg ...string) (*exec.Cmd, error) {
}

func Ipconfig(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "ipconfig.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "ipconfig.exe"), arg...)
}

func Powercfg(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "powercfg.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "powercfg.exe"), arg...)
}

func Powershell(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "WindowsPowerShell", "v1.0", "powershell.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), arg...)
}

func Repcli(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("PROGRAMFILES"), "Confer", "repcli"), arg...)
}

func Secedit(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "SecEdit.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "SecEdit.exe"), arg...)
}

func Taskkill(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, filepath.Join(os.Getenv("SYSTEM32"), "taskkill.exe"), arg...)
return validatedCommand(ctx, filepath.Join(os.Getenv("WINDIR"), "System32", "taskkill.exe"), arg...)
}

func ZerotierCli(ctx context.Context, arg ...string) (*exec.Cmd, error) {
Expand Down

0 comments on commit 0ce1ec4

Please sign in to comment.