Cisco Commands – Why ‘Enable Secret ‘ Produces Different MD5 Hash

ciscocisco-commandscisco-ios

I am configuring a CISCO's 4331 router password, in Packet Tracer. More specifically I use the command enable secret weakpassword. This command uses by default MD5 to hash the last string (i.e weakpassword) .

The thing is that when I use an online MD5 Hash Generator for 'weakpassword' I get the hash
e04efcfda166ec49ba7af5092877030e
and when I use the pre-mentioned command I get the hash $1$mERr$A4DAiA6cbNxoV7Y2eEVOA0 which apparently is not the same.

Why are the hashes different?

CISCO explicitly mentions that:

Enable secrets are hashed using the MD5 algorithm. As far as anyone at
Cisco knows, it is impossible to recover an enable secret based on the
contents of a configuration file (other than by obvious dictionary
attacks).

Best Answer

Cisco devices add a salt to the passwords before hashing so they can't be cracked with dictionary attacks (such as rainbow tables). The salt is partially made up of the device ID, if I recall.

MD5 is mostly still safe to use but is known to have collisions, so it's almost always suggested to use another hashing algorithm. On some of the more recent versions of Cisco IOS, IOS-XE, IOS-XR, and some of the other OS variants, users can specify the algorithm as part of the configuration.

For example, if you want to use a stronger algorithm, such as SHA256, for the enable password, you can use the command:

enable privilege 15 algorithm-type sha256 secret <password>