题目地址:https://buuoj.cn/challenges#Mysterious
题目附件是一个exe,运行起来让我们输入什么东西,尝试输入了一些字符没有反应
使用记事本打开,查看这个exe是64位的还是32位的
PE...L...
是32位的exe文件特征,使用ida打开,Shift+F12
查看字符
点击well done
,找到了类似flag的字符串
在Functions Window
找到这个地址,点击,F5
反汇编查看伪C代码
int __stdcall sub_401090(HWND hWnd, int a2, int a3, int a4)
{
char v5; // [esp+50h] [ebp-310h]
CHAR Text[4]; // [esp+154h] [ebp-20Ch]
char v7; // [esp+159h] [ebp-207h]
__int16 v8; // [esp+255h] [ebp-10Bh]
char v9; // [esp+257h] [ebp-109h]
int v10; // [esp+258h] [ebp-108h]
CHAR String; // [esp+25Ch] [ebp-104h]
char v12; // [esp+25Fh] [ebp-101h]
char v13; // [esp+260h] [ebp-100h]
char v14; // [esp+261h] [ebp-FFh]
memset(&String, 0, 0x104u);
v10 = 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);
v10 = atoi(&String) + 1;
if ( v10 == 123 && v12 == 120 && v14 == 122 && v13 == 121 )
{
strcpy(Text, "flag");
memset(&v7, 0, 0xFCu);
v8 = 0;
v9 = 0;
_itoa(v10, &v5, 10);
strcat(Text, "{");
strcat(Text, &v5);
strcat(Text, "_");
strcat(Text, "Buff3r_0v3rf|0w");
strcat(Text, "}");
MessageBoxA(0, Text, "well done", 0);
}
SetTimer(hWnd, 1u, 0x3E8u, TimerFunc);
}
if ( a3 == 1001 )
KillTimer(hWnd, 1u);
}
return 0;
}
满足
if ( v10 == 123 && v12 == 120 && v14 == 122 && v13 == 121 )
输入的字符长度不能大于6
,否则结束程序,v10
被atoi()
函数转为数字整型并且+1
,那么满足条件的v10
应该为122
,v12
、v13
、v14
对应的Ascii字符为xyz
,所以输入
122xyz
即可得到flag
从伪C代码里面按照程序拼接也可以得到flag
flag{123_Buff3r_0v3rf|0w}