kyle 0.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/kyle +5 -0
  3. data/lib/kyle.rb +197 -0
  4. metadata +67 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41ce6de3291e40ec0c4ee69c64b67e53a20fbea1
4
+ data.tar.gz: 48724ea7573c317fe55d06e22cc094100a7a9273
5
+ SHA512:
6
+ metadata.gz: 323423abeac94bfb3299f411327736ed17a9d0497f0c0db990a868b05157f9d5236711b69b315fbfe4e4e50ac70798c35f70bed126e93191db5de7b58898e759
7
+ data.tar.gz: 6576b2d82f9a4ec085fe85ced9fd12d0c7106a808a3110918f8a055130d02c68d6dff72df1a113c9d419e31de5e3ec1ea00d73e5e3e6728b68cc5746b15dce01
data/bin/kyle ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'kyle'
4
+
5
+ Kyle.run(ARGV)
data/lib/kyle.rb ADDED
@@ -0,0 +1,197 @@
1
+ #!/usr/bin/ruby
2
+ require 'openssl'
3
+ require 'highline/import'
4
+
5
+
6
+ $ENC_ALGS = [
7
+ "des3", "desx", "des", "cast", "bf",
8
+ "aes128", "aes192", "aes256", "rc4"
9
+
10
+ ]
11
+
12
+ $HSH_ALGS = [
13
+ "sha512", "sha384", "sha256", "sha224", "sha1", "sha",
14
+ "md5", "md4", "ripemd160"
15
+ ]
16
+
17
+ $letters = [
18
+ "q","w","e","r","t","y","u","i","o","p",
19
+ "a","s","d","f","g","h","j","k","l","z",
20
+ "x","c","v","b","n","m"
21
+ ]
22
+
23
+ $bletters = [
24
+ "Q","W","E","R","T","Y","U","I","O","P",
25
+ "A","S","D","F","G","H","J","K","L","Z",
26
+ "X","C","V","B","N","M"
27
+ ]
28
+
29
+ $nums = [
30
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
31
+ ]
32
+
33
+ $schars = [
34
+ ".", "@", "+", "-", "*", "/", "%", "_", "!", ","
35
+ ]
36
+
37
+ $passctable = []
38
+
39
+ $letters.each { |c| $passctable << c }
40
+ $bletters.each { |c| $passctable << c }
41
+ $nums.each { |c| $passctable << c }
42
+ $schars.each { |c| $passctable << c }
43
+
44
+ $animalnames = [
45
+ "Ape", "Bat", "Bear", "Whale", "Crow", "Dog", "Cat", "Wasp",
46
+ "Fox", "Gull", "Jackal", "Lion", "Panda", "Rat", "Shark", "Spider",
47
+ "Turtle", "Wolf", "Zebra"
48
+ ]
49
+
50
+ class Kyle
51
+
52
+ def self.to_hex(s)
53
+ s.each_byte.map { |b| b.to_s(16) }.join
54
+ end
55
+
56
+
57
+ def self.enc_it(alg,val,key)
58
+ #puts "enc_it #{alg} #{to_hex(val)} #{to_hex(key)}"
59
+ begin
60
+ cipher = OpenSSL::Cipher::Cipher.new(alg)
61
+ cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, "kyle", 10000, 32)
62
+ cipher.iv = sha512ize(key)
63
+ cipher.encrypt
64
+ return cipher.update(val) + cipher.final
65
+ rescue OpenSSL::Cipher::CipherError => e
66
+ puts "Error: #{e.message}"
67
+ end
68
+ end
69
+
70
+ def self.iterative_enc(val, key)
71
+ ret = val
72
+ val.each_byte do |c|
73
+ ret = enc_it($ENC_ALGS[c % ($ENC_ALGS.size)], ret, key)
74
+ end
75
+
76
+ return ret
77
+ end
78
+
79
+ def self.hash_it(alg,val)
80
+ #puts "hash_it #{alg} - #{to_hex(val)}"
81
+ OpenSSL::Digest.digest(alg,val)
82
+ end
83
+
84
+ def self.iterative_hash(val)
85
+ ret = val
86
+ val.each_byte do |c|
87
+ ret = hash_it($HSH_ALGS[c % ($HSH_ALGS.size)], ret)
88
+ end
89
+ return ret
90
+ end
91
+
92
+ def self.sha512ize(val)
93
+ hash_it("sha512",val)
94
+ end
95
+
96
+ def self.di_hash(val)
97
+ iterative_hash(iterative_hash(val))
98
+ end
99
+
100
+ def self.hash2pass(val)
101
+ ret = ""
102
+
103
+ # to be sure it is long enough
104
+ h = sha512ize(val)
105
+
106
+ h.each_byte do |c|
107
+ ret += $passctable[c % ($passctable.size)]
108
+ end
109
+
110
+ return ret[0..15]
111
+ end
112
+
113
+
114
+
115
+ def self.generate(hostname,account,port,key)
116
+
117
+ ret = Array.new
118
+
119
+ harr = [ di_hash(hostname), di_hash(account), di_hash(port), di_hash(key) ]
120
+
121
+ v1 = iterative_enc(harr[0],harr[1])
122
+ v2 = iterative_enc(harr[2],harr[3])
123
+
124
+ v = iterative_enc(v1,v2)
125
+
126
+ c = v
127
+ $animalnames.each do |animal|
128
+ c = OpenSSL::PKCS5.pbkdf2_hmac_sha1(c, v, 10000, 32)
129
+
130
+ ret << hash2pass(c)
131
+
132
+ end
133
+
134
+ return ret
135
+ end
136
+
137
+ $testarr = [
138
+ [
139
+ "microsoft.com","bill.gates","666","iKnowWhatYouDidToIBMLastSummer",
140
+ "WW0nQIY.0Rn6D8d2", "nXzU19faM7*gv7,I", "cgu0q7*DuT65r3rY", "ILZ,5vZLl/wRxf9y",
141
+ "Od..eF2k6_l3XHxe", "sedWPnJsSb4DEJw-", "JEr_SzZBoofgI7Tb", "xbbg@ebdz3FA.n6S",
142
+ "5EMS!XZP7WfPLKpO", "LcwDHUu0/ynzdSWE", "5+fDOoY.yrE+ESbj", "VWKqetfVKZtT,FI9",
143
+ "EDe7XvMZ%8tt2vsT", "vks.HPeDVkklS_qb", "hcVznOxvT5YvxIlU", "iBTr-I42uz7h7XnA",
144
+ "fLV,g6%@1G7xpQil", "toMFvN@Zd,b*KBC%", "FYbi/6Udx_4mO3D0"
145
+ ],
146
+ [
147
+ $passctable.join,$passctable.join,$passctable.join,$passctable.join,
148
+ "cuoTJm!UuIYCcQxs", "3HrQ3s/j53A+Rssm", "KK+IV7QE9Imd65hi", "M@FH%uduAIvn/0Fg",
149
+ "C@ffelLPbsh!ps68", "mF%j06cgTaD63v5C", "5pRiaZDk%SY6quet", "d56XIGF8PhHu!TfI",
150
+ "71UES8Six9G48hsc", "kmtu%gr1.k%T!tPy", "zE8*qE+uU.PsOkYY", "77Rbxcaiwp4Fwm.M",
151
+ "qWT0K%tFP8w7_H0S", "2uGyZI.SzAOujmkw", ".QhaGPzV_jnnRj@F", "4FsOh0GfaM4MVUUH",
152
+ "_3r0DzAdYvEp@dlA", "qcWgE@nt9SgUEsjP", "8F1BJ.OlV5Kj!wmM"
153
+ ]
154
+ ]
155
+
156
+ def self.test_it()
157
+ puts "Testing..."
158
+
159
+ failed = false
160
+ (0..1).each do |idx|
161
+ vals = generate($testarr[idx][0],$testarr[idx][1],$testarr[idx][2],$testarr[idx][3])
162
+ vals.each.with_index(0) do |v,i|
163
+ if ($testarr[idx][i+4] != v)
164
+ puts "Test failed: #{$testarr[idx][i+4]} <> #{v}"
165
+ failed = true
166
+ end
167
+ end
168
+ end
169
+ puts "Finished #{failed ? "and Failed" : "successfully"}"
170
+ end
171
+
172
+ def self.run(args)
173
+ if (args.size > 0 && args[0] == "test")
174
+ test_it()
175
+ else
176
+ hostname = ask("Hostname:")
177
+ account = ask("Account:")
178
+ port = ask("Port:")
179
+ key = ask("Key:") { |q| q.echo = false }
180
+ key2 = ask("Key (again):") { |q| q.echo = false }
181
+
182
+ if (key != key2)
183
+ puts "Passes do not match!!"
184
+ exit
185
+ end
186
+
187
+ puts "Calculating..."
188
+ vals = generate(hostname,account,port,key)
189
+
190
+ $animalnames.each.with_index(0) do |animal,i|
191
+
192
+ puts "#{animal}\t#{vals[i]}"
193
+
194
+ end
195
+ end
196
+ end
197
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kyle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Harun Esur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.6.20
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.20
33
+ description: A password manager for paranoids.
34
+ email: harun.esur@sceptive.com
35
+ executables:
36
+ - kyle
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - lib/kyle.rb
41
+ - bin/kyle
42
+ homepage: http://sceptive.com
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements:
61
+ - Ruby should be compiled with openssl support.
62
+ rubyforge_project:
63
+ rubygems_version: 2.0.14
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Kyle
67
+ test_files: []