NewStar MazE re wp

参考MazE | WriteUp - NewStar CTF 2024NewStar CTF week4-CSDN博客

先根据提示阅读Linux下进程间通信方式——pipe(管道) - cs_wu - 博客园管道机制大概是什么

64位无壳

写道注释里

__int64 __fastcall main(int a1, char **a2, char **a3)
{
  size_t v4; // rax
  size_t v5; // rax
  size_t v6; // rax
  int v7; // [rsp+Ch] [rbp-3034h] BYREF
  int v8; // [rsp+10h] [rbp-3030h] BYREF
  __pid_t v9; // [rsp+14h] [rbp-302Ch]
  ssize_t v10; // [rsp+18h] [rbp-3028h]
  int pipedes[2]; // [rsp+20h] [rbp-3020h] BYREF
  int v12[2]; // [rsp+28h] [rbp-3018h] BYREF
  char s[16]; // [rsp+30h] [rbp-3010h] BYREF
  char v14[16]; // [rsp+1030h] [rbp-2010h] BYREF
  char buf[16]; // [rsp+2030h] [rbp-1010h] BYREF
  unsigned __int64 v16; // [rsp+3038h] [rbp-8h]

  v16 = __readfsqword(0x28u);
  if ( pipe(pipedes) == -1 || pipe(v12) == -1 ){
    perror("pipe failed");
    return 1LL;
  }
  else {
    v9 = fork(); // 创建一个子线程,> 0 为父进程
    if ( v9 == -1 ){
      perror("fork failed");
      return 1LL;
    }
    else{
      if ( v9 ) {
        // 进程通信,父进程关闭了 pipedes[0](读取端),保留了 pipedes[1](写入端),关闭v12写
        close(pipedes[0]);
        close(v12[1]);
        read(v12[0], buf, 0x1000uLL);//读
        puts("This is a maze game.you need to go from the upper left corner of the maze to the lower right corner.");
        puts("The current interface only displays a 3*3 rectangular area centered on the current position.");//这里提示是3*3一个个去生成迷宫的(类似视野)
        puts("You can use 'w''a''s''d' on your keyboard to move");
        puts("Your flag is flag{md5(path)},and the path is the shortest path");
        puts("hint:The path length is 936!!!!So don鈥檛 think about doing it manually");
        printf("%s", buf);
        while ( 1 ){
          __isoc99_scanf("%s", s);
          system("clear");
          v4 = strlen(s);
          write(pipedes[1], s, v4 + 1);
          if ( !strcmp(s, "exit") )
            break;
          memset(buf, 0, 0x64uLL);
          read(v12[0], buf, 0x64uLL);
          puts(buf);
        }
        close(v12[0]);
        close(pipedes[1]);
      }
      else{
        close(v12[0]);
        close(pipedes[1]);
        v7 = 1;
        v8 = 1;
        sub_1469(v14, 1, 1);
        sleep(0);
        v5 = strlen(v14);
        write(v12[1], v14, v5 + 1);
        while ( 1 )
        {
          memset(buf, 0, 0x1000uLL);
          v10 = read(pipedes[0], buf, 0x1000uLL);
          if ( !strcmp(buf, "exit") )
            break;
          sub_168F(buf, (unsigned int)v10, &v7, &v8);
          memset(v14, 0, 0x1000uLL);
          sub_1469(v14, v7, v8);
          sleep(0);
          v6 = strlen(v14);
          write(v12[1], v14, v6 + 1);
        }
        close(pipedes[0]);
        close(v12[1]);
      }
      return 0LL;
    }
  }
}

父进程从管道中获得地图输出,从终端读取输入输入到另一个管道;子进程通过管道从父进程获得用户输入,然后将更新后的地图输入到管道。

推测:

sub_1469(v14, 1, 1);:

  • 这个函数在初始化时被调用,参数是 (v14, 1, 1),这可能代表 初始位置(例如,迷宫的左上角)。函数名可能暗示它与迷宫生成或视图更新有关。由于它在主逻辑中被首次调用并且没有先前的状态,因此可以推测它会生成一个初始的迷宫视图。

sub_168F(buf, (unsigned int)v10, &v7, &v8);:

  • 这个函数在读取玩家输入后被调用,参数包含玩家的输入(buf)和当前玩家的位置(v7v8)。通过这个函数,程序能够获取到玩家的移动指令,并可能更新他们的位置。

sub_1469(v14, v7, v8);:

  • 在玩家位置更新后再次调用这个函数,并传递了 v7v8 作为参数,这表明函数会根据新的玩家位置生成更新后的迷宫视图。

我们看一下1469

image-20241101200655512

这就是产生3*3迷宫的的逻辑,下面还有几个函数sub141B

image-20241101200736098

image-20241101200746956

image-20241101200757871

到这迷宫的建立逻辑结束了我们可以写脚本来生成迷宫

unk = [
  0x8B, 0x98, 0x8D, 0x9B, 0x9B, 0x99, 0xCA, 0xCA, 0x8B, 0x98,
  0x8D, 0x9B, 0x94, 0x22, 0x74, 0x25, 0x70, 0x26, 0x76, 0x64,
  0x74, 0x72, 0x35, 0x75, 0x63, 0xCC, 0xD9, 0xCE, 0x9A, 0xCD,
  0xDB, 0x8A, 0x8E, 0x9D, 0xCD, 0xCF, 0x9E, 0xB3, 0x20, 0x20,
  0x34, 0x23, 0x62, 0x35, 0x60, 0x22, 0x61, 0x71, 0x30, 0x3D,
  0xC8, 0xDE, 0xCF, 0x99, 0xCF, 0xCE, 0xCA, 0xD9, 0xC8, 0xCF,
  0x9A, 0xDD, 0x24, 0x64, 0x31, 0x26, 0x32, 0x35, 0x65, 0x72,
  0x24, 0x20, 0x30, 0x36, 0x1D, 0xCE, 0x8B, 0xCD, 0x9E, 0xCF,
  0xCB, 0xC9, 0x99, 0x8A, 0xCF, 0xCD, 0x99, 0x70, 0x25, 0x73,
  0x37, 0x25, 0x34, 0x72, 0x64, 0x74, 0x60, 0x72, 0x67, 0x8F,
  0xCA, 0x9C, 0xCE, 0x9E, 0xDF, 0x99, 0x98, 0x9F, 0x8F, 0x8C,
  0x9B, 0x84, 0x30, 0x37, 0x32, 0x71, 0x35, 0x26, 0x24, 0x74,
  0x25, 0x62, 0x26, 0x32, 0x8A, 0x8C, 0xCA, 0xCF, 0xDF, 0x8C,
  0x8C, 0x8F, 0xCE, 0x9C, 0x8F, 0xDF, 0xB0, 0x76, 0x22, 0x65,
  0x75, 0x63, 0x31, 0x24, 0x30, 0x23, 0x22, 0x21, 0x7B, 0x9C,
  0xDF, 0xCA, 0xDF, 0x89, 0xCC, 0xDE, 0x8F, 0x89, 0x8A, 0xCB,
  0xCF, 0x66, 0x33, 0x34, 0x71, 0x77, 0x75, 0x61, 0x25, 0x26,
  0x76, 0x64, 0x34, 0x08, 0x9B, 0xDF, 0x8E, 0x9D, 0x9D, 0xDE,
  0xDE, 0x8C, 0xDA, 0x8A, 0x9E, 0x8A, 0x66, 0x25, 0x25, 0x23,
  0x64, 0x31, 0x25, 0x23, 0x33, 0x71, 0x65, 0x33, 0x9A, 0xDA,
  0x9B, 0xC9, 0xD8, 0x8A, 0xCF, 0x8D, 0xDA, 0x9F, 0xDB, 0x8D,
  0xC6, 0x61, 0x60, 0x72, 0x65, 0x71, 0x21, 0x66, 0x37, 0x71,
  0x30, 0x77, 0x23, 0xCF, 0xDA, 0x9C, 0xD9, 0x9E, 0x8E, 0x9D,
  0xDF, 0xDF, 0xDE, 0x9D, 0x8C, 0xB5, 0x30, 0x26, 0x70, 0x75,
  0x35, 0x26, 0x32, 0x35, 0x30, 0x27, 0x65, 0x6F, 0xDE, 0xC8,
  0x88, 0x8F, 0x9B, 0x99, 0x9E, 0xDB, 0x9A, 0x99, 0x98, 0x8F,
  0x71, 0x33, 0x25, 0x64, 0x30, 0x77, 0x37, 0x21, 0x71, 0x72,
  0x24, 0x30, 0x0F, 0xDC, 0xD8, 0x9E, 0x8A, 0xDC, 0xDE, 0x8F,
  0xDA, 0xC9, 0xDC, 0x9B, 0xC9, 0x77, 0x20, 0x71, 0x25, 0x76,
  0x66, 0x20, 0x30, 0x23, 0x71, 0x25, 0x71, 0xDC, 0xC8, 0x8E,
  0xDF, 0xC9, 0x8B, 0xCE, 0xCF, 0x89, 0xD9, 0x9B, 0xCB, 0xD7,
  0x65, 0x70, 0x20, 0x23, 0x63, 0x61, 0x61, 0x63, 0x20, 0x31,
  0x61, 0x20, 0xD9, 0x9A, 0xDE, 0xDD, 0xCE, 0x9B, 0xCB, 0xD9,
  0xDC, 0xDF, 0xDF, 0xCD, 0xF1, 0x24, 0x60, 0x33, 0x72, 0x21,
  0x74, 0x72, 0x61, 0x24, 0x31, 0x62, 0x29, 0x9E, 0xCA, 0xDC,
  0xCA, 0xDE, 0xCE, 0xDD, 0x98, 0x9B, 0xCF, 0xD9, 0x9E, 0x74,
  0x65, 0x62, 0x32, 0x71, 0x70, 0x32, 0x64, 0x64, 0x70, 0x27,
  0x63, 0x0F, 0xDB, 0x88, 0x9A, 0xCF, 0xCE, 0xDD, 0x98, 0xCE,
  0xCF, 0x98, 0xCF, 0xD8, 0x65, 0x62, 0x27, 0x64, 0x20, 0x32,
  0x70, 0x20, 0x21, 0x67, 0x22, 0x35, 0xDF, 0xC9, 0x9F, 0x8A,
  0xCB, 0x89, 0xCC, 0xCF, 0xCE, 0xD9, 0x9F, 0xCE, 0xC0, 0x73,
  0x63, 0x30, 0x74, 0x22, 0x74, 0x60, 0x61, 0x33, 0x76, 0x30,
  0x22, 0xD8, 0xCE, 0xDF, 0xCF, 0x8D, 0xDD, 0xCE, 0x9E, 0xCD,
  0x8A, 0xCF, 0xCF, 0xB3, 0x62, 0x65, 0x60, 0x23, 0x61, 0x60,
  0x34, 0x32, 0x77, 0x64, 0x70, 0x7C, 0x9F, 0xCA, 0x9B, 0x9D,
  0xD8, 0x8E, 0xCB, 0x9C, 0x8A, 0x9A, 0x8A, 0x9C, 0x67, 0x74,
  0x65, 0x76, 0x64, 0x64, 0x71, 0x76, 0x23, 0x75, 0x60, 0x22,
  0x4B, 0xCB, 0x8B, 0x89, 0x89, 0x8A, 0x9A, 0xCC, 0x9F, 0x9B,
  0x9E, 0x89, 0xCE, 0x75, 0x74, 0x23, 0x24, 0x31, 0x65, 0x76,
  0x67, 0x30, 0x75, 0x23, 0x24, 0x8B, 0xDB, 0xDD, 0xDC, 0xDE,
  0x9A, 0xC9, 0xCB, 0x9B, 0x9B, 0x89, 0xDC, 0xD0, 0x71, 0x62,
  0x71, 0x64, 0x24, 0x76, 0x76, 0x75, 0x75, 0x63, 0x20, 0x23,
  0x8F, 0xCC, 0xCC, 0x8E, 0xCE, 0x99, 0xDB, 0x8E, 0x9A, 0x9D,
  0xDC, 0xCA, 0xA5, 0x63, 0x21, 0x64, 0x21, 0x37, 0x66, 0x21,
  0x21, 0x66, 0x71, 0x60, 0x6A, 0xDC, 0x88, 0xCE, 0x9E, 0xCD,
  0xCF, 0xDA, 0xDA, 0xD8, 0x8D, 0x8E, 0x8B, 0x77, 0x35, 0x61,
  0x25, 0x32, 0x33, 0x20, 0x20, 0x36, 0x71, 0x21, 0x34, 0x08,
  0xCD, 0x9E, 0x9E, 0xDC, 0xDE, 0x9E, 0x9E, 0x8C, 0xD8, 0xDE,
  0xDB, 0x8A, 0x74, 0x35, 0x35, 0x76, 0x33, 0x30, 0x61, 0x22,
  0x31, 0x64, 0x31, 0x62, 0xC9, 0x8B, 0x9B, 0xD9, 0x9A, 0xDF,
  0xCF, 0xC9, 0x9D, 0x9F, 0xCB, 0xCC, 0x81, 0x74, 0x30, 0x73,
  0x62, 0x21, 0x70, 0x22, 0x64, 0x31, 0x60, 0x66, 0x24, 0xDF,
  0xCE, 0xDC, 0xDE, 0xDF, 0xCF, 0xDC, 0x9C, 0x8A, 0x9A, 0x99,
  0xDB, 0xE5, 0x30, 0x36, 0x23, 0x60, 0x35, 0x77, 0x31, 0x20,
  0x30, 0x37, 0x33, 0x7F, 0x9F, 0xDD, 0xDF, 0xCE, 0x8F, 0xDC,
  0xCC, 0xDA, 0xCA, 0xCD, 0xDE, 0x9A, 0x65, 0x26, 0x37, 0x65,
  0x25, 0x62, 0x24, 0x21, 0x60, 0x22, 0x33, 0x21, 0x1A, 0xC9,
  0x9F, 0x8A, 0xCF, 0xD8, 0x89, 0xCA, 0x8A, 0x89, 0x9E, 0xDA,
  0xD8, 0x32, 0x66, 0x24, 0x20, 0x36, 0x74, 0x60, 0x74, 0x26,
  0x67, 0x60, 0x61, 0xCC, 0x9F, 0xDA, 0x9F, 0xDD, 0x99, 0xCE,
  0xDB, 0x89, 0x9F, 0x8B, 0x8B, 0xD3, 0x37, 0x21, 0x65, 0x66,
  0x70, 0x64, 0x65, 0x63, 0x33, 0x34, 0x25, 0x60, 0xCA, 0x9B,
  0xDB, 0x88, 0x8C, 0x8F, 0x9F, 0xD8, 0xDA, 0x8E, 0x9F, 0x89,
  0xB3, 0x60, 0x71, 0x62, 0x31, 0x71, 0x34, 0x73, 0x32, 0x70,
  0x21, 0x27, 0x2A, 0x8A, 0x8A, 0x89, 0x8C, 0xDA, 0xCA, 0xD8,
  0x9A, 0xCB, 0xCE, 0xCC, 0x89, 0x70, 0x64, 0x77, 0x25, 0x71,
  0x60, 0x33, 0x66, 0x74, 0x74, 0x33, 0x31, 0x5F, 0xCB, 0x89,
  0x9C, 0xDF, 0xDB, 0x8C, 0x8B, 0x8F, 0x8F, 0x8D, 0xCC, 0xD9,
  0x30, 0x72, 0x64, 0x61, 0x25, 0x62, 0x26, 0x75, 0x25, 0x77,
  0x65, 0x24, 0xCE, 0xDD, 0x98, 0x8E, 0xDE, 0xC8, 0x8F, 0x8A,
  0x9B, 0xD9, 0x89, 0x9B, 0xD5, 0x22, 0x64, 0x70, 0x34, 0x33,
  0x32, 0x20, 0x60, 0x62, 0x25, 0x75, 0x72, 0xC8, 0xC8, 0x8A,
  0xCB, 0x9D, 0xDA, 0xCE, 0xCE, 0x98, 0xC8, 0x9F, 0x9A, 0xB3,
  0x31, 0x24, 0x70, 0x27, 0x32, 0x25, 0x75, 0x26, 0x31, 0x65,
  0x30, 0x3D, 0xDD, 0x9A, 0x9A, 0x8D, 0xDE, 0x8E, 0xCA, 0xC8,
  0x8C, 0x9F, 0xDE, 0xDD, 0x70, 0x35, 0x34, 0x22, 0x63, 0x70,
  0x34, 0x33, 0x30, 0x25, 0x30, 0x33, 0x1D, 0xCB, 0xDB, 0xD8,
  0xCE, 0x8F, 0xCF, 0x89, 0xDC, 0xCA, 0x9F, 0xDC, 0x88, 0x24,
  0x64, 0x77, 0x32, 0x20, 0x30, 0x22, 0x21, 0x64, 0x24, 0x33,
  0x27, 0xCE, 0x8E, 0x99, 0xDA, 0xCE, 0xCA, 0xCD, 0x8D, 0xDE,
  0x8E, 0x9C, 0x8F, 0x80, 0x35, 0x27, 0x76, 0x75, 0x20, 0x73,
  0x71, 0x31, 0x25, 0x26, 0x63, 0x72, 0xDB, 0x88, 0x8B, 0xCF,
  0xCF, 0xD8, 0xD9, 0xDB, 0xCE, 0xCD, 0x8B, 0xDB, 0xA4, 0x66,
  0x66, 0x21, 0x74, 0x22, 0x24, 0x34, 0x61, 0x72, 0x26, 0x20,
  0x3F, 0xD9, 0xCA, 0x9B, 0xCB, 0x9C, 0xC9, 0xDB, 0x8E, 0xC8,
  0x9F, 0x9B, 0x9F, 0x73, 0x66, 0x20, 0x70, 0x67, 0x30, 0x25,
  0x25, 0x32, 0x66, 0x30, 0x61, 0x1C, 0x8F, 0x9E, 0x9A, 0xD9,
  0xCD, 0xDF, 0x8E, 0x8D, 0x9B, 0xCF, 0xCB, 0xCB, 0x36, 0x30,
  0x25, 0x66, 0x61, 0x34, 0x61, 0x32, 0x76, 0x24, 0x30, 0x63,
  0x8A, 0xDF, 0x8F, 0x98, 0x89, 0xDB, 0xDE, 0xCC, 0x8A, 0xCA,
  0x8F, 0xD8, 0xC2, 0x60, 0x30, 0x26, 0x31, 0x75, 0x65, 0x26,
  0x62, 0x74, 0x60, 0x62, 0x32, 0xCB, 0x9E, 0xDD, 0x8C, 0xDF,
  0x9F, 0xC8, 0xCE, 0xCF, 0x8A, 0xD8, 0xCD, 0xA4, 0x75, 0x22,
  0x64, 0x24, 0x35, 0x22, 0x63, 0x25, 0x34, 0x76, 0x24, 0x2E,
  0x8A, 0x89, 0x88, 0xCB, 0xCF, 0xDD, 0x8B, 0x9A, 0xDE, 0x9C,
  0x88, 0xCF, 0x74, 0x22, 0x75, 0x61, 0x65, 0x76, 0x62, 0x71,
  0x60, 0x22, 0x74, 0x24, 0x0E, 0x98, 0x9D, 0x9A, 0x9F, 0x9D,
  0x8E, 0xCB, 0xDB, 0x99, 0x98, 0x9A, 0x99, 0x76, 0x24, 0x35,
  0x24, 0x26, 0x62, 0x70, 0x20, 0x27, 0x30, 0x65, 0x65, 0xDD,
  0x88, 0x9B, 0xCE, 0x9C, 0x8E, 0xCF, 0xDB, 0x8C, 0xCC, 0xDE,
  0x9A, 0xD7, 0x74, 0x25, 0x60, 0x37, 0x22, 0x34, 0x20, 0x67,
  0x61, 0x65, 0x31, 0x70, 0xD9, 0xDA, 0x9E, 0x8D, 0xCE, 0xCF,
  0x8B, 0x9C, 0x98, 0xCF, 0x9A, 0xC8, 0xF0, 0x71, 0x24, 0x76,
  0x63, 0x60, 0x30, 0x67, 0x74, 0x21, 0x34, 0x32, 0x68, 0xDF,
  0x8E, 0x98, 0xCF, 0x8B, 0x9E, 0xDC, 0xD9, 0x8A, 0x8F, 0x8C,
  0x9A, 0x61, 0x34, 0x37, 0x23, 0x35, 0x61, 0x27, 0x60, 0x25,
  0x65, 0x23, 0x36, 0x1E, 0xDF, 0x98, 0xDB, 0x9F, 0xCA, 0xC8,
  0x98, 0xDF, 0x9A, 0x88, 0xCA, 0xD9, 0x35, 0x66, 0x66, 0x75,
  0x30, 0x73, 0x34, 0x74, 0x34, 0x22, 0x72, 0x61, 0xDB, 0x89,
  0x9F, 0xCA, 0x9E, 0xD9, 0xC9, 0x8B, 0xCE, 0x89, 0x9A, 0xCB,
  0xC4, 0x67, 0x63, 0x64, 0x65, 0x22, 0x35, 0x31, 0x70, 0x23,
  0x73, 0x64, 0x63, 0x99, 0xCA, 0xCA, 0x8B, 0x98, 0x8D, 0x9B,
  0x9B, 0x99, 0xCA, 0xCA, 0x8B, 0xE7
]

dword1 = [ -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0]

dword2 = [ -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0, 0, 0, 0]

maze = []

def sub_1329(a1, a2):
  v3 = "tgrddf55"
  return a1[a2] ^ ord(v3[a2 % 8])

def sub_13A1(a1, a2, a3):
  return (sub_1329(a1, (99 * a2 + a3) // 8) >> (7 - (99 * a2 + a3) % 8)) & 0x1

def sub_141B(a1, a2, a3):
  v4 = sub_13A1(a1, a2, a3)
  if v4 == 0 :
    return 48
  elif v4 == 1 :
    return 49
  else:
    return 101

def create_maze(a, i, j):
  for k in range(3):
    a[k] = sub_141B(unk, dword1[k] + i, dword2[k] + j)
  a[3] = 10
  for k in range(4, 7, 1):
    a[k] = sub_141B(unk, dword1[k] + i, dword2[k] + j)
  a[7] = 10
  for k in range(8, 11, 1):
    a[k] = sub_141B(unk, dword1[k] + i, dword2[k] + j)
  a[11] = 10

for i in range(1, 98 , 3):
  row1 = []
  row2 = []
  row3 = []
  for j in range(1, 98, 3):
    a = [0] * 12
    create_maze(a, i, j)
    row1.extend([a[0], a[1], a[2]])
    row2.extend([a[4], a[5], a[6]])
    row3.extend([a[8], a[9], a[10]])
  maze.extend(row1)
  maze.extend(row2)
  maze.extend(row3)

for i in range(len(maze)):
    print(chr(maze[i]),end=',')

这里我只写到了迷宫建立,因为我对python的数据结构不是很熟,比较熟练c++,我用了c++实现bfs和dfs

#include <iostream>
#include <queue>
#include <cstring>

using namespace std;
const int N = 110;

int map[N][N], v[N][N];
int maze[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,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0,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
typedef pair<pair<int, int>, string> PII;
queue<PII> q;

string bfs() {
    int dx[4] = { -1, 0, 1, 0 };
    int dy[4] = { 0, 1, 0, -1 };
    memset(v, -1, sizeof v);
    q.push({ { 1,1 }, "" });
    v[1][1] = 0;
    while (!q.empty()) {
        PII p = q.front();
        q.pop();
        if (p.first.first == 97 && p.first.second == 97) return p.second;
        for (int i = 0; i < 4; i++) {
            int x = p.first.first + dx[i], y = p.first.second + dy[i];
            if (x >= 0 && x < 99 && y >= 0 && y < 99 && map[x][y] == 0 && v[x][y] == -1) {
                if (i == 0) q.push({ { x,y },  p.second + "a"});
                else if (i == 1) q.push({ { x,y }, p.second + "s"});
                else if(i == 2) q.push({ { x,y }, p.second + "d"});
                else q.push({ { x,y }, p.second + "w"});
                v[x][y] = 0;
            }
        }
    }
    return "";
}

int main() {
    for (int i = 0; i < 99; i++) {
        for (int j = 0; j < 99; j++) {
            map[i][j] = maze[99 * i + j];
        }
    }
    cout << bfs() << endl;
}

dfs

#include <iostream>

using namespace std;
int maze[] = []//自己复制一下
int map[99][99];
char t[10000];
int r = 0;
int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, 1, 0, -1 };
char op[4] = { 'w', 'd', 's', 'a' };
bool check(int qx, int qy) {
    if (qx >= 0 && qx < 99 && qy >= 0 && qy < 99) {
        if (map[qx][qy] == 0) return 1;
    }
    return 0;
}
void dfs(int x, int y) {
    if (x == 97 && y == 97) {
        for (int i = 0; i < r; i++) cout << t[i];
        cout << endl;
        return;
    }
    for (int i = 0; i < 4; i++) {
        int qx = dx[i] + x;
        int qy = dy[i] + y;
        if (check(qx, qy)) {
            t[r] = op[i];
            r++;
            map[x][y] = 1;
            dfs(qx, qy);
            map[x][y] = 0;
            r--;
            t[r] = 0;
        }
    }
}
int main() {
    for (int i = 0; i < 99; i++) {
        for (int j = 0; j < 99; j++) {
            map[i][j] = maze[99 * i + j];
        }
    }
    dfs(1, 1);
    return 0;
}

得结果

4ed5a17ee7aeb95fcf12a3b96a9d4e6f