Remote Code Execution Exploitation on Brian’s Web Application
Remote Code Execution Exploitation on Brian’s Web Application
Situation:
This exercise aimed to uncover and exploit remote code execution (RCE) vulnerabilities in Brian Oppenheimer’s first PHP web project, hosted at http://www.artstailor.com/brian
. The investigation involved analyzing the web application for misconfigurations and weaknesses, gaining administrative access, and extracting sensitive data.
Obstacles:
- Password Decryption:
- Extracting and decrypting the hashed password stored in the
.htpasswd
file.
- Extracting and decrypting the hashed password stored in the
- Shell Exploitation:
- Modifying the Laudanum PHP shell to bypass restrictions and gain full system access.
- File Upload Restrictions:
- Circumventing a
.png
file upload requirement to deploy a PHP shell.
- Circumventing a
Actions Taken:
- Initial Reconnaissance:
- Used
nikto
to identify the/brian/private/
directory as potentially interesting. - Inspected the HTML source code of the web page, injecting
raw=true&
into the URL to list directory contents.
- Used
- Extracting
.htpasswd
:- Modified the URL to target the
.htpasswd
file. - Identified the password hash type (
MD5
) via a Google search. - Saved the hash to a text file and decrypted it using
john
to reveal the credentials:brian:swordfish
.
- Modified the URL to target the
- Gaining Administrative Access:
- Logged into the administrative page using the extracted credentials.
- Uploaded a modified Laudanum PHP shell (
shell.php
), ensuring compatibility by:- Adding the IP address
172.24.0.10
to the allowed list. - Commenting out deprecated lines (119–120).
- Setting a custom password for the shell.
- Adding the IP address
- File Upload Exploit:
- Renamed the shell file to
shell.png
and uploaded it. - Used Burp Suite to intercept the HTTP request, modifying the filename from
.png
to.php
before forwarding.
- Renamed the shell file to
- System Access:
- Accessed the shell at
http://www.artstailor.com/brian/imgfiles/shell.php
. - Navigated through directories to locate and exfiltrate the following files:
- IntermediateCA.txt
- RootCA.txt
- Server.txt
- ThisIsTheFileYouAreLookingFor
- Accessed the shell at
Results:
- Access Achieved:
- Gained administrative privileges and deployed a PHP shell for full control over the application server.
- Sensitive Data Extracted:
- Certification files and a sensitive target file were retrieved from the
/brian/private/
and/certs/
directories.
- Certification files and a sensitive target file were retrieved from the
- Critical Vulnerabilities Identified:
- Misconfigured file permissions and weak password hashing enabled exploitation.
Tool Purpose Overview:
nikto:
- Scanned the web application for vulnerabilities, identifying misconfigured directories.
john:
- Decrypted the MD5 hash stored in
.htpasswd
to reveal the administrator password.
Laudanum:
- Provided a PHP shell for executing commands on the remote server.
Burp Suite:
- Modified HTTP requests to bypass upload restrictions.
Recommendations:
- Enforce HTTPS:
- Use HTTPS to encrypt data in transit and prevent eavesdropping.
- Secure File Permissions:
- Restrict access to sensitive files, such as
.htpasswd
, and enforce proper access control.
- Restrict access to sensitive files, such as
- Strengthen Password Storage:
- Store passwords using strong hashing algorithms (e.g., bcrypt or Argon2).
- Validate File Uploads:
- Implement strict content validation for uploaded files to prevent unauthorized script execution.
- Routine Vulnerability Scans:
- Schedule regular scans to identify and remediate weaknesses in web applications.
View PDF Document