陇原战”疫“findmeWP
进入IDA
发现只是判断了长度还和一个字符串进行比较,很明显第一个函数另有玄机,进入sub_4024E0查看。
sub_4024E0
发现这里面利用函数表(不知道叫什么名)执行了两个函数,其中一个函数把之前看到的指向strcmp的指针修改到了真正的验证函数那里,这样我们就找到了真正的逻辑sub_401866。
sub_401866
可以看到传进来的SETCTF2021被变换成了一个256长的串,并和输入一起进入一个函数加密,加密后的串和一个数组比较。但是这里有个问题,最后比较的时候一个char是怎么和一个dword比较的呢,查看汇编代码可以发现,这里其实是比较后两位,而加密函数逻辑也很简单,于是便可以编写脚本了。
汇编代码
这里用了movzx和movsx来进行不同大小数值的传递,而查看比较dword串可以发现它前26个数达的后三字节全部是FF或00,而26以后则全为0。
编写脚本
s=[0x65,0x5f,0xef,0x3f,0xa0,0x66,0x10,0x39,0x81,0xbb,0x3,0x62,0xc7,0xa,0xe6,0xcf,0x47,0x4b,0xe4,0xae,0xa3,0x12,0x1d,0x55,0x29,0x98,0x61,0xac,0xee,0x8a,0xb9,0x11,0x15,0xf5,0x2c,0x3c,0x2a,0x7f,0xd7,0x2f,0xaa,0x80,0x90,0xfe,0x7e,0x97,0x51,0x4e,0x3e,0x7b,0x7,0x20,0x32,0xd1,0xc1,0x82,0x89,0x56,0xe7,0x1e,0x44,0x6f,0x58,0xbf,0x8e,0x21,0x16,0xdc,0xa9,0xc0,0x59,0x22,0x6d,0x93,0xd4,0xbd,0x2d,0xaf,0xa8,0x2,0x8b,0x96,0x42,0x78,0x5a,0xb1,0x64,0x45,0x18,0x50,0xd2,0x9e,0xa4,0x5e,0x4,0xb3,0xf1,0x77,0x8,0x9f,0x67,0x53,0x73,0xdd,0xd,0xa7,0x27,0xa5,0x28,0xfb,0xdb,0x8f,0xe2,0x6,0xcd,0xe,0xf0,0x95,0x5c,0x25,0x70,0x48,0x34,0xb2,0x23,0x3b,0x6b,0x1a,0xa2,0x68,0x30,0xed,0xf7,0x63,0x57,0x69,0x88,0x43,0xdf,0x9d,0x19,0xf6,0x6e,0x36,0xcc,0x13,0xd9,0x4f,0xd5,0xc3,0xc5,0x17,0x91,0x4a,0xb4,0xa6,0xbe,0xb0,0xc9,0x79,0x9c,0xea,0xce,0x3d,0xc6,0xb,0x38,0x85,0x24,0x5d,0xc,0xb8,0xc8,0xfc,0xf8,0x2b,0x52,0x60,0x6c,0x9b,0xfd,0xc4,0xde,0x5,0x84,0xb5,0xd3,0x0,0xca,0xe8,0xd6,0x40,0xba,0xeb,0xe5,0x4c,0xe1,0xda,0x37,0x9,0x41,0xf4,0xcb,0x1c,0xa1,0x6a,0x72,0x7d,0x87,0x14,0x54,0xd8,0x99,0x92,0xab,0x8d,0xf9,0x94,0x35,0xf3,0xb7,0x71,0x75,0xec,0xb6,0xc2,0xe9,0xad,0x8c,0xf,0x7a,0xbc,0x9a,0x1b,0x31,0x83,0x5b,0xe3,0xfa,0x4d,0x7c,0x86,0x76,0x2e,0x1f,0xe0,0x1,0x26,0x3a,0x74,0x49,0x33,0xff,0x46,0xd0,0xf2]
goal=[0xffffffb7,0x52,0xffffff85,0xffffffc1,0xffffff90,0xffffffe9,0x7,0xffffffb8,0xffffffe4,0x1a,0xffffffc3,0xffffffbd,0x1d,0xffffff8e,0xffffff85,0x46,0x0,0x21,0x44,0xffffffaf,0xffffffef,0x70,0x32,0xffffffb5,0x11,0xffffffc6]
for i in range(26):
goal[i]=goal[i]&0xff
k=0
for i in range(1,27):
k = (k + s[i]) % 256
s[i],s[k]=s[k],s[i]
goal[i-1] ^= s[(s[i] + s[k])%256]
for i in goal:
print(chr(i),end='')
另附提取数据的idapython脚本(现敲,可能有错)
ea=起始地址
for i in range(长度):
print(get_wide_byte(ea+i),end=',')
#如果idapython版本较老,这里应该是Byte(大概)
SETCTF{Th1s_i5_E2_5tRcm9!}
应该是Byte(大概)
### SETCTF{Th1s_i5_E2_5tRcm9!}