fix remote desktop + add system and trusted installer pills
This commit is contained in:
@@ -279,13 +279,14 @@ func captureAllDisplaysAndSend(ctx context.Context, env *rt.Env) error {
|
||||
|
||||
quality := jpegQuality()
|
||||
frame, _, err := buildFrame(canvas, 0, quality)
|
||||
canvasW, canvasH := canvas.Rect.Dx(), canvas.Rect.Dy()
|
||||
PutRGBA(canvas)
|
||||
canvas = nil
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
frame.Header.FPS = 1
|
||||
log.Printf("capture: all-displays initial frame %dx%d (%d monitors)", canvas.Rect.Dx(), canvas.Rect.Dy(), n)
|
||||
log.Printf("capture: all-displays initial frame %dx%d (%d monitors)", canvasW, canvasH, n)
|
||||
return wire.WriteMsg(ctx, env.Conn, frame)
|
||||
}
|
||||
|
||||
|
||||
@@ -613,6 +613,7 @@ func runSession(ctx context.Context, cancel context.CancelFunc, conn *websocket.
|
||||
hello.GPU = hw.GPU
|
||||
hello.RAM = hw.RAM
|
||||
hello.IsAdmin = sysinfo.IsAdmin()
|
||||
hello.Elevation = sysinfo.Elevation()
|
||||
|
||||
if err := wire.WriteMsg(ctx, env.Conn, hello); err != nil {
|
||||
return fmt.Errorf("send hello: %w", err)
|
||||
|
||||
@@ -8,3 +8,10 @@ import "os"
|
||||
func IsAdmin() bool {
|
||||
return os.Getuid() == 0
|
||||
}
|
||||
|
||||
func Elevation() string {
|
||||
if os.Getuid() == 0 {
|
||||
return "admin"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -2,10 +2,62 @@
|
||||
|
||||
package sysinfo
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// check current process token to see if we're admin asf
|
||||
func IsAdmin() bool {
|
||||
token := windows.GetCurrentProcessToken()
|
||||
return token.IsElevated()
|
||||
}
|
||||
|
||||
func Elevation() string {
|
||||
token := windows.GetCurrentProcessToken()
|
||||
|
||||
tu, err := token.GetTokenUser()
|
||||
if err == nil {
|
||||
sid := tu.User.Sid
|
||||
if isTrustedInstallerSID(sid) {
|
||||
return "trustedinstaller"
|
||||
}
|
||||
if isLocalSystemSID(sid) {
|
||||
return "system"
|
||||
}
|
||||
}
|
||||
|
||||
if token.IsElevated() {
|
||||
return "admin"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func isLocalSystemSID(sid *windows.SID) bool {
|
||||
system, err := windows.StringToSid("S-1-5-18")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return sid.Equals(system)
|
||||
}
|
||||
|
||||
func isTrustedInstallerSID(sid *windows.SID) bool {
|
||||
ti, err := windows.StringToSid("S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if sid.Equals(ti) {
|
||||
return true
|
||||
}
|
||||
idAuth := (*[6]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(sid)) + 2))
|
||||
if idAuth[5] == 5 { // SECURITY_NT_AUTHORITY
|
||||
subAuthCount := *(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(sid)) + 1))
|
||||
if subAuthCount >= 1 {
|
||||
firstSub := *(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(sid)) + 8))
|
||||
if firstSub == 80 { // SECURITY_SERVICE_ID_BASE_RID
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ type Hello struct {
|
||||
GPU string `msgpack:"gpu,omitempty"`
|
||||
RAM string `msgpack:"ram,omitempty"`
|
||||
IsAdmin bool `msgpack:"isAdmin,omitempty"`
|
||||
Elevation string `msgpack:"elevation,omitempty"`
|
||||
}
|
||||
|
||||
type EnrollmentChallenge struct {
|
||||
|
||||
Reference in New Issue
Block a user