8.微笑一下就能过关了
尼玛,碰到这样的题我能笑得出来嘛…
通关地址
看源码
<a href="?view-source">源代码</a></label>
打开连接可以看到
<?php
header("Content-type: text/html; charset=utf-8");
if (isset($_GET['view-source'])) {
show_source(__FILE__);
exit();
}
include('flag.php');
$smile = 1;
if (!isset ($_GET['^_^'])) $smile = 0;
if (preg_match ('/\./', $_GET['^_^'])) $smile = 0;
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;
if ($smile) {
if (@file_exists ($_GET['^_^'])) $smile = 0;
}
if ($smile) {
$smile = @file_get_contents ($_GET['^_^']);
if ($smile === "(●'◡'●)") die($flag);
}
?>
很明显,为了输出flag,需要满足上面的所有条件,即:
1.必须对"^_^"赋值
2."^_^"的值不能有 . % [0-9] http https ftp telnet 这些东西
3.$_SERVER['QUERY_STRING'],即"^_^=(输入的值)"这个字符串不能有 _ 这个字符
4.满足$smile!=0
5.file_exists ($_GET['^_^'])必须为0.也就是$_GET['^_^']此文件不存在
6."$smile"必须等于"(●'◡'●)".也就是file_get_contents($_GET['^_^'])必须为"(●'◡'●)"
仔细分析可以发现,第3点与第1点矛盾了
既要对"^_^"赋值,又得想办法去掉"^_^"中的"_"
那么可以采用Url编码变为"%5f".这样第3点就满足了.所以我们输入就应该为"^%5f^"
继续分析第2点,这个地方把 http https ftp telnet 这些给过滤了
而第6点又要通过file_get_contents()取出$_GET['^_^']里的值.
根据第5点,$_GET['^_^']又必须不存在
所以$_GET['^_^']只能是字符串"(●'◡'●)",不可能是文件名
那么file_get_contents()里的参数应该是啥呢,查了一下,发现data://完美符合.所以我们输入就应该为"^%5f^=data:,(●'◡'●)"
打开
http://lab1.xseclab.com/base13_ead1b12e47ec7cc5390303831b779d47/index.php?^%5f^=data:,(●'◡'●)
就能看到key啦~