[BUUCTF misc]Mysterious

[BUUCTF misc]Mysterious

下载下来是一个exe文件,直接打开,随便输入,发现并没有什么回显

直接用IDApro打开

shift+F12查看字符,看到界面有well done的字样

image-20220911095237836

猜测是输入成功之后出现的字样,点到里面去继续观察

image-20220911095356604

找到了一串类似flag的字符

image-20220911100647526

在左边界面找到这个地址,然后按F5进行反汇编

image-20220911100827091

有上述这样一串代码,我们分析一下

int __stdcall sub_401090(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 )//字符串长度不能大于6
        ExitProcess(0);
      v4 = atoi(String);//atoi函数将字符串数字转为整型数字
      Value = v4 + 1;
      if ( v4 == 122 && String[3] == 120 && String[5] == 122 && String[4] == 121 )//要输出flag的话,就要满足这个if语句里的要求
      {
        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(0, Text, "well done", 0);
      }
      SetTimer(hWnd, 1u, 0x3E8u, TimerFunc);
    }
    if ( a3 == 1001 )
      KillTimer(hWnd, 1u);
  }
  return 0;
}

那个if语句里的要求就是要让v4==122,然后再输入ASCII码为120,121,122的字符,查阅可得分别为xyz,然后进行输入即可得到flag

image-20220911103101640

posted @ 2022-09-11 10:32  Jinx8823  阅读(121)  评论(0编辑  收藏  举报