Skip to content

Commit

Permalink
windows: add net user enum
Browse files Browse the repository at this point in the history
In the go windows package, you can get user information by using
`NetUserGetInfo` along with a specified level. However, there is
no way to get a list of the users.
The only options are to
1. know the users,
2. brute force users, or
3. use an external tool or command (`net users`).

I suggest adding a function that implements the windows api for
`NetUserEnum`. This will allow a built in way to enumerate
users and follow the standard.

A side note is that I used `buf **byte` because
it is how the others are done, but using `buf *byte`
works just as well.

Change-Id: Ifcc916659eb1d796175cd18acd2e81f2661bfcd2
GitHub-Last-Rev: 3d01bca
GitHub-Pull-Request: #190
Reviewed-on: https://go-review.googlesource.com/c/sys/+/578475
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Auto-Submit: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
  • Loading branch information
JoeyShapiro authored and gopherbot committed May 9, 2024
1 parent 6dfb94e commit f34bb9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions windows/security_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type UserInfo10 struct {
//sys NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) = netapi32.NetUserGetInfo
//sys NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) = netapi32.NetGetJoinInformation
//sys NetApiBufferFree(buf *byte) (neterr error) = netapi32.NetApiBufferFree
//sys NetUserEnum(serverName *uint16, level uint32, filter uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32, resumeHandle *uint32) (neterr error) = netapi32.NetUserEnum

const (
// do not reorder
Expand Down
9 changes: 9 additions & 0 deletions windows/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f34bb9f

Please sign in to comment.