这道题,我做了做,我的英语不好,全都是机翻,然后就发现这好像是一个大富翁的游戏,你要到一定的钱才算赢,主程序主要是在monopoly那个文件上,可以直接在linux里边运行./monopoly,,应该是可以发现有3个难度的,但是只有最高难度才能触发种子。
玩过mc的都知道,种子通常是固定的一个地图,在这里是固定的一个步数,然后就看了别人的wp,就发现他这个是选择种子后返回再选难度和种子,你的钱和位置是不变的,而且在这个游戏里边,是有double的,也就是说,只要你只要走的合理,然后就能double。而且我是看到了别人的wp也知道地图:
[1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]
一共64个位置,然后我们在这一篇里边又看到第一次走3步RCTF-2021 部分WriteUp的种子是22,3和64是互素的,在循环地图中互素即意味着能遍历所有的格子,加上double那么就只是轮数的问题了。手动还是有点难的,我直接找ai写了个脚本。
#!/usr/bin/env python3
import subprocess
import time
import sys
import os
def correct_automation():
"""正确的自动化流程:4->3->seed22->4->3->seed22->..."""
attempt_count = 0
while True:
attempt_count += 1
print(f"=== 第 {attempt_count} 次完整循环 ===")
try:
# 启动游戏进程
proc = subprocess.Popen(
['./monopoly'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1
)
# 初始设置
proc.stdin.write("haha\n") # 名字
proc.stdin.write("3\n") # 选择困难模式
proc.stdin.write("22\n") # seed 22
proc.stdin.flush()
cycle_count = 0
while cycle_count < 100: # 最多100个循环
cycle_count += 1
print(f"循环内第 {cycle_count} 次")
# 处理一个完整循环:等待->选择4->等待->选择3->输入22
try:
# 等待并读取直到需要操作
while True:
line = proc.stdout.readline()
if not line:
break
print(f"输出: {line.strip()}")
# 检查是否获胜
if 'you win' in line or 'flag' in line or 'RCTF' in line:
print("🎉🎉🎉 获胜啦! 🎉🎉🎉")
# 读取所有剩余输出
remaining = proc.communicate()[0]
print(remaining)
return True
# 如果看到操作提示,跳出内循环
if 'want play' in line:
break
# 选择操作4
proc.stdin.write("4\n")
proc.stdin.flush()
print("选择操作: 4")
time.sleep(0.5)
# 等待下一个操作提示
while True:
line = proc.stdout.readline()
if not line:
break
print(f"输出: {line.strip()}")
if 'you win' in line:
print("🎉 获胜!")
remaining = proc.communicate()[0]
print(remaining)
return True
if 'want play' in line:
break
# 选择操作3(重新开始)
proc.stdin.write("3\n")
proc.stdin.flush()
print("选择操作: 3")
time.sleep(0.5)
# 等待seed输入提示
while True:
line = proc.stdout.readline()
if not line:
break
print(f"输出: {line.strip()}")
if 'win the game' in line:
break
# 输入seed 22
proc.stdin.write("22\n")
proc.stdin.flush()
print("输入seed: 22")
time.sleep(0.2)
except Exception as e:
print(f"循环内错误: {e}")
break
proc.terminate()
time.sleep(1)
except Exception as e:
print(f"运行错误: {e}")
time.sleep(0.5)
def fast_correct_automation():
"""快速版本:预先准备好所有输入"""
attempt = 0
while True:
attempt += 1
print(f"尝试 #{attempt}")
# 构建完整的输入序列
# 格式: 名字->3->22->4->3->22->4->3->22->...
input_sequence = "haha\n3\n22\n"
# 添加100个循环:4->3->22
for i in range(100):
input_sequence += "4\n3\n22\n"
try:
result = subprocess.run(
['./monopoly'],
input=input_sequence,
text=True,
capture_output=True,
timeout=120 # 2分钟超时
)
print(f"本轮输出长度: {len(result.stdout)}")
if 'you win' in result.stdout:
print("🎉 成功!")
print(result.stdout)
return True
# 检查是否在stderr中
if 'you win' in result.stderr:
print("🎉 在stderr中找到!")
print(result.stderr)
return True
except subprocess.TimeoutExpired:
print("超时,继续尝试...")
except Exception as e:
print(f"错误: {e}")
time.sleep(0.3)
def step_by_step_automation():
"""逐步调试版本,可以看到详细流程"""
attempt = 0
while True:
attempt += 1
print(f"\n{'=' * 50}")
print(f"尝试 #{attempt}")
print(f"{'=' * 50}")
proc = subprocess.Popen(
['./monopoly'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1
)
# 初始设置
steps = [
("发送名字", "haha\n"),
("选择困难模式", "3\n"),
("输入seed", "22\n")
]
for desc, cmd in steps:
print(f"{desc}: {cmd.strip()}")
proc.stdin.write(cmd)
proc.stdin.flush()
time.sleep(0.1)
# 主循环
for cycle in range(500):
print(f"\n--- 循环 {cycle + 1} ---")
# 步骤1: 等待并选择4
print("等待操作提示...")
while True:
line = proc.stdout.readline().strip()
if line:
print(f"收到: {line}")
if 'CTF' in line:
print("🎉 获胜!")
return True
if 'want play' in line:
break
print("选择操作: 4")
proc.stdin.write("4\n")
proc.stdin.flush()
time.sleep(0.1)
# 步骤2: 等待并选择3
print("等待下一个操作提示...")
while True:
line = proc.stdout.readline().strip()
if line:
print(f"收到: {line}")
if 'CTF' in line:
print("🎉 获胜!")
return True
if 'want play' in line:
break
print("选择操作: 3")
proc.stdin.write("3\n")
proc.stdin.flush()
time.sleep(0.1)
# 步骤3: 等待并输入seed 22
print("等待seed输入提示...")
while True:
line = proc.stdout.readline().strip()
if line:
print(f"收到: {line}")
if 'CTF' in line:
print("🎉 获胜!")
return True
if 'win the game' in line:
break
print("输入seed: 2")
proc.stdin.write("22\n")
proc.stdin.flush()
time.sleep(0.1)
proc.terminate()
time.sleep(0.5)
if __name__ == "__main__":
print("开始正确的自动化流程: 4->3->seed22->4->3->seed22->...")
print("按 Ctrl+C 停止")
if not os.path.exists('./monopoly'):
print("错误: 找不到 './monopoly' 文件")
sys.exit(1)
os.chmod('./monopoly', 0o755)
try:
# 选择一种方式运行
# correct_automation() # 标准版本
# fast_correct_automation() # 快速版本
step_by_step_automation() # 调试版本
except KeyboardInterrupt:
print("\n用户停止执行")
except Exception as e:
print(f"程序错误: {e}")
然后把这个py文件和你的mo文件放同一个目录中
python 1.py
就能看到你赢了,但是没有结果。出现这个联系管理员,说明按理说应该是已经有flag了。

这里是很难受的点,因为这个题是2021年的竞赛上的题,当时是在服务器上应该是有/flag这个文件的(或者文件夹里边有flag),这里是没有的,我就直接附上flag吧。
RCTF{you_are_a_multimillionaire_now}
只能说审核没干好吧,包括那个coolcat也是一样的根本解不出来。
1348

被折叠的 条评论
为什么被折叠?



