a #index 140 #index 143 = c #临时储存input c = ~(a & c) 141 = c#保存第一次加密 a = c c = 140 c = ~(a & c) 142 = c#保存第二次加密 c = 141 c = 143 c = ~(a & c) a = c c = 142 c = ~(a & c) #C
case 0x18是一个check,这个c是从case 0x17得出来的,可以想到如果c == 0 ,程序就会输出Right,否则输出Wrong
1 2 3 4 5 6 7 8 9 10 11 12
case0x17: // c = c - a v14 = c - dword_6010A4; label_c_v14: c = v14; break; case0x18: // check if ( c ) LABEL_35: v2 = *(_DWORD *)&v1[v2]; else v2 = v0 + 5; break;
注意这里判断是从最后一个字符开始的,那么他是如何判断的呢
大概写一下判断的过程
1 2 3 4 5 6 7
c = 146 #index--->0 c+= v1[0xbc] #c+=5 c = v1[c] #获取常量 a = c c = 146 #index---->0 c+= v1[c8] #+=111 定值 c = v1[c] #获取加密后的数据并和a比较
import ctypes cmp = [0x10, 0x18, 0x43, 0x14, 0x15, 0x47, 0x40, 0x17, 0x10, 0x1D, 0x4B, 0x12, 0x1F, 0x49, 0x48, 0x18, 0x53, 0x54, 0x01, 0x57, 0x51, 0x53, 0x05, 0x56, 0x5A, 0x08, 0x58, 0x5F, 0x0A, 0x0C, 0x58, 0x09] index = 0 flag = [] al = [i for i in range(ord('a'),ord('z')+1)] for i in range(10): al.append(i+ord("0")) for i in range(26): al.append(i+ord("A")) while(1): for c in al: if index >= 0x20: #print(len(flag)) print("".join(flag)) exit() _140 = index + 0x20 a = index + 0x20 _143 = c c = ctypes.c_ulong(~(a & c)) a = c.value c = _140 c = ctypes.c_ulong(~(a & c)).value _142 = c#保存第二次加密 c = _143 c = ctypes.c_ulong(~(a & c)).value a = c c = _142 c = (~(a & c)) + 4294967295 + 1 if c == cmp[index]: #print(_143) flag.append(chr(_143)) index+=1 _140+=1 a+=1 print(flag)