2023-03-03 03:20:34 +00:00
|
|
|
# uinput streaming approach
|
2023-01-30 01:45:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
``` go
|
2023-03-03 03:20:34 +00:00
|
|
|
--- do streaming keylogger approach
|
|
|
|
|
|
|
|
key := ""
|
2023-03-13 18:24:02 +00:00
|
|
|
if strings.HasPrefix(message_string, "@{keydown cmd}") {
|
|
|
|
key = strings.TrimPrefix(string(message_string), "@{keydown cmd}")
|
2023-03-03 03:20:34 +00:00
|
|
|
k.Write(1, key)
|
2023-03-13 18:24:02 +00:00
|
|
|
} else if strings.HasPrefix(message_string, "@{keyup cmd}") {
|
|
|
|
key = strings.TrimPrefix(string(message_string), "@{keyup cmd}")
|
2023-03-03 03:20:34 +00:00
|
|
|
k.Write(0, key)
|
2023-03-13 18:24:02 +00:00
|
|
|
} else if strings.HasPrefix(message_string, "@{keyheld cmd}") {
|
|
|
|
key = strings.TrimPrefix(string(message_string), "@{keyheld cmd}")
|
2023-03-06 01:51:45 +00:00
|
|
|
k.Write(2, key)
|
2023-03-03 03:20:34 +00:00
|
|
|
} else{
|
|
|
|
for _, key := range message_string {
|
|
|
|
// write once will simulate keyboard press/release, for long press or release, lookup at Write
|
|
|
|
k.WriteOnce(string(key))
|
2023-01-30 01:45:00 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-03 03:20:34 +00:00
|
|
|
|
|
|
|
|
2023-01-30 01:45:00 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
```
|