keylogger

Basic keylogger in Go (no C deps)

Github星跟踪图

Keylogger

Capture global keyboard events on Linux

Build Status
GoDoc
License MIT

Notes

  • Only Linux based
  • Need root privilages

Installation

go get github.com/MarinX/keylogger

Getting started

Finding keyboard device

There is a helper on finding the keyboard.

 keyboard := keylogger.FindKeyboardDevice()

Which goes through each file device name to find keyword "keyboard"

/sys/class/input/event[0-255]/device/name

and returns the file event path if found

/dev/input/event2

If the function returns empty string, you will need to cat each device name and get the event number.
If you know already, you can easily pass it to constructor

keylogger.New("/dev/input/event2")

Getting keypress

Once the keylogger returns channel event, you can switch by event code as described in input_event.go
For start, you can listen on keyboard state change

keylogger.EvKey

Once you get desire event, there is a helper to parse code into human readable key.

event.KeyString()

NOTE

If you listen on keyboard state change, it will return double results.
This is because pressing and releasing the key are 2 different state change.
There is a helper function which you can call to see which type of state change happend

// returns true if key on keyboard is pressed
event.KeyPress()

// returns true if key on keyboard is released
event.KeyRelease()

Example

You can find a example script in example/main.go

Running tests

No magic, just run

go test -v

Creating key sniffer (needs update)

License

This library is under the MIT License

I don't drink beer, so energy drink will do :)

BTC: 19AtHE6dgKX3R9vJSCSKRyF1saexLcBRep

主要指标

概览
名称与所有者MarinX/keylogger
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2015-09-27 10:17:49
推送于2024-06-20 10:58:46
最后一次提交2024-06-20 12:58:46
发布数0
用户参与
星数244
关注者数8
派生数60
提交数25
已启用问题?
问题数10
打开的问题数4
拉请求数8
打开的拉请求数0
关闭的拉请求数2
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?