From 0ce1ec46b60230d31ffbe6b281edac1325c88730 Mon Sep 17 00:00:00 2001 From: Rebecca Mahany-Horton Date: Tue, 14 Nov 2023 09:44:49 -0500 Subject: [PATCH] SYSTEM32 env var not available when running flare, use WINDIR instead --- pkg/allowedcmd/cmd_windows.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/allowedcmd/cmd_windows.go b/pkg/allowedcmd/cmd_windows.go index 7527a051c..5425a5926 100644 --- a/pkg/allowedcmd/cmd_windows.go +++ b/pkg/allowedcmd/cmd_windows.go @@ -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) { @@ -28,15 +28,15 @@ 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) { @@ -44,11 +44,11 @@ func Repcli(ctx context.Context, arg ...string) (*exec.Cmd, error) { } 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) {