#coding=utf-8 from pwn import * import time nice = ['Just do it\n','GOGOGO\n','Wuhu~!\n', 'You are so good\n','Nice.\n','Yeah~~~\n', "Let's go.\n",'So smart\n','Never stop\n','Wuhu\n']
defde(i): if i == 'W': return'S' elif i == 'S': return'W' elif i == 'A': return'D' elif i == 'D': return'A'
defsb(flag,x,y): #print flag xx = x yy = y for i in'WSAD': if i == 'W': if maze[x][y-1] != 0:#0为未走过 continue elif i == 'S': if maze[x][y+1] != 0: continue elif i == 'A': if maze[x-1][y] != 0: continue elif i == 'D': if maze[x+1][y] != 0: continue sh.send(i) time.sleep(0.05)#以防recv不到 recv = sh.recv() #print recv if str(recv) in nice: if i == 'W': y -= 1 elif i == 'S': y += 1 elif i == 'A': x -= 1 elif i == 'D': x += 1 maze[x][y] = 2#标记可走 sb(flag + i,x,y)#然后走 sh.send(de(i))#走回来 sh.recv() x = xx y = yy elif'md5'in recv:#输出结果 maze[x][y]=3 print(flag+i) exit(0) elif i == 'W':#标记不可走 maze[x][y-1] = 1 elif i == 'S': maze[x][y+1] = 1 elif i == 'A': maze[x-1][y] = 1 elif i == 'D': maze[x+1][y] = 1
maze=[0]*1000 for i in range(1000): maze[i]=[0]*1000
maze[1][1] = 2#start处可走 maze[1][2] = 2#start往下走一步 sh = process('./maze') sh.send('S') sh.recv() x = 1 y = 2 flag = 'S' sb(flag,x,y)