c7decrypt 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/c7decrypt.rb +17 -1
- metadata +5 -5
data/lib/c7decrypt.rb
CHANGED
@@ -24,6 +24,17 @@ class C7Decrypt
|
|
24
24
|
/password 7 ([a-zA-Z0-9]+)/
|
25
25
|
]
|
26
26
|
|
27
|
+
def initialize()
|
28
|
+
@legacy_mode = legacy_mode?
|
29
|
+
end
|
30
|
+
|
31
|
+
# Detect whether we're running in legacy mode or not
|
32
|
+
# Ruby 1.8.x uses [0] for ordinal conversion but does not .ord
|
33
|
+
# Ruby 1.9.x implements .ord but does not support [0] ordinal conversion
|
34
|
+
def legacy_mode?
|
35
|
+
return true if RUBY_VERSION.match(/1\.8\.[67]/)
|
36
|
+
end
|
37
|
+
|
27
38
|
# The Decryption Method for Cisco Type-7 Encrypted Strings
|
28
39
|
# @param [String] the Cisco Type-7 Encrypted String
|
29
40
|
# @return [String] the Decrypted String
|
@@ -45,7 +56,12 @@ class C7Decrypt
|
|
45
56
|
etext = "%02d" % seed
|
46
57
|
pt_chars = plain_text.scan(/./)
|
47
58
|
pt_chars.each_with_index do |char,i|
|
48
|
-
tmp =
|
59
|
+
tmp = nil
|
60
|
+
if @legacy_mode
|
61
|
+
tmp = char[0] ^ VT_TABLE[(i + seed)]
|
62
|
+
else
|
63
|
+
tmp = char.ord ^ VT_TABLE[(i + seed)]
|
64
|
+
end
|
49
65
|
etext += ("%02X" % tmp)
|
50
66
|
end
|
51
67
|
return etext
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c7decrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan Claudius
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-08 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: A library for decoding Cisco Type 7 passwords
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements: []
|
58
58
|
|
59
59
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.8.
|
60
|
+
rubygems_version: 1.8.24
|
61
61
|
signing_key:
|
62
62
|
specification_version: 3
|
63
63
|
summary: Ruby based Cisco Type 7 Password Decryptor
|