攻防世界_ezmaze

题目:ezmaze

re选手投递区

链接:https://adworld.xctf.org.cn/challenges/details?hash=8254ba70-6bfd-11ed-ab28-000c29bc20bf&task_category_id=4&rwNmOdr=1676962297545

无壳,64位,打开查看main

__int64 __fastcall main()
{
  _main();
  printf("Welcome to the maze game. Try to get out of the maze and get the flag.\n");
  initmap();
  text_55("%s", Input);
  if ( check(Input) )
    printf("Congratulations on coming out of the maze! The flag is 'flag{your input}'\n");
  else
    printf("What a pity. You're still trapped in the maze :(\n");
  system("pause");
  return 0i64;
}

将输入的调入了内部函数check,

bool __fastcall check(char *ch_0)
{
  int v2; // eax
  char *v3; // rcx
  unsigned int v4; // er8
  unsigned int v5; // edx
  char *v6; // r11
  char v7; // al

  v2 = strlen(ch_0);
  if ( v2 > 0 )
  {
    v3 = ch_0;
    v4 = 0;
    v5 = 0;
    v6 = &ch_0[v2 - 1 + 1];
    while ( 1 )
    {
      v7 = *v3;
      if ( *v3 == 's' )
      {
        ++v5;
      }
      else if ( v7 > 's' )
      {
        if ( v7 != 'w' )
          return 0;
        --v5;
      }
      else if ( v7 == 'a' )
      {
        --v4;
      }
      else
      {
        if ( v7 != 'd' )
          return 0;
        ++v4;
      }
      if ( !realmap[10 * v5 + v4] || v5 > 9 || v4 > 9 )
        break;
      if ( v6 == ++v3 )
        return v4 == 9 && v5 == 9;
    }
  }
  return 0;
}

很明显的思路从(0,0)->(9,9).wsad控制上下左右

现在就是要找到迷宫了

可以看到这个if ( !realmap[10 * v5 + v4] || v5 > 9 || v4 > 9 ),realamp是我们要找的迷宫了,
但是查看到发现没有。。应该是程序运行时才出来的,

main()函数中的initmap();应该就是生成迷宫的了,动态调试一下

选中edit->Exorp data导出即可得到迷宫

最简单的方法手动走出迷宫

flag{sddssdddwddwddsssaasassssddd}

感兴趣的话可以学习一下优先搜索算法得到路径

posted @ 2023-02-21 15:07  gvpn  阅读(112)  评论(0编辑  收藏  举报