keylogger 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +54 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +16 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +62 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/keylogger.gemspec +31 -0
- data/lib/input_devices.rb +31 -0
- data/lib/keylogger.rb +31 -0
- data/logger.rb +65 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1df41c3a960330c021587440a8f140347a2043a416c6f071ed81054203621d93
|
4
|
+
data.tar.gz: 539b1685543681da269d088092bc1e762ca1de5d468395743e3529975aa18d42
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec8a85cf6e3924bbfb7189b9c77a7b4f5ba3c2cf42659d3e78095851676aa02bf2316c436b439585ca4a0ff30939c843fbb4ceba1e1ffb5debbefd6b858223a4
|
7
|
+
data.tar.gz: 515eadb80cd8436dbac8e27f1d3b71e3c15d2b47f9eabd22fc01bed19644c756f1055f2790d11a844d091b9233aefc8419190cb27dc4cd47925d70ac25299f86
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
version: 2
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
docker:
|
6
|
+
# specify the version you desire here
|
7
|
+
- image: circleci/ruby:3.0.0
|
8
|
+
|
9
|
+
working_directory: ~/repo
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
|
14
|
+
# Download and cache dependencies
|
15
|
+
- restore_cache:
|
16
|
+
keys:
|
17
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
18
|
+
# fallback to using the latest cache if no exact match is found
|
19
|
+
- v1-dependencies-
|
20
|
+
|
21
|
+
- run:
|
22
|
+
name: install dependencies
|
23
|
+
command: |
|
24
|
+
gem install bundler:2.2.5
|
25
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
26
|
+
|
27
|
+
- save_cache:
|
28
|
+
paths:
|
29
|
+
- ./vendor/bundle
|
30
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
31
|
+
|
32
|
+
# run tests!
|
33
|
+
- run:
|
34
|
+
name: run tests
|
35
|
+
command: |
|
36
|
+
mkdir /tmp/test-results
|
37
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
38
|
+
|
39
|
+
bundle exec rspec --format progress \
|
40
|
+
--out /tmp/test-results/rspec.xml \
|
41
|
+
--format progress \
|
42
|
+
$TEST_FILES
|
43
|
+
|
44
|
+
# run rubocop
|
45
|
+
- run:
|
46
|
+
name: run rubocop
|
47
|
+
command: |
|
48
|
+
bundle exec rubocop .
|
49
|
+
|
50
|
+
# collect reports
|
51
|
+
- store_test_results:
|
52
|
+
path: /tmp/test-results
|
53
|
+
- store_artifacts:
|
54
|
+
path: /tmp/test-results
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: disable
|
3
|
+
Metrics/BlockLength:
|
4
|
+
Exclude:
|
5
|
+
- 'spec/**/*.rb'
|
6
|
+
Style/Documentation:
|
7
|
+
Enabled: false
|
8
|
+
Style/FrozenStringLiteralComment:
|
9
|
+
Enabled: false
|
10
|
+
# This is causing breaking changes:
|
11
|
+
Style/ExpandPathArguments:
|
12
|
+
Enabled: false
|
13
|
+
Gemspec/RequiredRubyVersion:
|
14
|
+
Enabled: false
|
15
|
+
Style/StringLiterals:
|
16
|
+
EnforcedStyle: double_quotes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
keylogger (0.0.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
coderay (1.1.3)
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
method_source (1.0.0)
|
13
|
+
parallel (1.21.0)
|
14
|
+
parser (3.0.2.0)
|
15
|
+
ast (~> 2.4.1)
|
16
|
+
pry (0.14.1)
|
17
|
+
coderay (~> 1.1)
|
18
|
+
method_source (~> 1.0)
|
19
|
+
rainbow (3.0.0)
|
20
|
+
rake (13.0.6)
|
21
|
+
regexp_parser (2.1.1)
|
22
|
+
rexml (3.2.5)
|
23
|
+
rspec (3.10.0)
|
24
|
+
rspec-core (~> 3.10.0)
|
25
|
+
rspec-expectations (~> 3.10.0)
|
26
|
+
rspec-mocks (~> 3.10.0)
|
27
|
+
rspec-core (3.10.1)
|
28
|
+
rspec-support (~> 3.10.0)
|
29
|
+
rspec-expectations (3.10.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-mocks (3.10.2)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-support (3.10.2)
|
36
|
+
rubocop (0.93.1)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 2.7.1.5)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
regexp_parser (>= 1.8)
|
41
|
+
rexml
|
42
|
+
rubocop-ast (>= 0.6.0)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
45
|
+
rubocop-ast (1.11.0)
|
46
|
+
parser (>= 3.0.1.1)
|
47
|
+
ruby-progressbar (1.11.0)
|
48
|
+
unicode-display_width (1.8.0)
|
49
|
+
|
50
|
+
PLATFORMS
|
51
|
+
x86_64-linux
|
52
|
+
|
53
|
+
DEPENDENCIES
|
54
|
+
bundler (~> 2.2)
|
55
|
+
keylogger!
|
56
|
+
pry (~> 0.13)
|
57
|
+
rake (~> 13.0)
|
58
|
+
rspec (~> 3.0)
|
59
|
+
rubocop (~> 0.82)
|
60
|
+
|
61
|
+
BUNDLED WITH
|
62
|
+
2.2.28
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 grdw
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Keylogger
|
2
|
+
|
3
|
+
[](https://circleci.com/gh/grdw/keylogger)
|
4
|
+
|
5
|
+
A simple keylogger for logging keyboard events. Only works on these Ruby platforms:
|
6
|
+
|
7
|
+
```
|
8
|
+
x86_64-linux
|
9
|
+
x86_64-linux-gnu
|
10
|
+
```
|
11
|
+
|
12
|
+
More platforms will be added in the future.
|
13
|
+
|
14
|
+
## Usage:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
Keylogger.new("Name of keyboard").listen do |key|
|
18
|
+
puts key
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
You can find the name of your keyboard in `cat /proc/bus/input/devices`.
|
23
|
+
|
24
|
+
|
25
|
+
## FAQ
|
26
|
+
|
27
|
+
Q: I get a "permission denied", what do I do?
|
28
|
+
|
29
|
+
A: Check which group owns these files: `ls -l /dev/input/` and add your own user to that group.
|
data/Rakefile
ADDED
data/keylogger.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "keylogger"
|
6
|
+
spec.version = "0.0.2"
|
7
|
+
spec.authors = ["grdw"]
|
8
|
+
spec.email = ["gerard@grdw.nl"]
|
9
|
+
|
10
|
+
spec.summary = "A basic keylogger"
|
11
|
+
spec.description = "A basic keylogger for linux"
|
12
|
+
spec.homepage = "https://github.com/grdw/keylogger"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
17
|
+
# into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
27
|
+
spec.add_development_dependency "pry", "~> 0.13"
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "rubocop", "~> 0.82"
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Keylogger
|
2
|
+
module InputDevices
|
3
|
+
KEYBOARD_EV = "120013".freeze
|
4
|
+
DEVICE_REGEX = /
|
5
|
+
N:\sName="(?<name>.+)"(\n|.)*
|
6
|
+
H:\sHandlers=.*event(?<event_id>[0-9]+).*(\n|.)*
|
7
|
+
B:\sEV=(?<ev>[0-9]+)
|
8
|
+
/x.freeze
|
9
|
+
|
10
|
+
Device = Struct.new(:name, :event_id, :ev, keyword_init: true)
|
11
|
+
|
12
|
+
def self.find_by_name(name)
|
13
|
+
devices.detect do |device|
|
14
|
+
device.name == name && device.ev == KEYBOARD_EV
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Pick the first keyboard out of the list
|
19
|
+
def self.default
|
20
|
+
devices.detect { |device| device.ev == KEYBOARD_EV }
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.devices
|
24
|
+
contents = File.read("/proc/bus/input/devices")
|
25
|
+
contents.split("\n\n").map do |device|
|
26
|
+
blob = DEVICE_REGEX.match(device).named_captures
|
27
|
+
Device.new(blob)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/keylogger.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative "input_devices"
|
2
|
+
class Keylogger
|
3
|
+
SUPPORTED_PLATFORMS = %w[x86_64-linux x86_64-linux-gnu].freeze
|
4
|
+
FORMAT = "l!<l!<HHI!<".freeze
|
5
|
+
MIN_ID = 0
|
6
|
+
MAX_ID = 59
|
7
|
+
|
8
|
+
DeviceNotFoundError = Class.new(StandardError)
|
9
|
+
WrongPlatformError = Class.new(StandardError)
|
10
|
+
|
11
|
+
def initialize(name = nil)
|
12
|
+
@device = InputDevices.find_by_name(name) || InputDevices.default
|
13
|
+
|
14
|
+
unless SUPPORTED_PLATFORMS.include?(RUBY_PLATFORM)
|
15
|
+
raise WrongPlatformError,
|
16
|
+
"platform #{RUBY_PLATFORM} not supported"
|
17
|
+
end
|
18
|
+
|
19
|
+
raise DeviceNotFoundError unless @device
|
20
|
+
end
|
21
|
+
|
22
|
+
def listen
|
23
|
+
file = File.open("/dev/input/event" + @device.event_id, "rb")
|
24
|
+
loop do
|
25
|
+
line = file.read(24)
|
26
|
+
value = line.unpack(FORMAT).last
|
27
|
+
|
28
|
+
yield value if value > MIN_ID && value < MAX_ID
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/logger.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative "lib/main"
|
2
|
+
|
3
|
+
QWERTY_MAP = {
|
4
|
+
2 => "1",
|
5
|
+
3 => "2",
|
6
|
+
4 => "3",
|
7
|
+
5 => "4",
|
8
|
+
6 => "5",
|
9
|
+
7 => "6",
|
10
|
+
8 => "7",
|
11
|
+
9 => "8",
|
12
|
+
10 => "9",
|
13
|
+
11 => "0",
|
14
|
+
12 => "-",
|
15
|
+
13 => "=",
|
16
|
+
14 => "[BACKSPACE]",
|
17
|
+
15 => "[TAB]",
|
18
|
+
16 => "a",
|
19
|
+
17 => "z",
|
20
|
+
18 => "e",
|
21
|
+
19 => "r",
|
22
|
+
20 => "t",
|
23
|
+
21 => "y",
|
24
|
+
22 => "u",
|
25
|
+
23 => "i",
|
26
|
+
24 => "o",
|
27
|
+
25 => "p",
|
28
|
+
26 => "^",
|
29
|
+
27 => "$",
|
30
|
+
28 => "\n",
|
31
|
+
29 => "[CTRL]",
|
32
|
+
30 => "q",
|
33
|
+
31 => "s",
|
34
|
+
32 => "d",
|
35
|
+
33 => "f",
|
36
|
+
34 => "g",
|
37
|
+
35 => "h",
|
38
|
+
36 => "j",
|
39
|
+
37 => "k",
|
40
|
+
38 => "l",
|
41
|
+
39 => "m",
|
42
|
+
40 => "ù",
|
43
|
+
41 => "*",
|
44
|
+
42 => "[SHIFT]",
|
45
|
+
43 => "<",
|
46
|
+
44 => "w",
|
47
|
+
45 => "x",
|
48
|
+
46 => "c",
|
49
|
+
47 => "v",
|
50
|
+
48 => "b",
|
51
|
+
49 => "n",
|
52
|
+
50 => ",",
|
53
|
+
51 => ";",
|
54
|
+
52 => " =>",
|
55
|
+
53 => "!",
|
56
|
+
54 => "[SHIFT]",
|
57
|
+
55 => "FN",
|
58
|
+
56 => "ALT",
|
59
|
+
57 => " ",
|
60
|
+
58 => "[CAPSLOCK]"
|
61
|
+
}.freeze
|
62
|
+
|
63
|
+
Keylogger.new(ARGV[0]).listen do |key|
|
64
|
+
puts [QWERTY_MAP[key], key].inspect
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: keylogger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- grdw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.82'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.82'
|
83
|
+
description: A basic keylogger for linux
|
84
|
+
email:
|
85
|
+
- gerard@grdw.nl
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".circleci/config.yml"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- keylogger.gemspec
|
99
|
+
- lib/input_devices.rb
|
100
|
+
- lib/keylogger.rb
|
101
|
+
- logger.rb
|
102
|
+
homepage: https://github.com/grdw/keylogger
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubygems_version: 3.2.22
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: A basic keylogger
|
125
|
+
test_files: []
|