Code to generate Cisco "secret" password hashes?
Solution 1:
As per this website, the OpenSSL command line utility appears to provide the functionality you need:
$ openssl passwd -1 -salt pdQG -table foobar
foobar $1$pdQG$0WzLBXV98voWIUEdIiLm11
$
And there is presumably an equivalent function in the library itself.
I'm not sure if IOS requires you to use specific salt values, but technically there is no reason why it should as long as the string you provide in your 'enable secret' command is a valid MD5 password digest. If you have the opportunity to test, I'd be interested to know your results.
Solution 2:
Cisco appears to require a 4-character salt. By default, without the "-salt
salt" argument, openssl
will generate an 8-character salt.
You can use openssl
to generate a Cisco-compatible hash of "cleartext" with an appropriate random 4-character salt, however, like so:
openssl passwd -salt `openssl rand -base64 3` -1 "cleartext"
The "openssl rand -base64 3
" sub-command generates 3 random bytes and then encodes them in base64 format, which gives you 4 printable characters (exactly what you need for a Cisco-compatible salt).
Thanks to Murali Suriar for the answer (elsewhere on this page) which got me started down the right path to this solution.
Solution 3:
5 I believe refers to the fact that it's type 5, which uses MD5, which means you are going to need 300 playstation 3s. Type 7 is easily cracked and they even have scripts on websites for it. This might be better asked on Stackoverflow.
Solution 4:
Here's a great reference http://haxcess.com/2008/10/21/cisco-password-recovery/
Bottom line is the hash is broken down into a few parts
-> Indicates MD5 algorithm
| -> Salt
| | -> Salt + Password Hash
| | |
$1$mERr$RchIrJirmCXltFBZ2l50l/
Here's a Perl solution that has worked wonders for me in the past. Put this baby in a loop and let it run.
#!/usr/bin/perl
use Crypt::PasswdMD5;
my $hash = unix_md5_crypt('password','salt')