easy_Maze 攻防世界

工具

IDA

思路展开

maze类:1.内存中画出一张地图(地图变换) 2.明确起点和终点 3.(四个字符对应上下左右)flag就是走出的路径

题目提示是maze类的,找上面三个关键点

int __cdecl main(int argc, const char **argv, const char **envp)
{
  __int64 v3; // rax
  int v5[7]; // [rsp+0h] [rbp-270h]
  int v6; // [rsp+C0h] [rbp-1B0h]
  int v7[7]; // [rsp+D0h] [rbp-1A0h]
  int v8; // [rsp+190h] [rbp-E0h]
  int v9[7]; // [rsp+1A0h] [rbp-D0h]
  int v10; // [rsp+1BCh] [rbp-B4h]
  int v11; // [rsp+1C0h] [rbp-B0h]
  int v12; // [rsp+1C4h] [rbp-ACh]
  int v13; // [rsp+1C8h] [rbp-A8h]
  int v14; // [rsp+1CCh] [rbp-A4h]
  int v15; // [rsp+1D0h] [rbp-A0h]
  int v16; // [rsp+1D4h] [rbp-9Ch]
  int v17; // [rsp+1D8h] [rbp-98h]
  int v18; // [rsp+1DCh] [rbp-94h]
  int v19; // [rsp+1E0h] [rbp-90h]
  int v20; // [rsp+1E4h] [rbp-8Ch]
  int v21; // [rsp+1E8h] [rbp-88h]
  int v22; // [rsp+1ECh] [rbp-84h]
  int v23; // [rsp+1F0h] [rbp-80h]
  int v24; // [rsp+1F4h] [rbp-7Ch]
  int v25; // [rsp+1F8h] [rbp-78h]
  int v26; // [rsp+1FCh] [rbp-74h]
  int v27; // [rsp+200h] [rbp-70h]
  int v28; // [rsp+204h] [rbp-6Ch]
  int v29; // [rsp+208h] [rbp-68h]
  int v30; // [rsp+20Ch] [rbp-64h]
  int v31; // [rsp+210h] [rbp-60h]
  int v32; // [rsp+214h] [rbp-5Ch]
  int v33; // [rsp+218h] [rbp-58h]
  int v34; // [rsp+21Ch] [rbp-54h]
  int v35; // [rsp+220h] [rbp-50h]
  int v36; // [rsp+224h] [rbp-4Ch]
  int v37; // [rsp+228h] [rbp-48h]
  int v38; // [rsp+22Ch] [rbp-44h]
  int v39; // [rsp+230h] [rbp-40h]
  int v40; // [rsp+234h] [rbp-3Ch]
  int v41; // [rsp+238h] [rbp-38h]
  int v42; // [rsp+23Ch] [rbp-34h]
  int v43; // [rsp+240h] [rbp-30h]
  int v44; // [rsp+244h] [rbp-2Ch]
  int v45; // [rsp+248h] [rbp-28h]
  int v46; // [rsp+24Ch] [rbp-24h]
  int v47; // [rsp+250h] [rbp-20h]
  int v48; // [rsp+254h] [rbp-1Ch]
  int v49; // [rsp+258h] [rbp-18h]
  int v50; // [rsp+25Ch] [rbp-14h]
  int v51; // [rsp+260h] [rbp-10h]

  v9[0] = 1;
  v9[1] = 1;
  v9[2] = -1;
  v9[3] = 1;
  v9[4] = -1;
  v9[5] = 1;
  v9[6] = -1;
  v10 = 0;
  v11 = 0;
  v12 = 0;
  v13 = 0;
  v14 = 1;
  v15 = -1;
  v16 = 0;
  v17 = 0;
  v18 = 1;
  v19 = 0;
  v20 = 0;
  v21 = 1;
  v22 = 0;
  v23 = -1;
  v24 = -1;
  v25 = 0;
  v26 = 1;
  v27 = 0;
  v28 = 1;
  v29 = -1;
  v30 = 0;
  v31 = -1;
  v32 = 0;
  v33 = 0;
  v34 = 0;
  v35 = 0;
  v36 = 0;
  v37 = 1;
  v38 = -1;
  v39 = -1;
  v40 = 1;
  v41 = -1;
  v42 = 0;
  v43 = -1;
  v44 = 2;
  v45 = 1;
  v46 = -1;
  v47 = 0;
  v48 = 0;
  v49 = -1;
  v50 = 1;
  v51 = 0;
  memset(v7, 0, 0xC0uLL);
  v8 = 0;
  memset(v5, 0, 0xC0uLL);
  v6 = 0;
  Step_0((int (*)[7])v9, 7, (int (*)[7])v7); #地图变换
  Step_1((int (*)[7])v7, 7, (int (*)[7])v5); #地图变换
  v3 = std::operator<<<std::char_traits<char>>(&_bss_start, "Please help me out!");
  std::ostream::operator<<(v3, &std::endl<char,std::char_traits<char>>);
  Step_2((int (*)[7])v5); #输入,验证
  system("pause");
  return 0;
}

进入Step_2函数

__int64 __fastcall Step_2(int (*a1)[7])
{
  int v1; // eax
  __int64 v2; // rax
  __int64 v3; // rax
  __int64 result; // rax
  __int64 v5; // rax
  char v6[35]; // [rsp+10h] [rbp-30h]
  char v7; // [rsp+33h] [rbp-Dh]
  int v8; // [rsp+34h] [rbp-Ch]
  int v9; // [rsp+38h] [rbp-8h]
  int v10; // [rsp+3Ch] [rbp-4h]

  v10 = 0;
  v9 = 0;
  v8 = 0;   #初始位置[0][0]
  while ( v8 <= 29 && (*a1)[7 * v10 + v9] == 1 )  #最多30步,走1
  {
    std::operator>><char,std::char_traits<char>>(&std::cin, &v7);
    v1 = v8++;
    v6[v1] = v7;
    if ( v7 == 'd' ) #向右
    {
      ++v9;
    }
    else if ( v7 > 'd' ) 
    {
      if ( v7 == 's' ) #向下
      {
        ++v10;
      }
      else
      {
        if ( v7 != 'w' ) #向上
          goto LABEL_14;
        --v10;
      }
    }
    else if ( v7 == 'a' ) #向左
    {
      --v9;
    }
    else
    {
LABEL_14:
      v2 = std::operator<<<std::char_traits<char>>(&_bss_start, "include illegal words.");
      std::ostream::operator<<(v2, &std::endl<char,std::char_traits<char>>);
    }
  }
  if ( v10 != 6 || v9 != 6 ) #结束位置[6][6]
  {
    v5 = std::operator<<<std::char_traits<char>>(&_bss_start, "Oh no!,Please try again~~");
    std::ostream::operator<<(v5, &std::endl<char,std::char_traits<char>>);
    result = 0LL;
  }
  else
  {
    v3 = std::operator<<<std::char_traits<char>>(&_bss_start, "Congratulations!");
    std::ostream::operator<<(v3, &std::endl<char,std::char_traits<char>>);
    output(v6, v8);
    result = 1LL;
  }
  return result;
}

综上:
1.地图两次变换(可通过动态调试找到)
2.起点[0][0]到[6][6]
3.wasd 对应上左下右

动态调试地图(这里小坑,需要设置显示的格式(下图))(设置成4byte_Integer和Signed)easy_Maze 攻防世界_第1张图片
动调dump出地图easy_Maze 攻防世界_第2张图片

地图整出来,走法
easy_Maze 攻防世界_第3张图片
ssddwdwdddssaasasaaassddddwdds

UNCTF{ssddwdwdddssaasasaaassddddwdds}

你可能感兴趣的:(我的CTF之路)