Created
December 22, 2018 14:49
-
-
Save Eduardo-Ortega102/12923a72097347650856401eced0eb4d to your computer and use it in GitHub Desktop.
A simple utility to decrypt cisco Type 7 passwords
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Based on the documentation from: | |
- http://pen-testing.sans.org/resources/papers/gcih/cisco-ios-type-7-password-vulnerability-100566 | |
- http://wiki.nil.com/Deobfuscating_Cisco_IOS_Passwords | |
translation = [ | |
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 | |
] | |
""" | |
import argparse | |
translation = [ | |
hex(ord(char)) for char in 'dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87' | |
] | |
def hexadecimal(text): | |
return int(text, 16) | |
def decrypt(text): | |
password = '' | |
jump, text = int(text[:2]), text[2:] | |
for i in range(0, len(text), 2): | |
password += chr(hexadecimal(text[i:i+2]) ^ hexadecimal(translation[jump])) | |
jump += 1 % len(translation) | |
return password | |
def argument_parser(): | |
parser = argparse.ArgumentParser(description='A simple utility to decrypt cisco Type 7 passwords') | |
parser.add_argument('text', nargs='+', help='the encrypted password that you want to decrypt') | |
parser.add_argument('-l', '--long-output', action='store_true', help='show a message with the encrypted and decrypted password') | |
return parser | |
def main(): | |
args = argument_parser().parse_args() | |
for text in args.text: | |
if args.long_output: | |
print('{}::{}'.format(text, decrypt(text))) | |
else: | |
print(decrypt(text)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment