uhide 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/uhide.rb +150 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ff1922c774fe0ee1689c5e439ea89e7feb84aa4e1fd247abedbb6b19b64cb22d
|
4
|
+
data.tar.gz: 722655053c515950060d854a6e3a9be18a229e40444729bf9c86d572573df506
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 296ce7ce84cc4821c69adfc71b91fbb77052de38c95aa8a29b5dc64a8171c036e2b86196ab6f11df2b96e7e479ba2db5834c511200bd6ce7c2746f6ceeabb3ab
|
7
|
+
data.tar.gz: e36acce65f04f65f7fd9cd80e7abd4195f6ee9fe266f59b52bd581eaf0270e3ec99bdc5a19caa341f8a6fb85cf88fad47485775fb03b3dc92f36e3d71d3e110d
|
data/lib/uhide.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'io/console'
|
2
|
+
require 'securerandom'
|
3
|
+
require 'active_support'
|
4
|
+
require 'colorize'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
โ = " โ > "
|
8
|
+
$๐ = " ๐ > "
|
9
|
+
$๐ง = (lambda { ๐๏ธ '๐ง', SecureRandom.random_bytes })
|
10
|
+
$๐ = lambda { ๐๏ธ '๐', ActiveSupport::MessageEncryptor.key_len }
|
11
|
+
INVALID_KEY = 'invalid key'.colorize(:red)
|
12
|
+
$cache = {}
|
13
|
+
|
14
|
+
def password?
|
15
|
+
๐งผ STDIN.noecho(&:gets)
|
16
|
+
end
|
17
|
+
|
18
|
+
def ๐ฝ
|
19
|
+
print "\r"
|
20
|
+
$stdout.flush
|
21
|
+
end
|
22
|
+
|
23
|
+
def โ ๐, simple: true
|
24
|
+
print ๐
|
25
|
+
password = password?
|
26
|
+
$password = password if simple
|
27
|
+
๐ฝ
|
28
|
+
return password
|
29
|
+
end
|
30
|
+
|
31
|
+
def ๐งผ ๐๏ธ
|
32
|
+
๐๏ธ.chomp
|
33
|
+
end
|
34
|
+
|
35
|
+
def ๐ ๐ท๏ธ: nil
|
36
|
+
if ๐ท๏ธ.nil?
|
37
|
+
puts $cache['ddllv']
|
38
|
+
else
|
39
|
+
puts $cache['ddllv'][๐ท๏ธ]
|
40
|
+
end
|
41
|
+
|
42
|
+
๐ = File.read './๐ง'
|
43
|
+
if ๐.empty?
|
44
|
+
๐ = SecureRandom.random_bytes $๐.call
|
45
|
+
File.write './๐ง', Marshal.dump(๐)
|
46
|
+
return $cache['๐ง'] = ๐
|
47
|
+
else
|
48
|
+
return $cache['๐ง'] = Marshal.load(File.read './๐ง')
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def ๐ ๐ท๏ธ, ๐
|
54
|
+
$cache['ddllv'][๐ท๏ธ] = ๐
|
55
|
+
๐พ
|
56
|
+
end
|
57
|
+
|
58
|
+
def ๐ค ๐ฃ๏ธ
|
59
|
+
๐พ, ๐ท๏ธ, ๐ = ๐ฃ๏ธ.split
|
60
|
+
|
61
|
+
case ๐พ.to_sym
|
62
|
+
when :get
|
63
|
+
if ๐ท๏ธ
|
64
|
+
๐ ๐ท๏ธ: ๐ท๏ธ
|
65
|
+
else
|
66
|
+
๐
|
67
|
+
end
|
68
|
+
|
69
|
+
when :set
|
70
|
+
๐ ๐ท๏ธ, ๐
|
71
|
+
|
72
|
+
when :reset
|
73
|
+
if โ($๐, simple: false) == $password
|
74
|
+
['ddllv', '๐ง', '๐'].each_entry{ |item| File.delete "./#{item}" }
|
75
|
+
exit!
|
76
|
+
else
|
77
|
+
puts INVALID_KEY
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def ๐พ
|
85
|
+
โ๏ธ = ActiveSupport::MessageEncryptor.new(
|
86
|
+
ActiveSupport::KeyGenerator.new($password).generate_key($๐ง.call, $๐.call)
|
87
|
+
)
|
88
|
+
|
89
|
+
was_bootstrapped = !(not $cache['ddllv'])
|
90
|
+
๐ = ๐๏ธ 'ddllv', {}, โ๏ธ: โ๏ธ
|
91
|
+
๐ 'ddllv', ๐, โ๏ธ: โ๏ธ if was_bootstrapped
|
92
|
+
end
|
93
|
+
|
94
|
+
def ๐ ๐๏ธ, ๐, โ๏ธ: false
|
95
|
+
if โ๏ธ
|
96
|
+
๐ = โ๏ธ.encrypt_and_sign ๐
|
97
|
+
else
|
98
|
+
๐ = ๐
|
99
|
+
end
|
100
|
+
|
101
|
+
๐ = Marshal.dump(๐)
|
102
|
+
File.write "./#{๐๏ธ}", ๐
|
103
|
+
return ๐
|
104
|
+
end
|
105
|
+
|
106
|
+
def ๐๏ธ ๐๏ธ, ๐, โ๏ธ: false
|
107
|
+
if $cache[๐๏ธ]
|
108
|
+
return $cache[๐๏ธ]
|
109
|
+
end
|
110
|
+
|
111
|
+
begin
|
112
|
+
๐ = File.read "./#{๐๏ธ}"
|
113
|
+
rescue Errno::ENOENT
|
114
|
+
๐ = ๐ ๐๏ธ, ๐, โ๏ธ: โ๏ธ
|
115
|
+
end
|
116
|
+
|
117
|
+
if not ๐.empty?
|
118
|
+
๐ = Marshal.load ๐
|
119
|
+
|
120
|
+
if โ๏ธ
|
121
|
+
begin
|
122
|
+
๐ = โ๏ธ.decrypt_and_verify ๐
|
123
|
+
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
124
|
+
puts INVALID_KEY
|
125
|
+
exit!
|
126
|
+
end
|
127
|
+
|
128
|
+
else
|
129
|
+
๐ = ๐
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
return $cache[๐๏ธ] = ๐
|
135
|
+
end
|
136
|
+
|
137
|
+
begin
|
138
|
+
โ $๐
|
139
|
+
|
140
|
+
๐พ
|
141
|
+
|
142
|
+
loop do
|
143
|
+
print โ
|
144
|
+
๐ค(๐งผ gets)
|
145
|
+
end
|
146
|
+
|
147
|
+
rescue SystemExit, Interrupt
|
148
|
+
๐ฝ
|
149
|
+
exit!
|
150
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uhide
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Keen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Allows a regular person to maintain a named list of secrets that's encrypted
|
14
|
+
at rest
|
15
|
+
email: mwk@mikekeen.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/uhide.rb
|
21
|
+
homepage: https://github.com/mkeen/uhide
|
22
|
+
licenses:
|
23
|
+
- ISC (BSD2/MIT)
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.2.0.rc.1
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: "โ๏ธ: Personal encryption fit for a spy"
|
44
|
+
test_files: []
|