keylogger

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2018 License: MIT, MIT Imports: 11 Imported by: 1

README

KeyLogger

Description

Capture global keyboard events on Linux

Installation

go get github.com/MarinX/keylogger

Notes

  • Only Linux based
  • Need root privilages

Example

package main

import (
    "fmt"
    "github.com/MarinX/keylogger"
)

func main() {
    devs, err := keylogger.NewDevices()
    if err != nil {
	    fmt.Println(err)
	    return
    }

    for _, val := range devs {
	    fmt.Println("Id->", val.Id, "Device->", val.Name)
    }

    //keyboard device file, on your system it will be diffrent!
    rd := keylogger.NewKeyLogger(devs[3])

    in, err := rd.Read()
    if err != nil {
	    fmt.Println(err)
	    return
    }

    for i := range in {

	    //we only need keypress
	    if i.Type == keylogger.EV_KEY {
		    fmt.Println(i.KeyString())
	    }
    }
}

Creating key sniffer

License

This library is under the MIT License

Author

Marin Basic

Documentation

Overview

keylogger

keymapper

model

Index

Constants

View Source
const (
	INPUTS        = "/sys/class/input/event%d/device/uevent"
	DEVICE_FILE   = "/dev/input/event%d"
	MAX_FILES     = 255
	MAX_NAME_SIZE = 256
)
View Source
const (
	EV_SYN       = 0x00
	EV_KEY       = 0x01
	EV_REL       = 0x02
	EV_ABS       = 0x03
	EV_MSC       = 0x04
	EV_SW        = 0x05
	EV_LED       = 0x11
	EV_SND       = 0x12
	EV_REP       = 0x14
	EV_FF        = 0x15
	EV_PWR       = 0x16
	EV_FF_STATUS = 0x17
	EV_MAX       = 0x1f
)

event types

Variables

This section is empty.

Functions

This section is empty.

Types

type InputDevice

type InputDevice struct {
	Id   int
	Name string
}

func NewDevices

func NewDevices() ([]*InputDevice, error)

type InputEvent

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

func (*InputEvent) KeyString

func (t *InputEvent) KeyString() string

type KeyLogger

type KeyLogger struct {
	Dev *InputDevice
	// contains filtered or unexported fields
}

func NewKeyLogger

func NewKeyLogger(dev *InputDevice) *KeyLogger

func (*KeyLogger) Read

func (t *KeyLogger) Read() (<-chan InputEvent, error)

func (*KeyLogger) Stop

func (t *KeyLogger) Stop()

Stop stops a current

Jump to

Keyboard shortcuts

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