GUET-CTF2019-encrypt

比对RC4加密算法(CRYPTO-RC4加密 - 知乎 (zhihu.com)),可以确认是RC4加密。然后还有一个魔改base64,就是编码的时候给每位数 +61。

题目难就难在初始识别RC4加密,解密过程是很简单,脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from Crypto.Cipher import ARC4
from binascii import unhexlify

v12 = [
0x5A, 0x60, 0x54, 0x7A, 0x7A, 0x54, 0x72, 0x44, 0x7C, 0x66,
0x51, 0x50, 0x5B, 0x5F, 0x56, 0x56, 0x4C, 0x7C, 0x79, 0x6E,
0x65, 0x55, 0x52, 0x79, 0x55, 0x6D, 0x46, 0x6B, 0x6C, 0x56,
0x4A, 0x67, 0x4C, 0x61, 0x73, 0x4A, 0x72, 0x6F, 0x5A, 0x70,
0x48, 0x52, 0x78, 0x49, 0x55, 0x6C, 0x48, 0x5C, 0x76, 0x5A,
0x45
]# 0x3D

binstring = ''
for i in range(len(v12)):
binstring += bin(v12[i] - 61)[2:].zfill(6)

print(binstring)
print(len(binstring))
s = []
for i in range(0, len(binstring), 8):
s.append(int(binstring[i:i+8], 2))

RC4_cipher = ''.join(hex(i)[2:].zfill(2) for i in s)#zfill(2)补0,毕竟1byte等于两位
print(RC4_cipher)

# RC4 解密
key = ''.join(hex(i)[2:].zfill(2) for i in [16, 32, 48, 48, 32, 32, 16, 64])
RC4_cipher = unhexlify(RC4_cipher.encode())
key = unhexlify(key.encode())
rc4 = ARC4.new(key)
flag = rc4.decrypt(RC4_cipher)
print(flag)


GUET-CTF2019-encrypt
http://example.com/2023/09/04/CTF/GUETCTF2019-encrypt/
作者
gla2xy
发布于
2023年9月4日
许可协议