-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
;)
from certipy.lib.certificate import load_pfx
from cryptography.hazmat.primitives.asymmetric import padding
from asn1crypto import cms
from Crypto.Cipher import PKCS1_OAEP, AES, DES3
from Crypto.PublicKey import RSA
from Crypto.Util.Padding import unpad
import binascii
import hexdump
def decrypt_triple_des(key, iv, ciphertext):
cipher = DES3.new(key, DES3.MODE_CBC, iv)
plaintext = cipher.decrypt(ciphertext)
try:
plaintext = unpad(plaintext, DES3.block_size)
except ValueError:
raise ValueError("Incorrect padding.")
return plaintext
with open("_SMSTSMediaPFX.pfx", "rb") as f:
pfx, cert = load_pfx(f.read(), b"PASSWORD")
with open("pol.xml", "rb") as g:
asn1bytes = g.read()
info = cms.ContentInfo.load(asn1bytes)
digested_data = info['content']
if digested_data['recipient_infos'].native[0]['key_encryption_algorithm']['algorithm'] != 'rsaes_pkcs1v15':
algo = digested_data['recipient_infos'].native[0]['key_encryption_algorithm']['algorithm']
print("{algo} not implemented yet")
session_key = digested_data['recipient_infos'].native[0]['encrypted_key']
key = pfx.decrypt(session_key, padding.PKCS1v15())
if digested_data['encrypted_content_info']['content_encryption_algorithm']['algorithm'].native != 'tripledes_3key':
algo = digested_data['encrypted_content_info']['content_encryption_algorithm']['algorithm'].native
print("{algo} not implemented yet")
iv = digested_data['encrypted_content_info']['content_encryption_algorithm']['parameters'].native
ciphertext = digested_data['encrypted_content_info']['encrypted_content'].native
decrypted_data = decrypt_triple_des(key, iv, ciphertext)
print(decrypted_data.decode('utf-16le'))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels