前言
关键词:[RC4|加密算法题|密码学|常见加密]
加密算法里有好几个mod 256 然后交换啥的,可以判断为RC4算法,具体看笔记特征值识别
题解
v8 = [0]*46
v8[0] = 0xC6
v8[1] = 0x21
v8[2] = 0xCA
v8[3] = 0xBF
v8[4] = 0x51
v8[5] = 0x43
v8[6] = 0x37
v8[7] = 0x31
v8[8] = 0x75
v8[9] = 0xE4
v8[10] = 0x8E
v8[11] = 0xC0
v8[12] = 0x54
v8[13] = 0x6F
v8[14] = 0x8F
v8[15] = 0xEE
v8[16] = 0xF8
v8[17] = 0x5A
v8[18] = 0xA2
v8[19] = 0xC1
v8[20] = 0xEB
v8[21] = 0xA5
v8[22] = 0x34
v8[23] = 0x6D
v8[24] = 0x71
v8[25] = 0x55
v8[26] = 8
v8[27] = 7
v8[28] = 0xB2
v8[29] = 0xA8
v8[30] = 0x2F
v8[31] = 0xF4
v8[32] = 0x51
v8[33] = 0x8E
v8[34] = 0xC
v8[35] = 0xCC
v8[36] = 0x33
v8[37] = 0x53
v8[38] = 0x31
v8[40] = 0x40
v8[41] = 0xD6
v8[42] = 0xCA
v8[43] = 0xEC
v8[44] = 0xD4
inputStr_length = 45
ctf233 = "Nu1Lctf233"
v3 = 0
tempStr = [0]*256
flag = ""
# 先生成一个tempStr
for i in range(256):
tempStr[i] = i
for j in range(256):
v3 = (tempStr[j]+v3+ord(ctf233[j % 10])) % 256
# 然后交换两个数
temp = tempStr[j]
tempStr[j] = tempStr[v3]
tempStr[v3] = temp
v5 = 0
v6 = 0
v7 = 0
while(v7 < 45):
v5 = (v5+1) % 256
v6 = (v6+tempStr[v5]) % 256
# 交换
temp = tempStr[v5]
tempStr[v5] = tempStr[v6]
tempStr[v6] = temp
#v8[v7] = tempStr[tempStr[v5]+tempStr[v6]] ^ flag[v7] 前面都照着算法走,最后交换律一下完事
flag += chr(v8[v7] ^ tempStr[(tempStr[v5]+tempStr[v6]) & 0xff])
v7 += 1
print(flag)