[HUBUCTF 2022 新生赛]help
感受:
1,未知参数可以动调
2,解题可以手搓(无奈之举)
3,可以用脚本
过程
无壳,直接丢IDA里
看到
三个地方,生成迷宫,走迷宫,md5加密
看生成迷宫
下断点,调试出来,甚至不用理解,还是要知道是16*16的迷宫
就是脚本了
maze = [[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1],[1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1],[1,0,1,1,1,0,1,1,0,0,0,1,0,1,1,1],[1,0,1,1,1,0,1,1,0,1,0,1,0,1,1,1],[1,0,1,1,1,0,0,0,0,1,0,1,0,1,1,1],[1,0,1,1,1,1,1,1,0,1,0,1,0,1,1,1],[1,0,1,1,1,1,1,1,0,0,0,1,0,1,1,1],[1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1],[1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1],[1,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1],[1,1,1,1,0,1,1,1,1,0,1,1,0,1,0,1],[1,1,1,1,0,1,1,1,1,0,1,1,0,1,0,1],[1,0,0,0,0,1,1,1,1,0,1,1,0,1,0,0],[1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,1],[1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1], ]#二维地图可换path_len = 0x7fffffff # 不限制路径长度def bfs(start, end, barrier):directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]for i in range(len(maze)):for j in range(len(maze[i])):if maze[i][j] == start:start = (i, j)if maze[i][j] == end:end = (i, j)queue = deque()queue.append((start, [start]))visited = set()visited.add(start)while queue:position, path = queue.popleft()if position == end:return pathelif len(path) == path_len:return pathfor d in directions:next_position = (position[0] + d[0], position[1] + d[1])if 0 <= next_position[0] < len(maze) and 0 <= next_position[1] < len(maze[0]) and \maze[next_position[0]][next_position[1]] != barrier and next_position not in visited:queue.append((next_position, path + [next_position]))visited.add(next_position)return Noneif __name__ == '__main__':maze[15][1] = 'S' # 起点maze[13][15] = 'E' # 终点path = bfs('S', 'E', 1)print("移动路径坐标:", path)print("移动路径方位:{", end='')for i in range(1, len(path)):x1, y1 = path[i - 1]x2, y2 = path[i]if x1 > x2: print("w", end='')elif x1 < x2: print("s", end='')elif y1 > y2: print("a", end='')elif y1 < y2: print("d", end='')print('}')