jammaster82

quote author=jammaster82 link=topic=694.msg4819#msg4819 date=1200069392

Applause

$companyname = trim($_REQUEST['companyname']);
$contactfirstname= trim($_REQUEST['contactfirstname']);
$contactlastname=trim($_REQUEST['contactlastname']);
$streetaddress=trim($_REQUEST['streetaddress']);
$suitenumber=trim($_REQUEST['suitenumber']);
$city=trim($_REQUEST['city']);

Applause how come they arent automatically variables?
so i can just be like


print $suitenumber;
print ' was the suitenumber posted to this form.';



jammaster82


<?

php

 

extract($_REQUEST);

echo $companyname.'::was companyname <br><br>';
echo $contactfirstname.'::was contactfirstname <br><br>';

?>




by placing extract($_REQUEST) at start of the script all GET, POST and Cookie data will be available as variables in the current scope.


Awwwwwwwwwwwwwwwwwww SNAP! 

nutballs

what happens when the variable already exists? Just curious.

vsloathe

Nice find bro. I wonder if doing this would open up an injection vector? I guess not but I would like to see the extract function.

perkiset

Absolutely opens up a vector - I personally would never use it.

The problem is that extract, by default, will overwrite variables in the same scope. So someone could take a wild-assed guess and overwrite some of yours and dick with your procedure, or if they really knew more they could potentially hijack you.

There are modifications to the extract behavior which can be seen here: http://us3.

php

 

.net

 /manual/en/function.extract.

php

  but this is a poor man's way to make sure. This little snippet uses scope as a hard firewall against variable intrusion.


<?

php

 

$AVarIExpect = 'testing';
$AnotherVarIExpect = 'Fubar';

doExtractFunction()


function doExtractFunction()
{
global $AVarIExpect, $AnotherVarIExpect;
extract($_REQUEST);
}
?>



Perkiset's Place Home   Politics @ Perkiset's