迷宫问题再探究

最近在学习CTF Wiki

看到了迷宫问题,给个链接:https://ctf-wiki.github.io/ctf-wiki/reverse/maze/maze/

之前在Keyfile的时候有遇见过简易的迷宫问题(贪吃蛇类型)

这个文件是个64位文件,直接拖进IDA,函数超级多,且没找到main函数,选择用字符串定位,直接发现了迷宫路径,如下

接下来就是看怎么判断越界,以及上下左右如何表示了,大家应该也猜得出来*代表通路吧

上下左右怎么表示看C代码比较清晰,如下

上:U  下:D  左:L  右:R

获胜条件也可以看到,横坐标89,纵坐标28,如下

然后把路径走出来就好了

然后这次遇到了一个问题就是这次的地图相比于之前贪吃蛇的那次多得多,要是靠复制黏贴出来是很麻烦的,借鉴了大佬的做法,可以在IDA中按shift+E来提取数据,还挺方便的,如下

提取出来的字符串是比较乱的,也没有换行,我自己使用python脚本弄的,如下

s='''**########################################################################################\x00\x00\x00\x00\x00\x00#************######*##############**************##*####*#######*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00###*#########*****************************************************************############\x00\x00\x00\x00\x00\x00###*#########*###############################################*######*****************#####\x00\x00\x00\x00\x00\x00###**********#############################################################################\x00\x00\x00\x00\x00\x00#*######################*******************************************#####*************#####\x00\x00\x00\x00\x00\x00############*#####*******************************************************************#####\x00\x00\x00\x00\x00\x00###*#################################################*#########*##*######*#####*####*#####\x00\x00\x00\x00\x00\x00###*####*****#####**********************#############*#########*##********#####*####*#####\x00\x00\x00\x00\x00\x00#************************####*####################################*#####*###########*#####\x00\x00\x00\x00\x00\x00###*####*###*#####*############################################*****************####*#####\x00\x00\x00\x00\x00\x00###*####*###*#####*####################***************#########*###############*####*#####\x00\x00\x00\x00\x00\x00#########*#########*#########*#######***************************##*#####*###########*#####\x00\x00\x00\x00\x00\x00#############################################################*######*#####################\x00\x00\x00\x00\x00\x00#******##*#########*#########*#######*#########################*##*#####*###########*#####\x00\x00\x00\x00\x00\x00#*####*##*#########*#########*#######*#########################*##*#####********####*#####\x00\x00\x00\x00\x00\x00###******###*#####*#################################################################*#####\x00\x00\x00\x00\x00\x00###*#########*###############################################*############################\x00\x00\x00\x00\x00\x00#*####*##*#########*######*******####*###**********####****####*##*############*####*#####\x00\x00\x00\x00\x00\x00#*##***#**#########*#################*###*########*####*#######*##*############*####*#####\x00\x00\x00\x00\x00\x00###**************************************************########*######*#####################\x00\x00\x00\x00\x00\x00#*##*###*##########*##############****###*******##*####*#######*##*##*****#####*####*#####\x00\x00\x00\x00\x00\x00#*##*###*##########*##############*############*##*####*#######*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00###################*##############################*####***#####*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00###################********************************############*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00###############################################################*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00#########################*****************************************************************\x00\x00\x00\x00\x00\x00###***************************************************#########*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00#*#######*####**###*#######***#######*########**###*******##*****##########################\x00\x00\x00\x00\x00##*#####*###*###*##*######*#########*#*######*##*#####*#####*##############################\x00\x00\x00\x00\x00###*###*####*###*##*######*##**####*###*####*#########*#####***############################\x00\x00\x00\x00\x00####*#*#####*###*##*##*###*###*###*******####*##*#####*#####*##############################\x00\x00\x00\x00\x00#####*#######**####****####**####*#######*####**######*#####*##############################\x00'''
s=s.replace('\x00\x00\x00\x00\x00\x00','\n')
#print(s)

s='''
**########################################################################################
#************######*##############**************##*####*#######*##*##*###*#####*####*#####
###*#########*****************************************************************############
###*#########*###############################################*######*****************#####
###**********#############################################################################
#*######################*******************************************#####*************#####
############*#####*******************************************************************#####
###*#################################################*#########*##*######*#####*####*#####
###*####*****#####**********************#############*#########*##********#####*####*#####
#************************####*####################################*#####*###########*#####
###*####*###*#####*############################################*****************####*#####
###*####*###*#####*####################***************#########*###############*####*#####
#########*#########*#########*#######***************************##*#####*###########*#####
#############################################################*######*#####################
#******##*#########*#########*#######*#########################*##*#####*###########*#####
#*####*##*#########*#########*#######*#########################*##*#####********####*#####
###******###*#####*#################################################################*#####
###*#########*###############################################*############################
#*####*##*#########*######*******####*###**********####****####*##*############*####*#####
#*##***#**#########*#################*###*########*####*#######*##*############*####*#####
###**************************************************########*######*#####################
#*##*###*##########*##############****###*******##*####*#######*##*##*****#####*####*#####
#*##*###*##########*##############*############*##*####*#######*##*##*###*#####*####*#####
###################*##############################*####***#####*##*##*###*#####*####*#####
###################********************************############*##*##*###*#####*####*#####
###############################################################*##*##*###*#####*####*#####
#########################*****************************************************************
###***************************************************#########*##*##*###*#####*####*#####
#*#######*####**###*#######***#######*########**###*******##*****##########################     
##*#####*###*###*##*######*#########*#*######*##*#####*#####*##############################     
###*###*####*###*##*######*##**####*###*####*#########*#####***############################     
####*#*#####*###*##*##*###*###*###*******####*##*#####*#####*##############################     
#####*#######**####****####**####*#######*####**######*#####*##############################'''

但最关键的一点是因为迷宫的每一行没有按照顺序排放,要改,改完之后如下,

s='''
0  **########################################################################################\x00\x00\x00\x00\x00\x00

1  #*######################*******************************************#####*************#####\x00\x00\x00\x00\x00\x00

2  #************************####*####################################*#####*###########*#####\x00\x00\x00\x00\x00\x00

3  #########*#########*#########*#######***************************##*#####*###########*#####\x00\x00\x00\x00\x00\x00

4  #******##*#########*#########*#######*#########################*##*#####*###########*#####\x00\x00\x00\x00\x00\x00

5  #*####*##*#########*#########*#######*#########################*##*#####********####*#####\x00\x00\x00\x00\x00\x00

6  #*####*##*#########*######*******####*###**********####****####*##*############*####*#####\x00\x00\x00\x00\x00\x00

7  #*##***#**#########*#################*###*########*####*#######*##*############*####*#####\x00\x00\x00\x00\x00\x00

8  #*##*###*##########*##############****###*******##*####*#######*##*##*****#####*####*#####\x00\x00\x00\x00\x00\x00

9  #*##*###*##########*##############*############*##*####*#######*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00

10 #************######*##############**************##*####*#######*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00

11 ###################*##############################*####***#####*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00

12 ###################********************************############*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00

13 ###############################################################*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00

14 ###***************************************************#########*##*##*###*#####*####*#####\x00\x00\x00\x00\x00\x00

15 ###*#################################################*#########*##*######*#####*####*#####\x00\x00\x00\x00\x00\x00

16 ###*####*****#####**********************#############*#########*##********#####*####*#####\x00\x00\x00\x00\x00\x00

17 ###*####*###*#####*####################***************#########*###############*####*#####\x00\x00\x00\x00\x00\x00

18 ###*####*###*#####*############################################*****************####*#####\x00\x00\x00\x00\x00\x00

19 ###******###*#####*#################################################################*#####\x00\x00\x00\x00\x00\x00

20 ############*#####*******************************************************************#####\x00\x00\x00\x00\x00\x00

21 ###**********#############################################################################\x00\x00\x00\x00\x00\x00

22 ###*#########*****************************************************************############\x00\x00\x00\x00\x00\x00

23 ###*#########*###############################################*############################\x00\x00\x00\x00\x00\x00

24 ###*#########*###############################################*######*****************#####\x00\x00\x00\x00\x00\x00

25 ###**************************************************########*######*#####################\x00\x00\x00\x00\x00\x00

26 #############################################################*######*#####################\x00\x00\x00\x00\x00\x00

27 #*#######*####**###*#######***#######*########**###*******##*****##########################\x00\x00\x00\x00\x00

28 #########################*****************************************************************\x00\x00\x00\x00\x00\x00

29 ##*#####*###*###*##*######*#########*#*######*##*#####*#####*##############################\x00\x00\x00\x00\x00

30 ###*###*####*###*##*######*##**####*###*####*#########*#####***############################\x00\x00\x00\x00\x00

31 ####*#*#####*###*##*##*###*###*###*******####*##*#####*#####*##############################\x00\x00\x00\x00\x00

32 #####*#######**####****####**####*#######*####**######*#####*##############################\x00
'''

猜你喜欢

转载自blog.csdn.net/qq_42192672/article/details/82906558