uhide 0.0.22 โ 0.0.27
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 +4 -4
- data/bin/uhide +0 -1
- data/lib/uhide/main.rb +59 -62
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7549fe073a8fe7084cda772418064c3ae4a6ee461ed3aa366cd1f2e36f35fbf9
|
4
|
+
data.tar.gz: 745e42dcf130591deb94f771e5a38ee00201c770d006b13e86ca68c05633d861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91e97dea996846aaa2b82a6166aae57504615119ad89250187c00c6d87e3abe1ac9f8bdcb66c2b9e45f48e75903c99a65377ec05978eb7b2d88212a7dd7c886d
|
7
|
+
data.tar.gz: ca79538b4400dfcc213f099ce0c72f1404c7751488f726a0f5e4b00c7d8b1ab04d00cf2f2095feadbc05c6719fe7650f4522587b30385e28d6bc5cb41ed3a4de
|
data/bin/uhide
CHANGED
data/lib/uhide/main.rb
CHANGED
@@ -1,96 +1,58 @@
|
|
1
|
+
INVALID_๐ = 'invalid key'.colorize(:magenta)
|
2
|
+
UNSUPPORTED_๐พ = 'unsupported'.colorize(:magenta) + ' ๐พ'
|
3
|
+
|
1
4
|
$โ = " โ > "
|
2
5
|
$๐ = " ๐ > "
|
3
6
|
$๐ง = -> { ๐๏ธ '๐ง', SecureRandom.random_bytes }
|
4
7
|
$๐ = -> { ๐๏ธ '๐', ActiveSupport::MessageEncryptor.key_len }
|
5
|
-
|
6
|
-
UNSUPPORTED_๐พ = 'unsupported'.colorize(:red) + ' ๐พ'
|
7
|
-
$cache = {}
|
8
|
-
|
9
|
-
def password?
|
10
|
-
๐งผ STDIN.noecho(&:gets)
|
11
|
-
end
|
8
|
+
$๐๏ธ = {}
|
12
9
|
|
13
10
|
def ๐ฝ
|
14
11
|
print "\r"
|
15
12
|
$stdout.flush
|
16
13
|
end
|
17
14
|
|
15
|
+
def ๐งผ ๐๏ธ
|
16
|
+
๐๏ธ.chomp
|
17
|
+
end
|
18
|
+
|
18
19
|
def โ ๐, simple: true
|
19
20
|
print ๐
|
20
|
-
|
21
|
-
|
21
|
+
โ๏ธ = ๐งผ STDIN.noecho(&:gets)
|
22
|
+
$โ๏ธ = โ๏ธ if simple
|
22
23
|
๐ฝ
|
23
|
-
return
|
24
|
-
end
|
25
|
-
|
26
|
-
def ๐งผ ๐๏ธ
|
27
|
-
๐๏ธ.chomp
|
24
|
+
return โ๏ธ
|
28
25
|
end
|
29
26
|
|
30
27
|
def ๐ ๐ท๏ธ: nil
|
31
28
|
if ๐ท๏ธ.nil?
|
32
|
-
puts
|
29
|
+
puts $๐๏ธ['ddllv']
|
33
30
|
else
|
34
|
-
puts
|
31
|
+
puts $๐๏ธ['ddllv'][๐ท๏ธ]
|
35
32
|
end
|
36
33
|
|
37
34
|
๐ = File.read './๐ง'
|
38
35
|
if ๐.empty?
|
39
36
|
๐ = SecureRandom.random_bytes $๐.call
|
40
37
|
File.write './๐ง', Marshal.dump(๐)
|
41
|
-
return
|
38
|
+
return $๐๏ธ['๐ง'] = ๐
|
42
39
|
else
|
43
|
-
return
|
40
|
+
return $๐๏ธ['๐ง'] = Marshal.load(File.read './๐ง')
|
44
41
|
end
|
45
42
|
|
46
43
|
end
|
47
44
|
|
48
45
|
def ๐ ๐ท๏ธ, ๐
|
49
|
-
|
46
|
+
$๐๏ธ['ddllv'][๐ท๏ธ] = ๐
|
50
47
|
๐พ
|
51
48
|
end
|
52
49
|
|
53
|
-
def ๐ค ๐ฃ๏ธ
|
54
|
-
๐พ, ๐ท๏ธ, ๐ = ๐ฃ๏ธ.split
|
55
|
-
|
56
|
-
if ๐พ.nil?
|
57
|
-
return
|
58
|
-
end
|
59
|
-
|
60
|
-
case ๐พ.to_sym
|
61
|
-
when :get
|
62
|
-
if ๐ท๏ธ
|
63
|
-
๐ ๐ท๏ธ: ๐ท๏ธ
|
64
|
-
else
|
65
|
-
๐
|
66
|
-
end
|
67
|
-
|
68
|
-
when :set
|
69
|
-
๐ ๐ท๏ธ, ๐
|
70
|
-
|
71
|
-
when :exit
|
72
|
-
exit!
|
73
|
-
|
74
|
-
when :reset
|
75
|
-
if โ($๐, simple: false) == $password
|
76
|
-
['ddllv', '๐ง', '๐'].each_entry{ |item| File.delete "./#{item}" }
|
77
|
-
exit!
|
78
|
-
else
|
79
|
-
puts INVALID_KEY
|
80
|
-
end
|
81
|
-
|
82
|
-
else
|
83
|
-
puts UNSUPPORTED_๐พ
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
50
|
def ๐พ
|
89
51
|
โ๏ธ = ActiveSupport::MessageEncryptor.new(
|
90
|
-
ActiveSupport::KeyGenerator.new(
|
52
|
+
ActiveSupport::KeyGenerator.new($โ๏ธ).generate_key($๐ง.call, $๐.call)
|
91
53
|
)
|
92
54
|
|
93
|
-
was_bootstrapped = !(not
|
55
|
+
was_bootstrapped = !(not $๐๏ธ['ddllv'])
|
94
56
|
๐ = ๐๏ธ 'ddllv', {}, โ๏ธ: โ๏ธ
|
95
57
|
๐ 'ddllv', ๐, โ๏ธ: โ๏ธ if was_bootstrapped
|
96
58
|
end
|
@@ -107,15 +69,15 @@ def ๐ ๐๏ธ, ๐, โ๏ธ: false
|
|
107
69
|
return ๐
|
108
70
|
end
|
109
71
|
|
110
|
-
def ๐๏ธ ๐๏ธ,
|
111
|
-
if
|
112
|
-
return
|
72
|
+
def ๐๏ธ ๐๏ธ, ๐, โ๏ธ: false
|
73
|
+
if $๐๏ธ[๐๏ธ]
|
74
|
+
return $๐๏ธ[๐๏ธ]
|
113
75
|
end
|
114
76
|
|
115
77
|
begin
|
116
78
|
๐ = File.read "./#{๐๏ธ}"
|
117
79
|
rescue Errno::ENOENT
|
118
|
-
๐ = ๐ ๐๏ธ,
|
80
|
+
๐ = ๐ ๐๏ธ, ๐, โ๏ธ: โ๏ธ
|
119
81
|
end
|
120
82
|
|
121
83
|
if not ๐.empty?
|
@@ -125,7 +87,7 @@ def ๐๏ธ ๐๏ธ, ๐, โ๏ธ: false
|
|
125
87
|
begin
|
126
88
|
๐ = โ๏ธ.decrypt_and_verify ๐
|
127
89
|
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
128
|
-
puts
|
90
|
+
puts INVALID_๐
|
129
91
|
exit!
|
130
92
|
end
|
131
93
|
|
@@ -135,7 +97,42 @@ def ๐๏ธ ๐๏ธ, ๐, โ๏ธ: false
|
|
135
97
|
|
136
98
|
end
|
137
99
|
|
138
|
-
return
|
100
|
+
return $๐๏ธ[๐๏ธ] = ๐
|
101
|
+
end
|
102
|
+
|
103
|
+
def ๐ค ๐ฃ๏ธ
|
104
|
+
๐พ, ๐ท๏ธ, ๐ = ๐ฃ๏ธ.split
|
105
|
+
|
106
|
+
if ๐พ.nil?
|
107
|
+
return
|
108
|
+
end
|
109
|
+
|
110
|
+
case ๐พ.to_sym
|
111
|
+
when :get
|
112
|
+
if ๐ท๏ธ
|
113
|
+
๐ ๐ท๏ธ: ๐ท๏ธ
|
114
|
+
else
|
115
|
+
๐
|
116
|
+
end
|
117
|
+
|
118
|
+
when :set
|
119
|
+
๐ ๐ท๏ธ, ๐
|
120
|
+
|
121
|
+
when :exit
|
122
|
+
exit!
|
123
|
+
|
124
|
+
when :reset
|
125
|
+
if โ($๐, simple: false) == $โ๏ธ
|
126
|
+
['ddllv', '๐ง', '๐'].each_entry { |item| File.delete "./#{item}" }
|
127
|
+
exit!
|
128
|
+
else
|
129
|
+
puts INVALID_๐
|
130
|
+
end
|
131
|
+
|
132
|
+
else
|
133
|
+
puts UNSUPPORTED_๐พ
|
134
|
+
end
|
135
|
+
|
139
136
|
end
|
140
137
|
|
141
138
|
class Uhide::Main
|