ios7crypt 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26b8991718bbf017d58f375bb3b3627f927dddc9
4
+ data.tar.gz: 65b7687704370e04a15f88fda0634f2f4ba1f242
5
+ SHA512:
6
+ metadata.gz: 56a0db85d192e0373baba22d2df6af4eb3f71edd251b62d6ac5dbf07f4444d0005f4ea8ace29196588a9b4b7fa8e17580771f039a3866ded6691bc32b9f6380e
7
+ data.tar.gz: f6440b0b8376ad3933a8bcb21533b3f90903ea3c4c9edc650a6ad811f98457d6c7f19ba8b9bd70f1e3f3d622d945576c03be38859c95260d863ee9412cf695fc
data/LICENSE.md ADDED
@@ -0,0 +1,23 @@
1
+ # FreeBSD License
2
+
3
+ # Copyright 2012 Andrew Pennebaker. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation and/or
12
+ other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED
15
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
17
+ SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/bin/ios7crypt ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'ios7crypt'
4
+
5
+ begin
6
+ main
7
+ rescue Interrupt
8
+ nil
9
+ end
data/lib/ios7crypt.rb ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Author:: Andrew Pennebaker
4
+ # Copyright:: Copyright 2007 - 2013 Andrew Pennebaker
5
+ #
6
+ # == Synopsis
7
+ #
8
+ # ios7crypt: encrypts and decrypts passwords with Cisco IOS7 algorithm
9
+
10
+ def usage
11
+ puts "#{$PROGRAM_NAME} [OPTIONS]
12
+
13
+ --help, -h:
14
+ show help
15
+
16
+ --encrypt, -e <password>
17
+ prints out the encrypted password as a hash
18
+
19
+ --decrypt, -d <hash>
20
+ prints out the decrypted hash as a password
21
+
22
+ --test, -t
23
+ runs unit tests"
24
+
25
+ exit
26
+ end
27
+
28
+ require 'rubygems'
29
+ require 'rubycheck'
30
+ require 'getoptlong'
31
+
32
+ require 'contracts'
33
+ include Contracts
34
+
35
+ #
36
+ # IOS7Crypt
37
+ #
38
+ module IOS7Crypt
39
+ XLAT = [
40
+ 0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f,
41
+ 0x41, 0x2c, 0x2e, 0x69, 0x79, 0x65, 0x77, 0x72,
42
+ 0x6b, 0x6c, 0x64, 0x4a, 0x4b, 0x44, 0x48, 0x53,
43
+ 0x55, 0x42, 0x73, 0x67, 0x76, 0x63, 0x61, 0x36,
44
+ 0x39, 0x38, 0x33, 0x34, 0x6e, 0x63, 0x78, 0x76,
45
+ 0x39, 0x38, 0x37, 0x33, 0x32, 0x35, 0x34, 0x6b,
46
+ 0x3b, 0x66, 0x67, 0x38, 0x37
47
+ ].freeze
48
+ end
49
+
50
+ #
51
+ # Monkeypatch String to feature #encrypt, #decrypt methods.
52
+ #
53
+ class String
54
+ Contract String => String
55
+ def encrypt
56
+ seed = rand(16)
57
+
58
+ hash = (0 .. (length - 1)).map do |i|
59
+ IOS7Crypt::XLAT[(seed + i) % IOS7Crypt::XLAT.length] ^ self[i].ord
60
+ end
61
+
62
+ format('%02d', seed) + hash.map do |e|
63
+ format('%02x', e)
64
+ end.join('')
65
+ end
66
+
67
+ Contract String => String
68
+ def decrypt
69
+ seed = self[0, 2].to_i
70
+
71
+ hash = self[2, length - 1]
72
+
73
+ pairs = (0 .. (hash.length / 2 - 1)).map do |i|
74
+ hash[i * 2, 2].to_i(16)
75
+ end
76
+
77
+ decrypted = (0 .. (pairs.length - 1)).map do |i|
78
+ IOS7Crypt::XLAT[(seed + i) % IOS7Crypt::XLAT.length] ^ pairs[i]
79
+ end
80
+
81
+ decrypted.map { |e| e.chr }.join('')
82
+ end
83
+ end
84
+
85
+ def self.test
86
+ prop_reversible = -> s { s == s.encrypt.decrypt }
87
+ RubyCheck.for_all(prop_reversible, [:gen_str])
88
+ end
89
+
90
+ def main
91
+ mode = :usage
92
+
93
+ password = ''
94
+ hash = ''
95
+
96
+ opts = GetoptLong.new(
97
+ ['--help', '-h', GetoptLong::NO_ARGUMENT],
98
+ ['--encrypt', '-e', GetoptLong::REQUIRED_ARGUMENT],
99
+ ['--decrypt', '-d', GetoptLong::REQUIRED_ARGUMENT],
100
+ ['--test', '-t', GetoptLong::NO_ARGUMENT]
101
+ )
102
+
103
+ opts.each do |option, value|
104
+ case option
105
+ when '--help'
106
+ usage
107
+ when '--encrypt'
108
+ mode = :encrypt
109
+ password = value
110
+ when '--decrypt'
111
+ mode = :decrypt
112
+ hash = value
113
+ when '--test'
114
+ mode = :test
115
+ else
116
+ usage
117
+ end
118
+ end
119
+
120
+ case mode
121
+ when :usage
122
+ usage
123
+ when :encrypt
124
+ puts password.encrypt
125
+ when :decrypt
126
+ puts hash.decrypt
127
+ when :test
128
+ test
129
+ else
130
+ usage
131
+ end
132
+ end
133
+
134
+ if $PROGRAM_NAME == __FILE__
135
+ begin
136
+ main
137
+ rescue Interrupt
138
+ nil
139
+ end
140
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,6 @@
1
+ #
2
+ # IOS7Crypt
3
+ #
4
+ module IOS7Crypt
5
+ VERSION = '0.1'
6
+ end
metadata ADDED
@@ -0,0 +1,273 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ios7crypt
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Pennebaker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: contracts
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: reek
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: flay
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: flog
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: roodi
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: churn
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cane
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: excellent
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: tailor
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: guard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: guard-shell
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0.6'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0.6'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: cucumber
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: aspelllint
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '>='
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ description: See README.md for example usage
238
+ email: andrew.pennebaker@gmail.com
239
+ executables:
240
+ - ios7crypt
241
+ extensions: []
242
+ extra_rdoc_files: []
243
+ files:
244
+ - lib/ios7crypt.rb
245
+ - lib/version.rb
246
+ - LICENSE.md
247
+ - bin/ios7crypt
248
+ homepage: https://github.com/mcandre/rb-ios7crypt
249
+ licenses:
250
+ - FreeBSD
251
+ metadata: {}
252
+ post_install_message:
253
+ rdoc_options: []
254
+ require_paths:
255
+ - lib
256
+ required_ruby_version: !ruby/object:Gem::Requirement
257
+ requirements:
258
+ - - '>='
259
+ - !ruby/object:Gem::Version
260
+ version: '0'
261
+ required_rubygems_version: !ruby/object:Gem::Requirement
262
+ requirements:
263
+ - - '>='
264
+ - !ruby/object:Gem::Version
265
+ version: '0'
266
+ requirements: []
267
+ rubyforge_project:
268
+ rubygems_version: 2.1.10
269
+ signing_key:
270
+ specification_version: 4
271
+ summary: IOS7 password encryptor/decryptor
272
+ test_files: []
273
+ has_rdoc: