TGCTF-2025-Web-Writeup

Web (ez)upload hint写有源码泄露 index.php.bak拿源码 1<?php 2define('UPLOAD_PATH', __DIR__ . '/uploads/'); 3$is_upload = false; 4$msg = null; 5$status_code = 200; // 默认状态码为 200 6if (isset($_POST['submit'])) { 7 if (file_exists(UPLOAD_PATH)) { 8 $deny_ext = array("php", "php5", "php4", "php3", "php2", "html", "htm", "phtml", "pht", "jsp", "jspa", "jspx", "jsw", "jsv", "jspf", "jtml", "asp", "aspx", "asa", "asax", "ascx", "ashx", "asmx", "cer", "swf", "htaccess"); 9 10 if (isset($_GET['name'])) { 11 $file_name = $_GET['name']; 12 } else { 13 $file_name = basename($_FILES['name']['name']); 14 } 15 $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); 16 17 if (!in_array($file_ext, $deny_ext)) { 18 $temp_file = $_FILES['name']['tmp_name']; 19 $file_content = file_get_contents($temp_file); 20 21 if (preg_match('/.+?</s', $file_content)) { 22 $msg = '文件内容包含非法字符,禁止上传!'; 23 $status_code = 403; // 403 表示禁止访问 24 } else { 25 $img_path = UPLOAD_PATH . $file_name; 26 if (move_uploaded_file($temp_file, $img_path)) { 27 $is_upload = true; 28 $msg = '文件上传成功!'; 29 } else { 30 $msg = '上传出错!'; 31 $status_code = 500; // 500 表示服务器内部错误 32 } 33 } 34 } else { 35 $msg = '禁止保存为该类型文件!'; 36 $status_code = 403; // 403 表示禁止访问 37 } 38 } else { 39 $msg = UPLOAD_PATH . '文件夹不存在,请手工创建!'; 40 $status_code = 404; // 404 表示资源未找到 41 } 42} 43 44// 设置 HTTP 状态码 45http_response_code($status_code); 46 47// 输出结果 48echo json_encode([ 49 'status_code' => $status_code, 50 'msg' => $msg, 51]); 审计一下代码,看到有个name,可以对文件名进行修改,想到目录穿越 ...

2025-04-18 · 7 分钟 · Xrntkk

XYCTF-2025-Web-Writeup

Web Signin 题目 1# -*- encoding: utf-8 -*- 2''' 3@File : main.py 4@Time : 2025/03/28 22:20:49 5@Author : LamentXU 6''' 7''' 8flag in /flag_{uuid4} 9''' 10from bottle import Bottle, request, response, redirect, static_file, run, route 11with open('../../secret.txt', 'r') as f: 12 secret = f.read() 13 14app = Bottle() 15@route('/') 16def index(): 17 return '''HI''' 18@route('/download') 19def download(): 20 name = request.query.filename 21 if '../../' in name or name.startswith('/') or name.startswith('../') or '\\' in name: 22 response.status = 403 23 return 'Forbidden' 24 with open(name, 'rb') as f: 25 data = f.read() 26 return data 27 28@route('/secret') 29def secret_page(): 30 try: 31 session = request.get_cookie("name", secret=secret) 32 if not session or session["name"] == "guest": 33 session = {"name": "guest"} 34 response.set_cookie("name", session, secret=secret) 35 return 'Forbidden!' 36 if session["name"] == "admin": 37 return 'The secret has been deleted!' 38 except: 39 return "Error!" 40run(host='0.0.0.0', port=8080, debug=False) 目录穿越拿secret ...

2025-04-10 · 6 分钟 · Xrntkk

NCTF-2025-Web-Writeup

sqlmap-master 题目 1from fastapi import FastAPI, Request 2from fastapi.responses import FileResponse, StreamingResponse 3import subprocess 4 5app = FastAPI() 6 7@app.get("/") 8async def index(): 9 return FileResponse("index.html") 10 11@app.post("/run") 12async def run(request: Request): 13 data = await request.json() 14 url = data.get("url") 15 16 if not url: 17 return {"error": "URL is required"} 18 19 command = f'sqlmap -u {url} --batch --flush-session' 20 21 def generate(): 22 process = subprocess.Popen( 23 command.split(), 24 stdout=subprocess.PIPE, 25 stderr=subprocess.STDOUT, 26 shell=False 27 ) 28 29 while True: 30 output = process.stdout.readline() 31 if output == '' and process.poll() is not None: 32 break 33 if output: 34 yield output 35 36 return StreamingResponse(generate(), media_type="text/plain") 其实就是一个网页端的sqlmap 看一下sqlmap的使用文档 ...

2025-03-24 · 2 分钟 · Xrntkk

TPCTF2025-Web-赛后复现Writeup

参考文章 https://blog.0xfff.team/posts/tpctf_2025_writeup/ https://z3n1th1.com/2025/03/tpctf2025-writeup/ TPCTF2025 Writeup - 星盟安全团队 baby layout 这是一道关于绕过DOMPurify库,进行xss cookie窃取的题目 DOMPurify 是一个专门用于清理 HTML 输入的 JavaScript 库,旨在防止跨站脚本 (XSS) 攻击。它通过过滤和净化用户提供的 HTML 内容,确保其安全地嵌入到网页中,避免恶意代码的执行。 ...

2025-03-15 · 5 分钟 · Xrntkk

GHCTF-2025-Web-Writeup

战队名:我要打奥斯汀major 比赛排名:5 Web upload?SSTI! 读取文件中的内容并进行模板渲染,存在ssti 有waf 1def contains_dangerous_keywords(file_path): 2 dangerous_keywords = ['_', 'os', 'subclasses', '__builtins__', '__globals__','flag',] 3 4 with open(file_path, 'rb') as f: 5 file_content = str(f.read()) 6 7 for keyword in dangerous_keywords: 8 if keyword in file_content: 9 return True # 找到危险关键字,返回 True 简单绕一下 ...

2025-03-09 · 6 分钟 · Xrntkk

HGAME2025-Web-Writeup

Web week1 Level 24 Pacman 拿到环境 一个小游戏,猜测应该是js审计 查看index.js发现代码进行了混淆 可以用工具反混淆一下,增加一下可读性 https://tool.yuanrenxue.cn/decode_obfuscator 反混淆之后找到这个 ...

2025-02-20 · 9 分钟 · Xrntkk

CTFSHOW-SQL注入-Writeup

无过滤注入(对输出内容进行过滤) web171 $sql = "select username,password from user where username !='flag' and id = '".$_GET['id']."' limit 1;"; flag是存在于username为flag的用户的数据中,我们只需要通过 1' or 1=1 --+ 即可输出所有用户数据 web172 相比上一题,这题增加了过滤 ...

2025-01-22 · 35 分钟 · Xrntkk

国城杯决赛-Web-Writeup

CTF mountain Python Bottle框架伪造session打pickle反序列化 拿到题目看一下源码,有hint 访问/display 根据提示,尝试用photo参数读图片 ...

2024-12-27 · 7 分钟 · Xrntkk