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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -