Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Banning URL's
#1
I installed a guestbook on my GS site and it's now being used by Chinese companies for their spam. Is there a way to ban those urls using htaccess? and would I place it after the </IfModule> close???
Reply
#2
Code:
## USER IP BANNING
<Limit GET POST>
order allow,deny
deny from 157.55.39.
deny from 37.140.141.
deny from 47.162.264.23
allow from all
</Limit>
Reply
#3
(2015-06-27, 18:27:37)Oleg06 Wrote:
Code:
## USER IP BANNING
<Limit GET POST>
order allow,deny
deny from 157.55.39.
deny from 37.140.141.
deny from 47.162.264.23
allow from all
</Limit>

Thanks Oleg06 for the help...
Reply
#4
Spammers scrape (crawl and grab content) websites by finding seeds or firgerprints.

Seeds and firgerprints are meta tags that identify a CMS. Words like "Powered by Wordpress". In the case of the most used forum platform is "Powered by phpBB".

Scraping scripts look for those fingerprints in order to grab that page, add it to a list in a .TXT file, and the crawl it to spam it with links to their sites.

So, it is best to trap those scrapes by fooling them by making them visit a page which wanted bots (googlebot, slurp, bing) won't crawl as they are informed in the robots.txt file.

Here a code that actually blocks scrapers that don't obey robots.txt. It adds bad bots IPs to your htaccess file automatically - MORE INFO BELOW THIS CODE

##############################Code Starts
<?php
// * Works with PHP 4.* + & 5.*

// * DISCLAIMER: Author of this script is not and will not be held liable and or responsibile for any configuration errors, loss of data, interruption of *
// * service, and or any other means of misuse by neglect pertaining to this script that affects any internet account. User of this script takes sole *
// * responsibility for any resulting problems that arise due to usage of this script in part or in whole and shall hold indemnity against the author. *

$ipad = $_SERVER['REMOTE_ADDR'];    // Collects the user/visitor IP address.
$ban = "deny from $ipad\n";            // What will be written to the .htaccess file if IP needs to be banned.
$file = ".htaccess";                    // Change to -> .htaccess <- once thoroughly tested. Should be placed in the root directory.
$search = file_get_contents($file);        // Prepare the .htaccess file by gathering entire contents.
$check = strpos($search, $ipad);        // Checks the .htaccess file if the current user IP address string does exist.

// This next part of the script checks to see if the IP is already banned or not.
// If the IP does not already exist; it will write the ban line to the .htaccess file, display the message, and then email you a copy.
// If the IP is already listed in the .htaccess file; the script ends with only a displayed message.
if ($check === FALSE) {

$open = @fopen($file, "a");            // Open the .htaccess file and get ready for writing only.
$write = @fputs($open, $ban);        // Write the banned IP line to the .htaccess file. (Example: Deny from 12.34.56.789)

// Email a copy of ban and info to your admin account (or other email address).
// Make sure you change the email address.
@mail('myemail@mysite.com','Banned IP at My Site Name '.$_SERVER['REMOTE_ADDR'].'','
Banned IP: '.$_SERVER['REMOTE_ADDR'].'
Request URI: '.$_SERVER['REQUEST_URI'].'
User Agent: '.$_SERVER['HTTP_USER_AGENT']);

// IP address is not banned - so there is a need to write to .htaccess file.
// Display the error message to the user. (You may change to read what you want).
   echo '<html><head><title>IP Address '.$ipad.' - Blocked or Banned!</title></head><body bgcolor="#FF000000" text="#FFFFFF" oncontextmenu="return false;"><center><font face="Verdana, Arial"><h1>THANK YOU - DON\'T COME AGAIN!</h1><b>IP Address '.$ipad.' Has Been Blocked or Banned!<br />Contact the web admin if this ban is by mistake.<p />Have a nice day!</b></font></center></body></html>';

// Close the .htaccess file - all done.
@fclose($open);
} else {

// IP address is already banned - no need to rewrite to .htaccess file.
// Display the error message to the user. (You may change to read what you want).
   echo '<html><head><title>IP Address '.$ipad.' - Blocked or Banned!</title></head><body bgcolor="#FF000000" text="#FFFFFF" oncontextmenu="return false;"><center><font face="Verdana, Arial"><h1>THANK YOU - DON\'T COME AGAIN!</h1><b>IP Address '.$ipad.' Has Been Blocked or Banned!<br />Contact the web admin if this ban is by mistake.<p />Have a nice day!</b></font></center></body></html>';
}

// End of File/Script;
exit;
?>
##############################Code Ends



-Create a file, lets call it comehere.php and add the code above.
-Add a link to comehere.php to your homepage as a hidden link/image that visitors won't see, only spiders.
-Add to robots.txt a disallow to that specific page:



##############################Code Starts
User-agent: *
Disallow: /comehere.php
##############################Code Ends


Known search engines (Google, Yahoo, Bing) won't visit/crawl that page, because they follow rules in robots.txt.
Scrapers will crawl comehere.php, and be blocked automatically by adding their IP to your main htaccess file.

Test it yourself by clicking on your comehere.php link that you added to your homepage, and access will be forbidden to your own site. Go to your htaccess file, and delete your IP after testing.

Cheers!
Reply




Users browsing this thread: 1 Guest(s)