1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 08:39:00 +01:00

Added a script that searched for the mode of unencryption that could unencrypt the answer

This commit is contained in:
Sammy Pfeiffer 2015-03-13 18:46:20 +01:00
parent d4e229b084
commit 677ed2f425

54
research_decrypt_mode.py Normal file
View File

@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
# Got from testing.py
encrypted_answer = 'L\xd7\xddI\x0b\xc3\xeay\xf1\x07]\x93\x7fY\x0cmVAX\x03\xeb\n}\x99\xd6\x99\xaa\xba\x05\x9d\xaaB\xe2\x97\xb3\xf2\xf8\xd8\x9f\xa6\x13\x177a\xb45A\x0f}\xb3\x99\xa3D?L\x94\xa3\xbcG\xe8\xf2\x14 \xb9.\x8b\xa0\xf1\xa5\xf1\x18\x9aZ2\x8f\xae\x05\xd9\x84H\xa3&\xad\x84\x82w\x9e\xe8\xba\x8a\x87QT\xdd\x12\x8c\x86\xde\xd8\x7fLM\xb9\x81H;JX\x85\x14\x1af!\xb20\xea)\xa8>(\xa9\xce5,\x96\x14\xd7P\x0c\xb3\x02\x9a\x16\xfc\x94\xacT\xa0\xd4\x82\xe5S1\xf4\xe1\x8cB\xad\x89\xc3C\xa6\rt)\xfa\x0b\xfe3\t\xdd\x02\xbe\xecP\xd6\xd7p\xf6\xf3\xb5\xdf6\xfc\x90l\xaa\x06\x8a\xc0XO\x96>\x85\x18\xebN\x08\x13x\xc0\x1ah\xbd\xedO\x99T\xfd\xed\x87C}\x89!\x99Oz\xfe\x927z~ &"\x0e/\x01N\x13\xfa\xd1\x96\x87\x0f\x83\x98d\x12X\xa7\x8c\xa8\x1c/\xbc\xab\xb2:\x07\xa6\x14\xfa\xe3\xd2\x8cG\xd6\x84\xe4[\x8f\x9e\x8f\xbb\x9c\x8a\x80\xbd\xcf\xaf!\xf7E\x1b\x1f\x91\x18\xc2\x8eBE\xfb\x84\xb6\xc5e5Q\xfd\xb8\xcb\xbc\xb4\x9f\xb7\x92\xfe\xae\xda,\xfaA\x94\x7fq\x1e\xd1\x05\xe8=\x9d#,\xe6\xb7y1\xe6\xc7!\xa0\x0bx\xd1\xb3\xad9\xc4\xdd\x99Y\xca\r\x07+\x903\x1e?\x1d_\x8b\xb0M\xff\x14\xc3:\x95\xa8\xee\xc1\xb5\xff\xfb1\x95\xe1\xcaT\xe4D\xcf\xd2%\x11\xeb@`Att\xbe\x11\xfc/\x05\x9a\xd2\x15\r\xb6\x9d\x88\xae\xa8\xd1q\xe5\x9b\x05A\x8d[\xbf\xaaN\x1b\xee\xbf#4\x1c\xd5\xa4\x1f\x0fo\xaf\xd0\x00g\xc1\x9a\x82\x00\x8c_\xd4\xac!{K\xca\x89x\xde\xf9\x8d\x19\xec\x12\x8epY\xdb\x9f\x98\xe6\x88\xe7\xc1\x92\x90\x17\x80\x03Ry\xf1n\x97e\xe2\x8c\xe9\x8c\xd6<\xba2:\x9f\x06g\x05\xaa#\xf4\xca1\x16o\xb5\x8b\xcd\xfe\x814h\xac\xcd\x0e\xd0\x1c\x0c\xc71\x11\xbe\xa5\xb3#\xcfh\x07)\x91\xc7\xc8iy!\x03\xc8\xf0\xb2\x02\xf3\xc7\xdf\xafXm\xf5\xaf\xdd\xc8\xeb\xb3n7\xe34\xa7R\x8c\xaf\xa3\xb7y\xe7\x12\x0f\x0c\xc2\xa8v\x12E\xc3u\xc8Y\x1fh.\xcf\x01\xae\x8c\x00"v\x99V\xad>\xaf\x08)\x83V*\x9b\xad\xc0\x9c\x94\xa5D[\x08s\x88\xd1\xcb\xf6\xf8j\xa1c\xc1yb\xda\x12\xa1~\xf6\xd1"\x14\x11a\x02\xc1\xd3\xf5'
tmp_aes_key = b'\x82\xeb\x12\x0e\xbeT\x80>!\xaa\x01\xac\xc8\xe1u#d\x1b\x08\xf5G\xc7\xe5g\xa9\xc3\x1d*BC;6'
tmp_aes_iv = b'r\xbb/\xe8\x0bb,T\x19\x17\xf20WsTf\x1d_C\x83|2h\xd3s\x82\xaeVW\x10v\xff'
from Crypto.Cipher import AES
# try all modes
aes_modes = [AES.MODE_CBC, AES.MODE_CFB, AES.MODE_CTR, AES.MODE_ECB, AES.MODE_OFB, AES.MODE_OPENPGP, AES.MODE_PGP]
aes_modes_names = ["AES.MODE_CBC", "AES.MODE_CFB", "AES.MODE_CTR", "AES.MODE_ECB", "AES.MODE_OFB", "AES.MODE_OPENPGP", "AES.MODE_PGP"]
working_modes = []
working_modenames = []
for mode, modename in zip(aes_modes, aes_modes_names):
print("\n\nTrying mode: " + modename + "(" + str(mode) + ")")
try:
crypting_object = AES.new(tmp_aes_key, mode, tmp_aes_iv) # encrypter thing
decrypted_answer = crypting_object.decrypt(encrypted_answer)
print("decrypted_answer: ")
print(decrypted_answer.__repr__())
working_modes.append(mode)
working_modenames.append(modename)
except Exception as e:
print("Exception: " + str(e))
print("\n\nModes " + str(working_modenames) + " (" + str(working_modes) + ") succesfully unencrypted the answer!")
# Output was:
# Trying mode: AES.MODE_CBC(2)
# Exception: IV must be 16 bytes long
#
#
# Trying mode: AES.MODE_CFB(3)
# Exception: IV must be 16 bytes long
#
#
# Trying mode: AES.MODE_CTR(6)
# Exception: 'counter' keyword parameter is required with CTR mode
#
#
# Trying mode: AES.MODE_ECB(1)
# decrypted_answer:
# '\xb4\x87<\xc5&\xe2J\x0e\x96\x1a\x08\xeaSR\xc4!.\x17\x0b]ZI\xd6\xdc\xbd5\x87i\x11\x1b\x9d\x04\x93;\xc5\xd7C\xe1[\xb9\xaa\x95a)\x14\xfd\x8f\xe8\xf8\xc7\xb1~\xdf\xd3\xf7\xf8\xdc\xc4v\xae \xd7\xff\x91\x0c}:\xf45T~\xad\x00w\xde\x98\xe7\xd5b\x7f\xafZg\xd0\x01\x1e\xcaF\xc7\xe4,@kS\xc8|\xe4\xedv\xa3g\x121.\x00\x10X$\x00\xd0\xea\x12\xe0\xc0n\xdd\x9c&\xb3\xd9\x15\x97\xc67\xaeH\xef\xfb\xd9\x8eC\x8b\x99\xb6P\x9f&\x9d\x95a\x00\xc3\xac\xd7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3a\x1c=#\x03\x9b\xb2\x8e\xe0\x95\x9a\xf4R\x8d\xcf\xef\x88\xef\xce|\xe7\x9a5\xfe>\x13\x9d\x13\xe9 \xfc[\x02\xe2QP\xd4\x93\xe3\x15uJ3\xe6\xe1B\x12\xbdy\x81G\x9a*\x93K'
#
#
# Trying mode: AES.MODE_OFB(5)
# Exception: IV must be 16 bytes long
#
#
# Trying mode: AES.MODE_OPENPGP(7)
# Exception: Length of IV must be 16 or 18 bytes for MODE_OPENPGP
#
#
# Trying mode: AES.MODE_PGP(4)
# Exception: MODE_PGP is not supported anymore