题目:http://lab1.xseclab.com/base13_ead1b12e47ec7cc5390303831b779d47/index.php
代码:
<?php
header("Content-type: text/html; charset=utf-8");//header() 函数向客户端发送原始的 HTTP 报头
if (isset($_GET['view-source'])) //isset() — 检测变量是否设置,$_GET[]定义变量
{
show_source(__FILE__); //show_source() 函数对文件进行语法高亮显示
exit(); //exit() 函数输出一条消息,并退出当前脚本
}
include('flag.php'); //include()服务器执行 PHP 文件之前在该文件中插入一个文件的内容
$smile = 1; //$符号是变量符号;把$符号加上字符串,这个字符串就是一个变量名或对象名。
if (!isset ($_GET['^_^'])) $smile = 0;
if (preg_match ('/\./', $_GET['^_^'])) $smile = 0; //preg_match()返回 pattern 的匹配次数。 它的值将是0次(不匹配)或1次,因为preg_match()在第一次匹配后 将会停止搜索。
if (preg_match ('/%/', $_GET['^_^'])) $smile = 0;
if (preg_match ('/[0-9]/', $_GET['^_^'])) $smile = 0;
if (preg_match ('/http/', $_GET['^_^']) ) $smile = 0;
if (preg_match ('/https/', $_GET['^_^']) ) $smile = 0;
if (preg_match ('/ftp/', $_GET['^_^'])) $smile = 0;
if (preg_match ('/telnet/', $_GET['^_^'])) $smile = 0;
if (preg_match ('/_/', $_SERVER['QUERY_STRING'])) $smile = 0; //$_SERVER["QUERY_STRING"] 获取查询语句,获取的是?后面的值
if ($smile) {
if (@file_exists ($_GET['^_^'])) $smile = 0; //file_exists() 函数检查文件或目录是否存在。
}
if ($smile) {
$smile = @file_get_contents ($_GET['^_^']); //file_get_contents() 函数把整个文件读入一个字符串中。
if ($smile === "(●'◡'●)") die($flag); //die() 函数输出一条消息,并退出当前脚本。
}
?>
审计得:
1.必须有^_^参数
2.参数中不能有. %
3.键名中不能有_(与1矛盾) —->在url中‘—’和‘ . ’等价
4.^_^必须是文件
5.文件不在本地存在
不懂data协议
我猜,要求^_^必须是文件 ,且文件不在本地存在
data协议能办到
构造url ?^.^=data:,(●’◡’●) 怎么构造的?不懂
陷入一个不好的漩涡,总想着找到flag,然后交上去。
有什么意义吗?一时的快感,却没学到什么。
要在做题中不断问为什么,不断学习。
做ctf,哦做什么都要不断学习阿。