2018 hctf seven

本来是看 2018 hctf的 io pwn题  也就是   the_end 题目

那个题目其实我是看的懂的,,但是不知道为啥本地打不通,,

自己 的 va 还有 伪造的 还有 one 都写进去了  ,,, 都没搞定,,

最后发现了 有个题目很好玩,  算是迷宫 题目  而且还是驱动的

重点在 read 函数里面

 这里注册了一个驱动函数 我推测是 键盘过滤,,  后来分析了一下  发现自己分析的对

关于键盘过滤 可以参考一下  我这篇文章

https://blog.csdn.net/qq_41071646/article/details/86530700

 

那么  看一下这个回调

很明显 的一个迷宫图

 

其中 的 w 按下的扫描码是 17           a  30 s 31  d 32

那么 

其中的208 令人寻味 这里的是 13*16  也就是说 假如在第一行 往上走 会走到最后一行  同理走后一行也可以

这里的图 其实用不到 这个 地方 直接一般的搜索就可以解决。。。 、

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<map>
#include<time.h>
#include<queue>
#include "windows.h"
using namespace std;
char s[14][17] =
{"****************",
"o..............*",
"**************.*",
"************...*",
"***********..***",
"**********..****",
"*********..*****",
"********..******",
"*******..*******",
"******..********",
"*****..*********",
"****..**********",
"****7***********",
"****************",};
int hh[5]= {1,0,-1,0};//y
int kk[5]= {0,1,0,-1};//x
char w[5]={'d','s','a','w'};
 //a 左 d右 s下 w上
bool vis[20][20];
struct code{
 int x,y;
 queue<char>l;
}as,ad;
bool pd(int i,int j)
{
    if(i>=0&&i<14&&j>=0&&j<16&&!vis[i][j]&&s[i][j]!='*')
        return 1;
    return 0;
}

void slove()
{
     memset(vis,0,sizeof(vis));
     queue<code>qq;
     as.x=1,as.y=0;
     while(!as.l.empty())
        as.l.pop();
     qq.push(as);
     while(!qq.empty())
     {
          ad=qq.front();
          qq.pop();
          //printf("%d %d\n",ad.x,ad.y);
          if(s[ad.x][ad.y]=='7')
          {
               while(!ad.l.empty())
               {
                    printf("%c",ad.l.front());
                    ad.l.pop();
               }
               return;
              // printf("1\n");
              // printf("\n");
          }
          for(int i=0; i<4; i++)
        {
            as=ad;
            as.x=ad.x+kk[i];
            as.y=ad.y+hh[i];
            if(pd(as.x,as.y))
            {
                //printf("%d %d %c\n",as.x,as.y,w[i]);
                as.l.push(w[i]);
                qq.push(as);
                vis[as.x][as.y]=1;
            }
        }
     }

}
int main()
{
   slove();
   return 0;
}

不过,,,,驱动题的迷宫算法 感觉也没啥好玩的,,,,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值