| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | Dynamic Page Inclusion Fix One of my sites includes files depending on the variable definded in the URL address. Someone told me that is a secruity flaw, could anyone tell me what I can do to fix it? Here is an exmaple: mysite.com/?page=somehaxsite.com/haxscript.php It will include haxscript.php, any one know hte fix?
__________________ LogoJive.com - Professional Grade Web Development! My Domain Listing: dnListing.com/unknown Last edited by Unknown; 11-14-2004 at 05:43 PM. |
| |
| | #2 (permalink) |
| NamePros Regular | Bump
__________________ LogoJive.com - Professional Grade Web Development! My Domain Listing: dnListing.com/unknown |
| |
| | #3 (permalink) |
| New Member | you need to edit the files so the filename's it looks for are prefixed with a let's say a letter or word.. mysite.com/?page=sale.php would pulldown inc_sale.php If you need help post the snippet of code that does your includes or email it to me at wcolby@NOSPAMranking.ws (remove the nospam) and I'll edit it and mail it back to you with instructions. |
| |
| | #4 (permalink) |
| NamePros Regular | So I just create a prefix for all file names and in the script ask for the $page var and add the prefix to it then include it? This is simple, but I was wondering if there is an easier way.
__________________ LogoJive.com - Professional Grade Web Development! My Domain Listing: dnListing.com/unknown |
| |
| | #5 (permalink) |
| NamePros Regular | I actually had my site hacked like this. I ended up just creating header and footer files and including them in every page instead of using the index.php?page=bla method. I know it takes a lot of work, but you're almost guaranteed to be safe. Alternatively, you could probably make sure the include statement is like this: include("http://www.mysite.com/".$_HTTP_GET_VARS["page"]); I'm not completely sure that's safe, however, so I would just go with the first method. |
| |
| | #8 (permalink) | |
| Senior Member | Quote:
what is to stop someone going to a url for say http://www.mysite.com/script.php?pag...des/config.inc
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft | |
| |
| | #9 (permalink) | |
| NamePros Regular | Quote:
However, most include files are .inc.php and the values are within <?php and ?> tags, meaning they won't be shown anyway. I'd just go with the header and footer files methods. It's a minor inconvenience to switch over, but makes you safer in the long run. | |
| |
| | #10 (permalink) |
| Senior Member | then why this discussion in the first place, the person wishes to secure a php file. Also even if it is a .php file the possible error message could convey information in itself.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #11 (permalink) |
| Senior Member | use a switch statement <? switch($_GET['page']) { case 'page1': include("page1.php"); break; case 'page2': include("page1.php"); break; case 'page3': include("page1.php"); break; case 'page4': include("page1.php"); break; case default: include("error.php"); } ?> then change the links to http://yoursite.com/index.php?page=page1 etc and if they give something like http://yourside.com/index.php?page=hakscript.php that will send them to the default case and show them an error |
| |
| | #12 (permalink) |
| NamePros Regular | Why not just have your link look like http://www.yoursite.com?page=blah not http://www.yoursite.com?page=blah.php Then in the index file have include($_GET[page].php); I think that would work....
__________________ CoverageArea.com & CoverageAreas.com - TAKING OFFERS Discuss Business | PC Gaming Talk | Travel Safety Tips |
| |
| | #13 (permalink) | |
| Account Closed | Quote:
Using: http://www.yoursite.com?page=hacksite | |
| |
| | #14 (permalink) |
| NamePros Regular | Well along with what I said I usually have an index file which will have something like if ($_GET[page] == "blah") { include("blah.php"); } or like said before use a switch structure. Also, is there a reason the user should not be allowed to visit http://www.yoursite.com?page=whatever I do not understnad how that would lead them to hacking the site...Can you explain please?
__________________ CoverageArea.com & CoverageAreas.com - TAKING OFFERS Discuss Business | PC Gaming Talk | Travel Safety Tips |
| |
| | #15 (permalink) | |
| Account Closed | Quote:
Maybe: if ($_GET[page] == "blah") { include("blah.php"); } else { include ("error.php"); } or if ($_GET[page] == "blah") include("blah.php"); else include ("error.php"); Maybe? That should work.. | |
| |
| | #16 (permalink) |
| NamePros Regular | Yes, thats what I meant...The code I posted was a quicky, I didnt expand on the else.
__________________ CoverageArea.com & CoverageAreas.com - TAKING OFFERS Discuss Business | PC Gaming Talk | Travel Safety Tips |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |