拿到题目点开就秒退,推测是直接检测某种flag的形式而不是输入flag进行check。拖进IDA查看字符串
果然看到有用的东西,进行定位分析
int __thiscall sub_402550(int this, int a2, int a3, int a4)
{
int v4; // esi@1
struct _iobuf *v5; // eax@2
int v6; // eax@3
std::codecvt_base *v7; // edi@3
void (__thiscall ***v8)(_DWORD, _DWORD); // eax@7
int result; // eax@9
char v10; // [sp+Ch] [bp-14h]@3
int v11; // [sp+10h] [bp-10h]@6
int v12; // [sp+1Ch] [bp-4h]@3
v4 = this;
if ( *(this + 76) || (v5 = std::_Fiopen("C:\\Users\\CSAW2016\\haha\\flag_dir\\flag.txt", 1, 64)) == 0 )
{
result = 0;
}
else
{
sub_402430(v5, 1);
v6 = std::basic_streambuf<char,std::char_traits<char>>::getloc(v4, &v10);
v12 = 0;
v7 = sub_402C80(v6);
if ( std::codecvt_base::always_noconv(v7) )
{
*(v4 + 56) = 0;
}
else
{
*(v4 + 56) = v7;
std::basic_streambuf<char,std::char_traits<char>>::_Init(v4);
}
v12 = 1;
if ( v11 )
{
v8 = (*(*v11 + 8))();
if ( v8 )
(**v8)(v8, 1);
}
result = v4;
}
return result;
}
大体上运用std::_Fiopen 打开本机文件flag.txt,为配合题目,自行创建一个flag.txt
至于flag的长度,我有看到
进行定位分析
OD动态调试一下发现思路错了
只能在flag.txt上写点内容动态调试程序了
发现问题原来这个字符串实在循环里·输入18位以上都会显示18位,所以长度为18,跟到最后可以看到flag明文对比
flag为idg_cni~bjbfi|gsxb