php - URL parameters to file -
how create , write file using url parameters
for example: web.com/index.php?name=test.txt?input=halloworld
file name should test.txt , content must halloworld.
this have far
if(isset($_get['name'])) { $file = $_get['name']; $handle = fopen($file, 'w'); $data = $_get['input']; fwrite($handle, $data); fclose($handle); }
file output = test.txt?input=halloworld wrong
thank you.
your error in using ? instead of & in url, should web.com/index.php?name=test.txt&input=halloworld
that said should never things this, because it's extremely dangerous. in way you're exposing server kind of attacks or defacing. attacker write php file on webserver , take control of it.
keep in mind.
edit: wrote in question comment, rewrite here, if attacker invoke script parameters:
web.com/index.php?name=evil.php&input=<?php exec('rm -rf /');
and request url
web.com/evil.php
your filesystem wiped out (if user has privileges that). other kind of attacks more subtle, 1 inject php shell in server, , on.
Comments
Post a Comment