web21!~never never never give up!
打开环境,一看,哦!不会做,下一个~
OK! never give
找了一大圈,这个注释比较显眼,打开看看
giao,开幕雷击,好像是一个论坛,没找到啥实质性的东西,看看源码
这段码一看是base64,解码试试看
ojbk,还要再解码一次,再看是url解码,解码结果↓
";if(!$_GET['id'])
{
header('Location: hello.php?id=1');
exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
echo 'no no no no no no no';
return ;
}
$data = @file_get_contents($a,'r');
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
$flag = "flag{***********}"
}
else
{
print "never never never give up !!!";
}
?>
阅读一遍,大致明白要求:
1.!$_GET[‘id’] 应该为true,否则会跳转到hello.php?id=1这个页面
2.$a中不能含有"."
3.将$a文件通过file_get_contents读入到 $data,并且 $a文件到内容为"bugku is a nice plateform!"
4.$id==0,(这似乎与第一点相矛盾)
5.$b的长度大于5
6.将$b的第一个字符提取出来,与"111"进行拼接后,满足正则匹配
7.$b的第一个字符不能是4
关于第四点可以看看php的弱类型比较,可以在菜鸟或者这里
第2和第3点条件是针对于
a
的
,
读
取
的
文
件
名
中
不
能
包
含
"
.
"
,
并
且
a的, 读取的文件名中不能包含".",并且
a的,读取的文件名中不能包含".",并且a表示的文件中的内容为"bugku is a nice plateform!"。我们可以看到该题目是通过file_get_contents函数进行读取的文件内容,这个函数可以通过php伪协议(php://input)去绕过。
php://input 是个可以访问请求的原始数据的只读流.CTF中经常使用file_get_contents获取php://input内容(通过POST数据),需要开启allow_url_include,并且当enctype="multipart/form-data"的时候php://input是无效的。
我们令$a=php://input,然后将"bugku is a nice plateform!"通过POST方法进行传递。
然后我们来继续解题
用burp suite抓包一下,
构造 ?id=0e123&a=php://input&b=.23456并且提交bugku is a nice plateforml!
ok 得到了flag。never give up!