Cracking Cisco IOS password hashes: type 5, 7, 8, and 9
Identify Cisco IOS type 5, 7, 8 and 9 passwords, decode type 7 instantly, and crack type 5/8/9 with the right hashcat mode and John the Ripper format.
A Cisco IOS or IOS-XE running-config can carry four completely different kinds of "encrypted" password behind the same password or secret keyword, and only the digit after the dollar sign tells you which one you are looking at. Get that digit wrong and you either waste hours brute-forcing something that was never a hash, or run a tool that never had a chance against it. This is the quick way to tell them apart and the exact command for each.
Reading the config line
username admin password 7 0822455D0A16
username netadmin secret 5 $1$xyz$Nhwt5dnRSXcRBnGfTzNkv1
username svc_backup secret 8 $8$TnGX/fE4KGHOVU$pEhnEvxrEcEAJyQciqGsfttub0jradTYZsAd2LFkddc
username oob secret 9 $9$2MJBozw/9R3UsU$2lFhcKvpghcyw8deP25GOfyZaagyUOGBymkryvOdfo6
password always means type 7 (or type 0, plaintext, if there is no number at all). secret carries the stronger types: 5, 8, or 9. The number before the value, or the character right after the first $, is the whole identification — you don't need the identifier on this site for Cisco lines, just read the prefix. The hash identifier still helps once you've pulled the raw value out of the config and want to confirm it, or if you're handed a bare string with the username ... secret N wrapper already stripped.
Type 7: not a hash, just decode it
Cisco type 7 is a reversible Vigenère-style XOR cipher Cisco has used since the 1990s for things like enable password and PPP/OSPF authentication keys that the device needs to read back in cleartext. It was never meant to resist an attacker with the config file — it only stops someone glancing over your shoulder at a printout. The two-digit prefix (08 above) is the starting offset into a fixed 53-byte key table; every following byte pair is one ciphertext byte XORed with the key byte at the current offset, incrementing by one each step.
Because the key table is fixed and public, decoding takes microseconds and needs no wordlist at all:
python3 -c "
key = 'dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87'
enc = '0822455D0A16'
seed = int(enc[:2])
data = bytes.fromhex(enc[2:])
print(''.join(chr(b ^ ord(key[(seed + i) % len(key)])) for i, b in enumerate(data)))
"
That decodes to the plaintext password directly. There is no hashcat mode and no John format for type 7 because there is nothing to crack — if you see password 7 ... in a config, treat the secret as already compromised. If it is protecting anything live, rotate it; do not spend GPU time on it.
Type 5: md5crypt, nothing Cisco-specific
Cisco type 5 is the enable secret format from classic IOS, and it is exactly standard Unix md5crypt — the same $1$salt$hash scheme covered in sha512crypt and /etc/shadow for its sha512crypt cousin. Cisco just reused an existing crypt() format rather than inventing one, which means every md5crypt tool works unmodified:
echo '$1$xyz$Nhwt5dnRSXcRBnGfTzNkv1' > hash.txt
hashcat -m 500 -a 0 hash.txt rockyou.txt
john --format=md5crypt --wordlist=rockyou.txt hash.txt
md5crypt runs 1,000 MD5 rounds per guess, salted, so it is slow compared to a raw digest but still cheap on a GPU: a wordlist-plus-rules run clears it in minutes for anything not genuinely random. Cisco's own guidance now points administrators toward type 8 or 9 instead, precisely because type 5 falls this easily — if a device still produces type 5 enable secret lines by default instead of type 9, that is a config worth flagging in a review.
Type 8 and type 9: the modern, slow secrets
Cisco introduced type 8 (PBKDF2-HMAC-SHA256, 20,000 iterations) and type 9 (scrypt, N=16384, r=1, p=1) together to replace type 5 with something that actually costs an attacker real time per guess — the same motivation covered in why fast hashes are dangerous. Both are salted and both show up wrapped as secret 8 $8$... or secret 9 $9$....
# Type 8 — PBKDF2-SHA256
echo '$8$TnGX/fE4KGHOVU$pEhnEvxrEcEAJyQciqGsfttub0jradTYZsAd2LFkddc' > hash8.txt
hashcat -m 9200 -a 0 hash8.txt rockyou.txt
john --format=cisco8 --wordlist=rockyou.txt hash8.txt
# Type 9 — scrypt
echo '$9$2MJBozw/9R3UsU$2lFhcKvpghcyw8deP25GOfyZaagyUOGBymkryvOdfo6' > hash9.txt
hashcat -m 9300 -a 0 hash9.txt rockyou.txt
john --format=cisco9 --wordlist=rockyou.txt hash9.txt
The cisco8 and cisco9 John formats need a jumbo build (john --list=formats | grep -i cisco to confirm yours has them); both hashcat modes ship in mainline, no plugin required. Type 9's scrypt cost makes it the closest thing to memory-hard protection Cisco ships, and together with type 8 it benchmarks orders of magnitude slower per guess than type 5 — check with hashcat -b -m 9200 and -b -m 9300 against -b -m 500 on your own card before assuming a network device's secrets will fall quickly. Against either, skip the blind mask attack covered in mask attacks and keyspace unless you know the shape; a targeted wordlist and rule set built around the organization's naming conventions is what actually recovers a type 8/9 secret in practice.
What this means during an assessment
A show running-config or a TFTP-grabbed config file is worth pulling apart line by line rather than feeding wholesale into a cracker. Type 7 values are free wins — decode every one, since network engineers reuse enable and line passwords constantly, and a type 7 PPP secret has cracked more than one neighboring device's type 5 or 8 secret once you know the person's pattern. Type 5 is worth a real wordlist-plus-rules attempt; it is rarely a dead end. Type 8 and 9 are where you budget real GPU time only if the target justifies it, and where a weak, guessable password is still the realistic way in — the algorithm is strong, but these are chosen by the same people who chose everything else in the config.