我正在尝试解密来自mirc的FiSH插件加密的一些消息。该插件使用blowfish加密作为模式ECB基于密钥,但首先它将消息加密为code64,然后使用blowfish ECB。问题是当我尝试使用blowfish解密消息后,从base64解码它总是得到相同的错误。 “在ECB模式下,数据必须与块边界对齐”
des加密的消息是:“Probando un mensaje cifrado”
from Crypto.Cipher import Blowfish
from Crypto.Util.Padding import pad, unpad
from os import urandom
import base64
key = b"passw0rd"
text =b"+OK Tnkrh0sIoWb1oS1FT.RQop/.JPXNc.lclFO/gueZ4/ZwN1H0"
decode64 = base64.b64decode(text)
decrypt = Blowfish.new(key,Blowfish.MODE_ECB)
msg = decrypt.decrypt(decode64)
print(msg)
site-packages\Crypto\Cipher\_mode_ecb.py", line 163, in decrypt
raise ValueError("Data must be aligned to block boundary in ECB mode")
ValueError: Data must be aligned to block boundary in ECB mode
WITH NON-STANDARD TABLE:
custom_a = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
standard_a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
DECODE_TRANS = str.maketrans(custom_a,standard_a)
key = b"passw0rd"
text ="Tnkrh0sIoWb1oS1FT.RQop/.JPXNc.lclFO/gueZ4/ZwN1H0"
decode64 = base64.b64decode(text.translate(DECODE_TRANS))
decrypt = Blowfish.new(key,Blowfish.MODE_ECB)
msg = decrypt.decrypt(decode64)
print(msg)
答案 0 :(得分:0)
我在这里看到两个明显的问题。可能会有更多,但这些需要先处理。
在解密之前,您需要从邮件中删除前缀"+OK "
。它不是加密数据的一部分。
FiSH传输的数据不是标准的Base64。它使用您必须考虑的a nonstandard encoding table。