exeinfo查看,可知是32位程序,无shell,用IDA直接打开,找到main函数,F5切换代码显示如下:
int __cdecl main_0(int argc, const char **argv, const char **envp)
{
size_t v3; // eax
const char *v4; // eax
size_t v5; // eax
char v7; // [esp+0h] [ebp-188h]
char v8; // [esp+0h] [ebp-188h]
signed int j; // [esp+DCh] [ebp-ACh]
int i; // [esp+E8h] [ebp-A0h]
signed int v11; // [esp+E8h] [ebp-A0h]
char Destination[108]; // [esp+F4h] [ebp-94h] BYREF
char Str[28]; // [esp+160h] [ebp-28h] BYREF
char v14[8]; // [esp+17Ch] [ebp-Ch] BYREF
for ( i = 0; i < 100; ++i )
{
if ( (unsigned int)i >= 0x64 )
j____report_rangecheckfailure();
Destination[i] = 0;
}
sub_41132F("please enter the flag:", v7);
sub_411375("%20s", (char)Str);
v3 = j_strlen(Str);
v4 = (const char *)sub_4110BE(Str, v3, v14);
strncpy(Destination, v4, 0x28u);
v11 = j_strlen(Destination);
for ( j = 0; j < v11; ++j )
Destination[j] += j;
v5 = j_strlen(Destination);
if ( !strncmp(Destination, Str2, v5) )
sub_41132F("rigth flag!\n", v8);
else
sub_41132F("wrong flag!\n", v8);
return 0;
}
可以看到,Destination变量首先赋零初始化,然后读入Str变量,即flag。
flag经过sub_4110BE函数处理后,赋值给Destination,然后逐位加j,最后和Str2做对比。Str2已知,定义如下:
.data:0041A034 Str2 db 'e3nifIH9b_C@n@dH',0 ; DATA XREF: _main_0+142↑o
分析sub_4110BE函数,发现每三个字节一组做处理,并通过aAbcdefghijklmn赋值,这个变量定义如下:
.rdata:00417B30 aAbcdefghijklmn db 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
猜测sub_4110BE函数是base64编码。于是写解码脚本如下:
import base64
a='e3nifIH9b_C@n@dH'
i=0
s=''
for b in a:
s+=chr(ord(b)-i)
i=i+1
print(base64.b64decode(s))
运行结果是"{i_l0ve_you}",可知答案是flag{i_l0ve_you}