keylogger

package module
v0.0.0-...-e3cbbce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

README

go-keylogger

Keylogger written in Go

Build Status

Status: Done

Record keystrokes in Linux environment. Keylogger listens for input events on selected input device and stores decoded hits in a specified log file. The application requires root permissions.

Live

Screenshot Desktop

Features

  • List available input devices
  • Record keystrokes sent to observed input devices (e.g. keyboards)
  • Collect logged input data in log files

Installation

$ go get github.com/mtojek/go-keylogger/cmd/keylogger

Usage

$ keylogger 
Usage: keylogger [--version] [--help] <command> [<args>]

Available commands are:
    devices    Lists available input devices
    record     Records any keys pressed on the selected device
    version    Prints the application version
Examples

List available input devices:

# keylogger devices
Available event devices:
  event0 (name: "AT Translated Set 2 keyboard", path: /dev/input/event0)
  event1 (name: "Power Button", path: /dev/input/event1)
  event2 (name: "Sleep Button", path: /dev/input/event2)
  event3 (name: "VirtualBox mouse integration", path: /dev/input/event3)
  event4 (name: "ImExPS/2 Generic Explorer Mouse", path: /dev/input/event4)

Start recording input events:

# keylogger record --eventPath=/dev/input/event0 --logPath=/tmp/keylogger.log
Start recording...

See recorded keystrokes in the log file/tmp/keylogger.log:

# cat /tmp/keylogger.log 
HELLO
<R_SHIFT>MARCIN <R_SHIFT>TOJEK<L_CTRL><L_CTRL><L_CTRL><L_CTRL><L_CTRL><L_CTRL>C

License

Apache License 2.0

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	EventPath string
	ID        string
	Name      string
}

Device describes generic input interface.

type DeviceManager

type DeviceManager struct{}

DeviceManager allows for listing event devices.

func (*DeviceManager) ListDevices

func (dm *DeviceManager) ListDevices() ([]Device, error)

ListDevices provides a set of available event devices.

type InputEvent

type InputEvent struct {
	Time  syscall.Timeval
	Type  uint16
	Code  uint16
	Value int32
}

InputEvent represents an input device event. Input code can be mapped to strings using KeyMapper.

type KeyMapper

type KeyMapper struct{}

KeyMapper is responsible for mapping uint codes to human readable labels.

func (*KeyMapper) Map

func (km *KeyMapper) Map(code uint16) string

Map method maps key codes to labels.

type KeyRecorder

type KeyRecorder struct{}

KeyRecorder is responsible for recoding key hits.

func (*KeyRecorder) Record

func (kr *KeyRecorder) Record(options *RecorderOptions) error

Record method observes incoming events, maps them to key hits and stores in the log file.

type Logger

type Logger interface {
	Error(string)
}

Logger exposes an interface to collect errors.

type ProcessingError

type ProcessingError struct {
	Error error
	Done  bool
}

ProcessingError wraps runtime error with processing status.

type RecorderOptions

type RecorderOptions struct {
	ShutdownCh <-chan struct{}
	Logger     Logger

	EventPath string
	LogPath   string
}

RecorderOptions stores configuration options of the KeyRecorder.

type Root

type Root struct{}

Root defines required permissions to run the application.

func (*Root) Ensure

func (r *Root) Ensure() error

Ensure method checks if the application is running with root permissions.

Directories

Path Synopsis
cmd
keylogger command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL