mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Mostly fixed character encoding and stuff. Signed-off-by: Mike Lloyd <mike@reboot3times.org>
24 lines
484 B
Go
24 lines
484 B
Go
package security
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"github.com/senorprogrammer/wtf/wtf"
|
|
)
|
|
|
|
func LoggedInUsers() []string {
|
|
cmd := exec.Command("powershell.exe", "(query user) -replace '\\s{2,}', ','")
|
|
users := wtf.ExecuteCommand(cmd)
|
|
return cleanUsers(strings.Split(users, "\n")[1:])
|
|
}
|
|
|
|
func cleanUsers(users []string) []string {
|
|
cleaned := make([]string, 0)
|
|
for _, user := range users {
|
|
usr := strings.Split(user, ",")
|
|
cleaned = append(cleaned, usr[0])
|
|
}
|
|
return cleaned
|
|
}
|