-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_or_decode_pw.py
executable file
·29 lines (21 loc) · 1.2 KB
/
generate_or_decode_pw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
import sys
import argparse
from mitel.firmware_pw import generate_fw_pw_bundle, decode_fw_pw_bundle
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description = "generate or decode password for Aastra/DeTeWe/Mitel .upk zipped firmwares")
subparsers = parser.add_subparsers(help="sub-command help", dest="subparser_name")
generate_parser = subparsers.add_parser("generate", help="generate a firmware package comment and password combo.")
decode_parser = subparsers.add_parser("decode", help="decode a firmware package comment to reveal the password.")
decode_parser.add_argument("zip_comment", type=str, help="zip comment of the firmware package, use single quotes to wrap the text.")
args = parser.parse_args(args=None if sys.argv[1:] else ['--help'])
bundle = None
if args.subparser_name == "generate":
bundle = generate_fw_pw_bundle()
elif args.subparser_name == "decode":
bundle = decode_fw_pw_bundle(args.zip_comment)
if bundle is not None:
print(f"firmware uuid string: '{bundle[0]}'")
print(f"firmware zip password: '{bundle[1]}'")
print(f"firmware zip comment: '{bundle[2]}'")