Ejemplo n.º 1
0
def aes_enc():
    return tinyaes.AES(b'0123456789ABCDEF', b'1234567890ABCDEF')
Ejemplo n.º 2
0
#!/usr/bin/env python3
import tinyaes
import zlib

CRYPT_BLOCK_SIZE = 16

# 从crypt_key.pyc获取key,也可自行反编译获取
key = bytes('0000000000000tea', 'utf-8')

inf = open('cup.pyc.encrypted', 'rb')  # 打开加密文件
outf = open('cup.pyc', 'wb')  # 输出文件

# 按加密块大小进行读取
iv = inf.read(CRYPT_BLOCK_SIZE)

cipher = tinyaes.AES(key, iv)

# 解密
plaintext = zlib.decompress(cipher.CTR_xcrypt_buffer(inf.read()))

# 补pyc头(最后自己补也行)
head = open('../struct.pyc', 'rb').read(16)
outf.write(head)

# 写入解密数据
outf.write(plaintext)

inf.close()
outf.close()

Ejemplo n.º 3
0
def test_ivs_of_len_16_or_None_are_ok(iv, aes_enc):
    tinyaes.AES(b'0' * 16, iv)
Ejemplo n.º 4
0
def test_ivs_of_len_not_16_are_raise(iv, aes_enc):
    if len(iv) != 16:
        with pytest.raises(ValueError):
            tinyaes.AES(b'0' * 16, iv)
Ejemplo n.º 5
0
def test_keys_of_len_not_16_are_raise(key, aes_enc):
    if len(key) != 16:
        with pytest.raises(ValueError):
            tinyaes.AES(key)
Ejemplo n.º 6
0
def test_keys_of_len_16_are_ok(key, aes_enc):
    tinyaes.AES(key)
Ejemplo n.º 7
0
def aes_dec3():
    # Different key for decoding test
    return tinyaes.AES(b'56789ABCDEF01234', b'567890ABCDEF1234')
Ejemplo n.º 8
0
def aes_dec2():
    # Different key for decoding test
    return tinyaes.AES(b'ABCDEF0123456789', b'ABCDEF1234567890')
Ejemplo n.º 9
0
def aes_dec():
    # Need to have two same-keys instancies
    return tinyaes.AES(b'0123456789ABCDEF', b'1234567890ABCDEF')