【Pwn】maze - WriteUp
1.运行函数,收集字符串
获取关键词字符串:luck
2.寻找字符串引用代码
3.生成伪代码
4.获得main函数的C语言代码
5.分析程序逻辑
check函数:
main函数
int __fastcall main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // edx
char v5; // [rsp+23h] [rbp-Dh]
unsigned int v6; // [rsp+28h] [rbp-8h]
unsigned int v7; // [rsp+2Ch] [rbp-4h]
_main(argc, argv, envp);
puts("Welcome to the maze. You need to find the exit, which is at point C. Your current position is marked as @.");
puts("flag{\"The shortest route\"},good luck!!");
v7 = 14;
v6 = 0;
while ( (unsigned int)check(v7, v6) != 1 )
{
while ( 1 )
{
v5 = getchar();
if ( v5 == 108 )
break;
if ( v5 > 108 )
{
if ( v5 == 115 )
{
++v7;
goto LABEL_15;
}
if ( v5 == 121 )
{
--v7;
goto LABEL_15;
}
}
else if ( v5 == 99 )
{
++v6;
goto LABEL_15;
}
}
--v6;
LABEL_15:
if ( (unsigned int)check_1(v7, v6) )
{
puts("you've hit a wall!!bro@!");
if ( v5 == 108 )
{
++v6;
}
else if ( v5 > 108 )
{
if ( v5 == 115 )
{
--v7;
}
else if ( v5 == 121 )
{
++v7;
}
}
else if ( v5 == 99 )
{
--v6;
}
}
else
{
puts("You are one step closer to victory!!");
v3 = idx++;
str[v3] = v5;
}
}
puts("you are win!!");
sleep(60LL);
return 0;
}
发现 ‘s' 'l' 'y ' 'c' 为控制上下左右移动
要使map[10 * a1 + a2] == 67 为真
提取map数组数据,获取得到地图
替换方便查看
观察发现 0属于路,1属于墙
由于当check(v7,v6) !=1时跳出循环,游戏胜利,所以需要设法构建使得check函数返回1
由check函数分析得出,67为迷宫出口
由此可得67为出口,64为起点
由以上算法可得 c为向右 y向上 s向下 l向左
故路径为cyyyyyyyyyccccssscccssssssc
不过这里应该有个什么脚本可以可以。(BFS //不过我还没学过hhh)