Jump to content

Securing an old website coded with register_globals turned on!


omidbrb

Recommended Posts

Hello Everyone,

 

I'm facing a website which is quite badly written, with register_globals turned on and I don't have the time to go through the code and secure the website. Do you think including the following code (that works) above every page in the website will secure the website from cross-site scripting attacks?

 

It's actually scanning all _GET and _SET variables that PHP has turned into variables:

 

foreach(array_keys($_GET) as $kk)
{
    $$kk = htmlspecialchars($$kk);
    $$kk = str_replace("shell_exec", "little_bunny", $$kk);
    $$kk = str_replace("exec", "little_bunny", $$kk);
    $$kk = str_replace("javascript", "evil_bunny", $$kk);
}

foreach(array_keys($_POST) as $kk)
{
    $$kk = htmlspecialchars($$kk);
    $$kk = str_replace("shell_exec", "little_bunny", $$kk);
    $$kk = str_replace("exec", "little_bunny", $$kk);
    $$kk = str_replace("javascript", "evil_bunny", $$kk);
}

 

Best,

Omid

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.