YenKoc 发表于 2020-2-12 23:33

bugku上一道迷宫逆向题的分析


TIPS:是本人第一次在吾爱上发帖,也是个逆向的新手,虽然很菜,但是会一直坚持---------分析有哪些地方不对的,请大家指出,互相进步
1.第一步先拖入IDA分析一步,shift+F12,查找提示信息,进而找到我们需要的函数

2.找到了有价值的线索字符串.rdata:00518068 00000013 C welcome to zsctf!\n,点击进入,并对字符串变量按x键,查看引用。


3.再进入调用这个字符串的函数中,F5反编译一下

4.分析一手

5.跟进去关键函数

发现了这个函数,一个控制方向,后一个字符控制走的步数。而且lrud字符不就是代表方向吗,典型的迷宫而且12行26列

不过并没有就此结束,个人觉得最坑的地方在于,四个方向的地图不一样。比如这上

和下

6.画出迷宫的图,才好解。IDC脚本安排上,这也是临时学的shift+F2

7.其他方向类比。再用python写出脚本
up='0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,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,1,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,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,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0,0,0,0,0,1,0,0,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,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1'.replace(',','')
right='0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,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,1,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,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0'.replace(',','')
tmp='~`-.'
res=""
for i in range(len(up)):
    if i%26==0:
      print(res)
      res=""
    if up=='1':
      tmp=tmp.replace('~','U')
    if down=='1':
      tmp=tmp.replace('`','D')
    if left=='1':
      tmp=tmp.replace('-','L')
    if right=='1':
         tmp=tmp.replace('.','R')
    res+=tmp+" "
    tmp='~`-.'


8.得出我们的答案了,再异或(因为之前加密过了,而且用的是异或1,变回原样也是按位异或)
a = list("06360836063b0839073e0639")
flag=""
a[16] = chr(ord(a[16]) ^ 1)
for i in range(24):
    flag+=chr(ord(a)^i)
print(flag)
07154=518?9i<5=6!&!v$#%.


pizazzboy 发表于 2020-2-13 11:01

虽然对IDA一窍不通,还是顶你。

YenKoc 发表于 2020-2-13 11:07

pizazzboy 发表于 2020-2-13 11:01
虽然对IDA一窍不通,还是顶你。

其实我也没有很精通,看各位大神的操作中,偷学了一点操作,多看多练,我也是菜鸟,感谢支持{:1_918:}

yanghang_chou 发表于 2020-2-13 12:38

又学习了~~~~

工程欧巴 发表于 2020-2-13 16:28

又学习喽

netsill 发表于 2020-2-14 15:24

学习ing。。

Sagitar2009 发表于 2020-2-14 16:36

这个就有点深奥了,可以说的再明白些。

YenKoc 发表于 2020-2-14 22:40

Sagitar2009 发表于 2020-2-14 16:36
这个就有点深奥了,可以说的再明白些。

那天晚上被老妈赶着上床睡觉,有些地方写的不是很详细,哪里玄学的可以提出来

Hmily 发表于 2020-4-1 23:25

代码用代码框处理下,不然会被discuz识别成斜体。
页: [1]
查看完整版本: bugku上一道迷宫逆向题的分析