From PNG to Shell: The Chatbot That Helped Me Hack Itself
The chatbot allowed uploading files with a .png extension but did not validate the actual content, and the server executed the file as PHP. An attacker could upload a PHP reverse shell disguised as a PNG and gain remote code execution on the server.
medium.com
Published on medium.com
My eyes widened. My hacker brain didn’t see “images.” It saw execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The server relied solely on the file extension for validation and stored uploads in a web-accessible directory where they were executed as PHP.
Impact
An attacker could execute arbitrary code on the server, potentially leading to full compromise.
What the attacker needed
No authentication required; Chatbot accepts file uploads
How it was found
- Rename a PHP reverse shell file to have a .png extension.
- Upload the renamed file through the chatbot's file upload feature.
- The server accepts the file and returns a public URL.
- Start a Netcat listener on the attacker's machine.
- Access the uploaded file's URL to trigger the reverse shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A chatbot let people upload pictures, but it only looked at the file name ending (like .png) and not what was inside. The server then ran the file as a program, so an attacker could upload a malicious script and take control of the server.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.