GFSJ0781-【Mysterious】
atoi
一个普通c++程序 点击运行发现是一个验证password题目 我们使用ida打开发现是一个一眼丁真的验证
int __stdcall DialogFunc_0(HWND hWnd, int a2, int a3, int a4)
{
int v4; // eax
char Source[260]; // [esp+50h] [ebp-310h] BYREF
_BYTE Text[257]; // [esp+154h] [ebp-20Ch] BYREF
__int16 v8; // [esp+255h] [ebp-10Bh]
char v9; // [esp+257h] [ebp-109h]
int Value; // [esp+258h] [ebp-108h]
CHAR String[260]; // [esp+25Ch] [ebp-104h] BYREF
memset(String, 0, sizeof(String));
Value = 0;
if ( a2 == 16 )
{
DestroyWindow(hWnd);
PostQuitMessage(0);
}
else if ( a2 == 273 )
{
if ( a3 == 1000 )
{
GetDlgItemTextA(hWnd, 1002, String, 260);
strlen(String);
if ( strlen(String) > 6 )
ExitProcess(0);
v4 = atoi(String);
Value = v4 + 1;
if ( v4 == 122 && String[3] == 'x' && String[5] == 'z' && String[4] == 'y' )
{
strcpy(Text, "flag");
memset(&Text[5], 0, 0xFCu);
v8 = 0;
v9 = 0;
_itoa(Value, Source, 10);
strcat(Text, "{");
strcat(Text, Source);
strcat(Text, "_");
strcat(Text, "Buff3r_0v3rf|0w");
strcat(Text, "}");
MessageBoxA(nullptr, Text, "well done", 0);
}
SetTimer(hWnd, 1u, 0x3E8u, TimerFunc);
}
if ( a3 == 1001 )
KillTimer(hWnd, 1u);
}
return 0;
}
由于 v4 = atoi(String); 能看到前面的数字是122 然后就是 x y z 所以password就是 122xyz 这就要扯到atoi只能解析一个字符串前面的数字 所以 v4 == 122 就是string[012] 的验证字符
同时又因为Value = v4 + 1; 使得flag 为
flag{123_Buff3r_0v3rf|0w}
评论