PDA

View Full Version : Block php scripts from scanning site?



insertnamehere
01-02-2006, 09:25 PM
I have found some php scripts on another site are being used to scan for files and folders on my site...

What can I do to block the script from scanning my folders? I would prefer to do it "quiety" that is, not letting the script or script runner know they have been blocked, but instead just blocking (or redirecting) without any thing being noticed. (So that say the results page of the scripts just comes back empty every time)

Twey
01-03-2006, 03:12 PM
This is difficult. The best way is to look for the precise headers it always uses (User-Agent, connection timeout, and so on). If the script always comes from that site, of course, you can just block (or redirect) connection attempts from that address. The address can be found with $_SERVER['HTTP_REMOTE_ADDR'], or the domain name with $_SERVER['HTTP_REMOTE_HOST']. To redirect, you use the Location: header like so:

<?php if($_SERVER['HTTP_REMOTE_HOST'] == "badsite.com") header("Location: http://www.google.com/"); ?>That may not work, however; it's possible that the script would ignore HTTP redirects. In this case, try:
<?php if($_SERVER['HTTP_REMOTE_HOST'] == "badsite.com") {
require("http://www.google.com/");
die();
} ?>If all the above methods fail (the site uses a different address and changes its headers periodically to avoid detection), you'd need to rely on Javascript to tell the bots from the browsers. I'd advise, if it gets to this stage, leaving it; the cost of making your pages dependent on Javascript isn't worth the saving of the bandwidth these bots use up.

insertnamehere
01-03-2006, 08:23 PM
so I would have to put one of those scripts on every page? or just on the index?

Twey
01-04-2006, 04:17 PM
At the very top of whichever page(s) the scripts request.