This Python script decrypts Cisco “type 7” or otherwise insecure passwords used for local users, OSPF keys, and TACACS keys. It can:
.txt
, .log
, or .cisco
) for lines like:
username <USERNAME> privilege 15 password 7 <ENCRYPTED>
interface <INTF_NAME>
…
ip ospf message-digest-key <KEY_ID> md5 7 <ENCRYPTED>
tacacs server <SERVER_NAME>
…
key 7 <ENCRYPTED>
- or -
key <PLAINTEXT>
Interactive Troubleshooting
Quickly decrypt a single Type 7 string on the command line (-s
) when reviewing live device logs or debugging automation failures.
Configuration Reviews
Use recursive directory scans (-d
) to ensure no overlooked files in nested folders—ideal for large teams sharing network standards.
Security Audits
Scan entire configuration repositories (or live exports) to locate insecure (unencrypted or Type 7) credentials without manual searching.
Bulk Reporting
Generate CSV reports (--csv
) for integration into vulnerability management or ticketing systems.
CI/CD Integration
Incorporate into build or compliance pipelines to automatically flag new or changed Cisco configs that contain weak password storage.
usage: c7_decrypt [-h] [-s] [-m] [-d DEPTH] [-c] target
Decrypt Cisco Type 7 lines in files/directories, or a single string.
positional arguments:
target File or directory path (if not using -s), or a raw type-7 string (if -s is set).
options:
-h, --help show this help message and exit
-s, --string Interpret the `target` argument as a raw type-7 encrypted string.
-m, --mask Mask the decrypted passwords (show <MASKED> instead).
-d, --depth DEPTH Recursively parse directories up to this depth (default=0 = non-recursive).
-c, --csv Output results in CSV format.
Decrypt a single Type 7 string:
./c7_decrypt.py -s 15060E1F103A2A373B243A3017
If valid, you’ll see output like:
Decrypted password: testpassword
Parse a single file:
./c7_decrypt.py config.txt
.txt
, .log
, .cisco
).username … password 7 <ENC>
lines.ip ospf message-digest-key <#> md5 7 <ENC>
under interface configurations.key 7 <ENC>
under TACACS server configurations.Parse a directory (non-recursive):
./c7_decrypt.py /path/to/configs
.txt
, .log
, .cisco
files are scanned.Parse a directory (recursive):
./c7_decrypt.py -r 2 /path/to/configs
.txt
, .log
, .cisco
files down to 2 subdirectory levels.Mask the decrypted passwords (e.g., for security audits):
./c7_decrypt.py --mask /path/to/configs
<MASKED>
for each found password.You can emit all findings in CSV format by adding the -c
/--csv
flag (ignored in string mode). The output is written to stdout with these columns:
file,username,type,decrypted_password,ospf_interface,ospf_key_id,ospf_key,tacacs_server,tacacs_key
./c7_decrypt.py --csv /path/to/configs
Produces:
file,username,type,decrypted_password,ospf_interface,ospf_key_id,ospf_key,tacacs_server,tacacs_key
/path/to/configs/router1.txt,testadmin,7,testpassword,,,,,
/path/to/configs/router1.txt,testadmin2,7,testpassword2,,,,,
/path/to/configs/router1.txt,,,,Vlan800,1,testospfkey
/path/to/configs/router1.txt,,,,,,,TACACS_1,testtacacskey
…
To save the CSV directly to a file, use shell redirection (>
or >>
). For example:
# Overwrite or create results.csv ./c7_decrypt.py --csv /path/to/configs > results.csv # Append to an existing file ./c7_decrypt.py --csv /path/to/configs >> results.csv
-s
and provide a non-existent path, it prints:
Error: file or directory does not exist: /bad/path
-s
, it always interprets your argument as a raw Cisco Type 7 encrypted string, never checking the filesystem..txt
, .log
, or .cisco
are parsed to avoid false positives from other file types.No Type 7 passwords or keys found in any file in path: /path/to/dir
Decimal Offset
The first two characters of an encrypted string are interpreted as decimal (0..15). This is a different approach from the “classic” Type 7, which often uses them as hex. Some Cisco devices (certain ASA versions) store the offset that way.
53-Byte Key
The script uses a longer XOR key than the 22-byte string you may find in older references. This key is:
0x64,0x73,0x66,0x64,0x3B,0x6B,0x66,0x6F,0x41,0x2C,
0x2E,0x69,0x79,0x65,0x77,0x72,0x6B,0x6C,0x64,0x4A,
0x4B,0x44,0x48,0x53,0x55,0x42,0x73,0x67,0x76,0x63,
0x61,0x36,0x39,0x38,0x33,0x34,0x6E,0x63,0x78,0x76,
0x39,0x38,0x37,0x33,0x32,0x35,0x34,0x6B,0x3B,0x66,
0x67,0x38,0x37
Allowed Extensions
.txt
, .log
, .cisco
ALLOWED_EXTENSIONS
set.Masking for Security Audits
--mask
allows you to verify where Type 7 passwords exist in your configs, without revealing the actual plaintext. This option is especially useful during internal or external security assessments.MIT License
Copyright (c) 2025 Derek Smiley
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Owner
Contributors
Categories
Products
Catalyst SwitchesCatalyst RoutersIOS XEProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community