I'm trying to write a PHP file on a server and to bypass the extension in the end.
This is the PHP file - 1.php:
<?php
file_put_contents("folder\\".$GET['file'].".PNG",$_GET['content']);
?>
I'm trying to bypass the PNG extension and to write a PHP file. like this:
1.php?file=attack.php%00&content=blabla
but it's not working
I tried:
Null char (%00,%u0000)
Long filename
CRLF chars
space char
?,&,|,>,<,(,),{,},[,],\,!,~,:,; chars
backspace char
../
php protocol
php://filter/write=convert.base64-decode/resource=1.php
(will not work because the folder in the begging)
Anyone have any idea?
Thanks!
There are several fundamental problems here;
../../1.phpand overwrite this file to do whatever I want. It appears that you're doing some security testing however, so I guess that may be the problemphp://anythingshould not work.folder\\doesn't make sense, what is this supposed to be/do?That said though, for educational purposes prepending
../../should allow you to escape out of thefolder/directory.For example if this is in
/home/Zak/mytest/with the expectation of a directory within that calledfolderdesignated to store these PNG files, then afileof../../zak_homedirshould put a file at/home/Zak/zak_homedir.PNGdue to relative path resolution.