攻防世界RE-reverse_re3
打开main函数:
一步一步来,先看sub_11B4():
dword_202AB0=0
sub_940()中:
这里函数较多,不过已经可以知道大概思路了,即输入的内容能够让函数跑到以下位置的,就是flag:
然后分析while函数,100,119,27,97,对应的是w,a,s,d这几个常用的游戏方向键,再加上word_202020的值,大概知道了这是一个迷宫题,那就好办了,提取word_202020的数据,从迷宫的判断函数可以知道,迷宫是15*15大小的,让ai整理一下,得到迷宫。
import re# 读取文件
with open("export_results.txt", "r") as file:content = file.read()# 使用正则表达式提取所有数字
numbers = re.findall(r"\b\d+\b", content) # 匹配整数
numbers = [int(num) for num in numbers] # 转为整数列表
j=0
for i in range(0,len(numbers),15):print(numbers[i:i+15])j+=1if j%15==0:print()
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 1, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 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, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0]
有三个迷宫,3为角色位置,4为出口,1为可走道路。
编写代码走迷宫:
import numpy as np
from collections import deque# 定义迷宫 (1=路, 0=墙, 3=玩家, 4=出口)
maze = np.array([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[1, 1, 1, 1, 1, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0],[1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],[1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],[1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0],[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0],[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
])# 初始玩家位置 (3的位置)
player_pos = np.argwhere(maze == 3)[0]
exit_pos = np.argwhere(maze == 4)[0]# 方向映射 (WASD)
directions = {'w': (-1, 0), # 上's': (1, 0), # 下'a': (0, -1), # 左'd': (0, 1), # 右
}# BFS 计算最短路径
def find_shortest_path(maze, start, end):queue = deque([(start, [])])visited = set()visited.add(tuple(start))while queue:(x, y), path = queue.popleft()if (x, y) == tuple(end):return pathfor dir_name, (dx, dy) in directions.items():nx, ny = x + dx, y + dyif 0 <= nx < 15 and 0 <= ny < 15 and maze[nx][ny] != 0 and (nx, ny) not in visited:visited.add((nx, ny))queue.append(((nx, ny), path + [dir_name]))return None # 无解# 获取最短路径
shortest_path = find_shortest_path(maze, player_pos, exit_pos)
print("最短路径:", ''.join(shortest_path) if shortest_path else "无解")# 游戏主循环
while True:# 打印迷宫for row in maze:print(' '.join(map(str, row)))print("当前路径:", ''.join(shortest_path) if shortest_path else "无解")# 玩家移动move = input("输入 WASD 移动 (q 退出): ").lower()if move == 'q':breakif move not in directions:print("无效输入!")continuedx, dy = directions[move]new_x, new_y = player_pos[0] + dx, player_pos[1] + dy# 检查移动是否合法if 0 <= new_x < 15 and 0 <= new_y < 15 and maze[new_x][new_y] != 0:maze[player_pos[0]][player_pos[1]] = 1 # 旧位置恢复为路player_pos = [new_x, new_y]maze[new_x][new_y] = 3 # 新位置设为玩家# 检查是否到达出口if (new_x, new_y) == tuple(exit_pos):print("恭喜!你找到了出口!")breakelse:print("不能往那里走!")
1:ddsssddddsssdss
2:dddddsssddddsssaassssddds
3,ddssddwddssssssdddssssdddss
整合一下:
ddsssddddsssdssdddddsssddddsssaassssdddsddssddwddssssssdddssssdddss
from hashlib import md5data = 'ddsssddddsssdssdddddsssddddsssaassssdddsddssddwddssssssdddssssdddss'
a=md5(data.encode("utf-8")).hexdigest()
print(a)
flag:flag{aeea66fcac7fa80ed8f79f38ad5bb953}