While testing a photo-sharing application you discover that its POST /api/upload endpoint saves every incoming file, without modification, directly into the server's public/assets directory and only checks that the request's Content-Type header is exactly image/png. What is the most reliable technique to upload a working PHP web shell through this API under these conditions?
Upload a PNG-PHP polyglot that starts with valid PNG header bytes, save it as shell.php, and include your PHP payload after the PNG data.
Issue an HTTP PUT request to replace public/assets/index.html with raw PHP code while keeping the Content-Type set to image/png.
Name the file shell.php%00.png to rely on a null-byte truncation of the extension during upload validation.
Change the Content-Type header to application/x-php and upload a plain PHP script whose filename ends in .png.
Because the endpoint validates only the Content-Type header, it will accept any file whose HTTP header is set to image/png regardless of the actual file content. Creating a PNG-PHP polyglot lets you prepend the required PNG magic bytes so the image/png check passes, while giving the file a .php extension ensures the web server's PHP interpreter executes the embedded code when the file is later requested. Simply changing the Content-Type to application/x-php would fail the server-side check, null-byte filename tricks no longer work on modern stacks, and attempting to overwrite existing files with HTTP PUT is unreliable and often blocked.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a PNG-PHP polyglot file?
Open an interactive chat with Bash
Why does a web server execute PHP code in a file with the `.php` extension?
Open an interactive chat with Bash
What is the role of Content-Type in file uploads, and why does it matter here?
Open an interactive chat with Bash
Certified Ethical Hacker (CEH)
Web Application Hacking
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .