Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!
Many administrators don't realize how easily someone could crack a Cisco IOS password. In fact, it's quite a simple process. Let's examine the different types of Cisco passwords and discuss how you can ensure they stay secret.
To begin, keep in mind that I'm not trying to teach anyone how to become a cracker. Rather, I believe it's important that administrators understand this process so they can better protect their routers' administrative passwords.
There are three types of Cisco passwords: clear-text passwords, type 7 encryption, and type 5 encryption. Let's take a look at the pros and cons of each.
It should go without saying that clear-text passwords are completely insecure. Basically, if someone can view your router's configuration, then he or she can also see the password since it has no encryption at all. In other words, clear-text passwords offer almost no benefits.
Type 7 encryption
Type 7 encrypted passwords are weak, and it can be surprisingly easy to crack them. In fact, one could accomplish this using a six-line Perl script. (You can find this script and directions on the Tech FAQ Web site.)
In addition, Windows-based programs are available that allow you to enter a decrypted password, and the program will immediately return the clear-text password. (SolarWinds sells a password decryptor for this purpose.)
Finally, you can find a Java applet on the Web that decrypts Cisco passwords, and you can download an offline version for your own use.
Type 5 encryption
Encrypted with the MD5 algorithm, type 5 passwords are the most secure of the three. There is currently no known method for decrypting a type 5 password.
The only way to crack a type 5 password is by initiating a brute-force or dictionary attack. In addition, programs are available to do this on the Web. To learn how to protect your systems from such an attack, check out this article, "Protect your router from a dictionary DoS attack."
Protecting your passwords
With the exception of a brute-force dictionary attack, all of these password-cracking methods rely on the event that someone somehow gains access to your router's configuration files in the first place. Of course, the chance of this happening becomes less likely when you've stored the configuration on the router and made it mandatory to have administrator privileges to access the configuration.
However, that doesn't mean it can't happen. Here are some possible scenarios:
- Like a good administrator, you back up your configuration files to a TFTP server. However, the configuration file directory has NTFS or shared permissions for either everyone or all authenticated users. If someone can access the configuration file, he or she could easily decode a type 7 password and then gain access to the real router.
- Like some organizations, you provide a username and password to support personnel that has read-only access to the configuration file. However, if someone has permission to read the file, he or she could easily decode a type 7 password.
The almost foolproof way to gain access to a router's configuration file is from the console. If someone can access the router's console, he or she can also view the configuration file and—of course—perform password recovery. This is why physical security for routers is so important.
Locking down access with commands
Cisco has an IOS command called no service password-recovery. This command prevents anyone with console access from accessing the router configuration and clearing the password. (For documentation of this command, check out Cisco's Web site.)
In addition, you should always use the enable secret command rather than the enable password command. The enable password command uses the weaker type 7 encryption, whereas the enable secret command uses the stronger type 5 encryption.
Cisco also has the service password-encryption command. But even with this command, all other passwords on the router remain encrypted with only the weaker type 7 encryption. To encrypt any username passwords, use the command username secret instead of the normal username command. (For more information, see Cisco's documentation for this command.)
Lock down routers with these steps
In summary, to protect your routers, take the following steps:
- Whenever possible, always use type 5 encryption, using commands such as enable secret and username secret.
- Whenever storing your router's configuration somewhere off the router itself, take steps to protect access to the configuration by setting the proper permissions.
- Use as much physical security as reasonably possible to protect access to the router's console.
David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.