-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
24 lines (18 loc) · 1000 Bytes
/
Copy pathmain.py
File metadata and controls
24 lines (18 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from RSADecryptor import *
from keyDecryptor import *
import argparse
# Arguments
parser = argparse.ArgumentParser()
parser.add_argument("-esk", "--encriptedRSA", required=False, help="Encrypted RSA key.")
parser.add_argument("-hpass", "--hardwarePassword", required=False, default="", help="Hardware password of the PLC. Empty string "" by default.")
parser.add_argument("-rsa", "--RSAkey", required=False, help="RSA decrypted key in hex-PEM format.")
parser.add_argument("-pk", "--privateKey", required=False, help="Passphrase + Private encrypted key.")
args = parser.parse_args()
if args.encriptedRSA:
rsa_key = RSADecrypt(bytes.fromhex(args.encriptedRSA), args.hardwarePassword)
print(f"\n[+] Decrypted ({len(rsa_key)} bytes):\n{rsa_key.hex()}")
elif args.RSAkey and args.privateKey:
private_key = KeyDecrypt(args.RSAkey, args.privateKey)
print(f"\n[+] Private key PEM:\n{private_key.decode()}")
else:
print("[x] ERROR: Please specify a valid combination of arguments")