line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Cisco::Hash;
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1334
|
use strict;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1180
|
|
6
|
2
|
|
|
2
|
|
12
|
use warnings;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
207
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter;
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%02d", q$Revision: 0.02 $ =~ m/ (\d+) \. (\d+) /xg;
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
232
|
use vars qw[
|
13
|
|
|
|
|
|
|
@EXPORT_OK
|
14
|
|
|
|
|
|
|
@XLAT
|
15
|
|
|
|
|
|
|
$EXLAT
|
16
|
2
|
|
|
2
|
|
18
|
];
|
|
2
|
|
|
|
|
6
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
BEGIN {
|
19
|
2
|
|
|
2
|
|
7
|
*import = \&Exporter::import;
|
20
|
2
|
|
|
|
|
47
|
@EXPORT_OK = qw(decrypt encrypt usage);
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
14
|
use Carp;
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1278
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
@XLAT = (
|
26
|
|
|
|
|
|
|
0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f,
|
27
|
|
|
|
|
|
|
0x41, 0x2c, 0x2e, 0x69, 0x79, 0x65, 0x77, 0x72,
|
28
|
|
|
|
|
|
|
0x6b, 0x6c, 0x64, 0x4a, 0x4b, 0x44, 0x48, 0x53,
|
29
|
|
|
|
|
|
|
0x55, 0x42, 0x73, 0x67, 0x76, 0x63, 0x61, 0x36,
|
30
|
|
|
|
|
|
|
0x39, 0x38, 0x33, 0x34, 0x6e, 0x63, 0x78, 0x76,
|
31
|
|
|
|
|
|
|
0x39, 0x38, 0x37, 0x33, 0x32, 0x35, 0x34, 0x6b,
|
32
|
|
|
|
|
|
|
0x3b, 0x66, 0x67, 0x38, 0x37
|
33
|
|
|
|
|
|
|
);
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$EXLAT = scalar@XLAT;
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub decrypt {
|
38
|
1
|
|
|
1
|
1
|
10
|
my $e = shift;
|
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
4
|
$e = uc $e;
|
41
|
|
|
|
|
|
|
|
42
|
1
|
50
|
|
|
|
4
|
die "ERROR: The encrypted string has an odd length but must have an even. Call usage for help."
|
43
|
|
|
|
|
|
|
if length $e & 1;
|
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
12
|
die "ERROR: Invalid character detected. Ensure you only paste the enrcypted password. Call usage for help."
|
46
|
|
|
|
|
|
|
if $e !~ /^[\dA-F]+$/i;
|
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
3
|
my $d;
|
49
|
1
|
|
|
|
|
7
|
my ($eh, $et) = ($e =~ /(..)(.+)/o);
|
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
6
|
for(my $i = 0; $i < length $et ; $i += 2) {
|
52
|
5
|
|
|
|
|
34
|
$d .= sprintf "%c", hex( substr $et, $i, 2 )^$XLAT[ $eh++ % $EXLAT ];
|
53
|
|
|
|
|
|
|
}
|
54
|
1
|
|
|
|
|
4
|
return $d;
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub encrypt {
|
58
|
1
|
|
|
1
|
1
|
11
|
my ($d, $of) = @_;
|
59
|
|
|
|
|
|
|
|
60
|
1
|
50
|
|
|
|
5
|
die "ERROR: Insufficient number of Arguments. Call usage for help."
|
61
|
|
|
|
|
|
|
if @_ != 2;
|
62
|
|
|
|
|
|
|
|
63
|
1
|
50
|
33
|
|
|
15
|
die "ERROR: The offset you provided is not supported. Call usage for help."
|
64
|
|
|
|
|
|
|
if $of < 0 || $of > 52;
|
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
8
|
my $e .= sprintf "%02d", $of;
|
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
5
|
for(my $i = 0; $i < length $d; $i++) {
|
69
|
5
|
|
|
|
|
32
|
$e .= sprintf "%02x", unpack( 'C', substr $d, $i, 1 )^$XLAT[ $of++ % $EXLAT ];
|
70
|
|
|
|
|
|
|
}
|
71
|
1
|
|
|
|
|
5
|
return uc $e;
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub usage {
|
75
|
0
|
|
|
0
|
1
|
|
die <
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
decrypt()
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Paste the encrypted hash without any preceeding information
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Exmaple:
|
82
|
|
|
|
|
|
|
use Cisco::Hash qw(decrypt);
|
83
|
|
|
|
|
|
|
decrypt('1511021F0725'); # Will return 'cisco'
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
encrypt(, )
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
You can define any passphrase you like to encrpyt into a encrypted hash.
|
88
|
|
|
|
|
|
|
Altough it seems that Cisco devices strip of all characters above the
|
89
|
|
|
|
|
|
|
224th position.
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The offset describes at which position of the translate mask encryption
|
92
|
|
|
|
|
|
|
should be startet. Due to the length of the mask (which is 53) allowed
|
93
|
|
|
|
|
|
|
values are 0 to 52 (decimal).
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Example:
|
96
|
|
|
|
|
|
|
use Cisco::Hash qw(encrypt);
|
97
|
|
|
|
|
|
|
encrypt('cisco', 15); # will return '1511021F0725'
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
THIS SOFTWARE IS NEITHER INTENDED FOR MALICIOUS USE NOR FOR THE USE
|
100
|
|
|
|
|
|
|
IN ANY OTHER ILLEGAL PURPOSES.
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
EOF
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1;
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__
|