• Stars
    star
    235
  • Rank 171,079 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created about 9 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Basic keylogger in Go (no C deps)

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()

Writing keypress

Best way is to open an text editor and see how keyboard will react There are 2 methods:

func (k *KeyLogger) WriteOnce(key string) error

and

func (k *KeyLogger) Write(direction KeyEvent, key string) error 

WriteOnce method simulates single key press, eg: press and release letter M

Write writes to keyboard and sync the event. This will keep the key pressed or released until you call another write with other direction eg, if the key is "A" and direction is press, on UI, you will see "AAAAA..." until you stop with release

Probably you want to use WriteOnce method

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

More Repositories

1

godroid

Golang 1.4 beta on Android
Java
137
star
2

agewasm

A simple and secure online client-side Age key generator, encryption and decryption tool built using wasm
HTML
73
star
3

goble

Bluetooth Low Energy for Go
Go
45
star
4

btc-vanity

Generate Bitcoin Vanity Address
Go
27
star
5

yap

YAP! - Yet Another PGP Tool
Dart
17
star
6

mycommander-server

MyCommander Golang server application
Go
9
star
7

monerorpc

Full Monero RPC client(Wallet AND Daemon) written in go
Go
6
star
8

agemobile

Gomobile support for Age
Objective-C
6
star
9

mcastrpc

Golang Multicast JSON RPC Server
Go
6
star
10

vibrator

Port Android vibrator hardware to Go
Go
4
star
11

gogi

A car diagnostic tool written in go
Go
3
star
12

beanrpc

Beanstalkd RPC for go
Go
3
star
13

jsonrpconion

Library for building JSON RPC services on Tor network
Go
2
star
14

droneservo

A drone hardware fun plugin :)
Go
2
star
15

telegram-bots

Telegram bots in go
Go
2
star
16

monion

fast, secure messaging system for developing rich apps on Tor network.
2
star
17

go-mercedes-bot

Mercedes Benz Dealer Slack Bot in go
Go
2
star
18

chrome-image-recognition

Get image tags using image recognition and machine learning.
JavaScript
1
star
19

emacs-setup

My Emacs setup for C/C++ and GoLang
1
star
20

IoTOS

IoT OS for embedded, running OpenWRT or similliar linux distro
1
star
21

codeswholesale

Go wrapper for CodesWholesale API
Go
1
star
22

tor-phishy

A Tor browser plugin which block access to the phising sites.
JavaScript
1
star
23

mycommander

MyCommander Android app
Java
1
star
24

go-mercedes-dealer

Mercedes-Benz Dealer API library for go
Go
1
star
25

electrumrpc

Golang JSON RPC client to talk with Electrum server
Go
1
star
26

oc-steamauth

Steam API authentication for OctoberCMS
PHP
1
star
27

mqtt

Basic MQTT wrapper for Go
Go
1
star