Blocking IPs

Discuss Article Dashboard management issues, modifications here, and view modifications created by other AD users.

Blocking IPs

Postby joebrochin » Sun Oct 19, 2008 1:47 pm

How do we block a specific group of IP addresses, like India's?
joebrochin
Active Member
 
Posts: 121
Joined: Mon Sep 17, 2007 7:16 pm
Location: Jacksonville, NC

Re: Blocking IPs

Postby GardenSimply » Sun Oct 19, 2008 5:35 pm

Joe,

You can ban an IP and IP blocks in .htaccess, but given the ease with which one can use a proxy banning IP addresses it hardly seems worthwhile.

Most of the tools tend to have proxy use built in and most test the proxy before use so with a list of a couple of hundred proxies, you probably won't stop much for long.

Solution: Andrew

The trick is to stop downloads that match certain trigger patterns or to obfuscate the location of required directories. I used to have a script for the former purpose, prolly still do somewhere; here is an example of one for the latter: http://www.hotscripts.com/Detailed/31142.html

Edit: here is a link to a script that works to ban scrapers based upon their behaviour:
http://www.anticrawl.com
User avatar
GardenSimply
Admin
 
Posts: 208
Joined: Sat Sep 15, 2007 10:31 am
Location: Oklahoma

Re: Blocking IPs

Postby joebrochin » Sun Oct 19, 2008 5:51 pm

So I am looking at my htaccess file and see the following:

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>


Do I start the code after the above with:

Order Deny,Allow
Deny from 58.2.0.0 58.2.255.255
Deny from 58.68.0.0 58.68.127.255
Deny from 58.146.96.0 58.146.127.255
(more ips follow after....)
joebrochin
Active Member
 
Posts: 121
Joined: Mon Sep 17, 2007 7:16 pm
Location: Jacksonville, NC

Re: Blocking IPs

Postby GardenSimply » Mon Oct 20, 2008 6:03 am

Sorry I left the coding out.

Code: Select all
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>

The above is included in AD's default .htaccess.

The limit directive limits the IP ban to GET requests and POST actions... so they won't be able to do some things, but they will be able to access files.
There's no good reason to limit when IP banning because In general, access restriction directives apply to all access methods (GET, PUT, POST, etc). It is possible to restrict some methods, while leaving other methods unrestricted, by enclosing the directives in a <Limit> section. (so when IP banning, you don't want any limits, you only want them OUT, so no need for Limit, right? ;)

The order directive controls the default access state and the order in which Allow and Deny are evaluated.

From Apache...
Ordering is one of...

Deny,Allow
The Deny directives are evaluated before the Allow directives. Access is allowed by default. Any client which does not match a Deny directive or does match an Allow directive will be allowed access to the server.

Allow,Deny
The Allow directives are evaluated before the Deny directives. Access is denied by default. Any client which does not match an Allow directive or does match a Deny directive will be denied access to the server.


In the following example, all hosts in the test2.com domain are allowed access; all other hosts are denied access.

Code: Select all
Order Deny,Allow
Deny from all
Allow from test2.com


In the following example, all hosts in the test2.com domain are allowed access, except for the hosts which are in the testing.test2.com subdomain, who are denied access. All hosts not in the test2.com domain are denied access because the default state is to deny access to the server.

Code: Select all
Order Allow,Deny
Allow from test2.com
Deny from testing.test2.com


On the other hand, if the Order in the last example is changed to Deny,Allow, all hosts will be allowed access. This happens because, regardless of the actual ordering of the directives in the configuration file, the Allow from test2.com will be evaluated last and will override the Deny from foo.test2.com. All hosts not in the test2.com domain will also be allowed access because the default state will change to allow.

Sooooo, bearing all that in mind, you can use * for a wildcard and write...

Code: Select all
<Files *>
deny from 58.2.0.0 58.2.255.255
deny from 58.68.0.0 58.68.127.255
deny from 58.146.96.0 58.146.127.255
</Files>
<Files .htaccess>
deny from all
</Files> 


If you want to deny an IP block you can do this like:
deny from 58.0.0.0

or a range:
deny from 58.0.0.0/20 (58.0.0.0-58.0.15.255)
deny from 58.150.0.0/20 (58.150.0.0 - 58.150.15.255)


You can block IP, IP block, or domain like this...
deny from 88.151.
deny from goldeninternet.ru
More detailed information can be found at http://httpd.apache.org/docs/1.3/mod/mod_access.html/


Remember to upload .htaccess files, and .htpasswd files using ASCII mode.
User avatar
GardenSimply
Admin
 
Posts: 208
Joined: Sat Sep 15, 2007 10:31 am
Location: Oklahoma

Re: Blocking IPs

Postby joebrochin » Sat Oct 25, 2008 9:22 am

Thanks Jodi,

So that said can you have a peek at mine on Rhino to let me know if I have it right now?
joebrochin
Active Member
 
Posts: 121
Joined: Mon Sep 17, 2007 7:16 pm
Location: Jacksonville, NC

Re: Blocking IPs

Postby merger » Tue Dec 09, 2008 7:06 pm

Hi. do hope this helps you all out.
If you want to know the codes to block any country you can find this here.
http://www.find-ip-address.org/ip-country/
This is a drastic measure and stops any good clients from the country.
I find it much easier to just run a script I wrote that deletes articles that are spam before I see them.

First of all the code you want to ad to your htaccess files is this.
<Files .htaccess>
order allow,deny
deny from all
</Files>

This will prevent anyone from reading your htaccess or htpassword files.

If you have directories and wish them to be private.
IndexIgnore */*


Will prevent directory browsing if added to the directory in question's .htaccess file. Should a directory not have an index file.

This little code will prevent others from linking to your images as bandwidth leeching.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?domain.com/.*$ [NC]
RewriteRule .(gif|jpg)$ - [F]


If you want to send a message to not steal your images, this works great.
RewriteRule .(gif|jpg)$ http://www.myartsubmit.com/images/stolen.gif [R,L]


Which directs them to this file.Image


It is possible to use htaccess to ban Ip's . I have found this to work threw proxies and anonymous software's.
Its called get real IP and works. Make it into a php file, and just include it in your setup. or in the Header file. Which works for all files.
<?php
function getRealIP()
{

if( $_SERVER['HTTP_X_FORWARDED_FOR'] != '' )
{
$client_ip =
( !empty($_SERVER['REMOTE_ADDR']) ) ?
$_SERVER['REMOTE_ADDR']
:
( ( !empty($_ENV['REMOTE_ADDR']) ) ?
$_ENV['REMOTE_ADDR']
:
"unknown" );

$entries = split('[, ]', $_SERVER['HTTP_X_FORWARDED_FOR']);

reset($entries);
while (list(, $entry) = each($entries))
{
$entry = trim($entry);
if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) )
{

$private_ip = array(
'/^0\./',
'/^127\.0\.0\.1/',
'/^192\.168\..*/',
'/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/',
'/^10\..*/');

$found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);

if ($client_ip != $found_ip)
{
$client_ip = $found_ip;
break;
}
}
}
}
else
{
$client_ip =
( !empty($_SERVER['REMOTE_ADDR']) ) ?
$_SERVER['REMOTE_ADDR']
:
( ( !empty($_ENV['REMOTE_ADDR']) ) ?
$_ENV['REMOTE_ADDR']
:
"unknown" );
}

return $client_ip;

}
?>
merger
New Member
 
Posts: 7
Joined: Tue Dec 09, 2008 11:29 am
Location: Canada

Re: Blocking IPs

Postby GardenSimply » Thu Dec 11, 2008 4:09 am

Thanks for all those .htaccess tips Kevin! :)
User avatar
GardenSimply
Admin
 
Posts: 208
Joined: Sat Sep 15, 2007 10:31 am
Location: Oklahoma

Re: Blocking IPs

Postby rleeq » Tue Jan 13, 2009 10:46 am

While I agree that dealing with authors from India can be a pain, but I'm not sure it would be fair to ban all ip's from India. After all some of the authors write well and they abide by the guidelines.
Having said that, I to want to ban some ip's also. I tried to block an ip using the ip blocking feature of phpmyadmin but I guess I didn't set it up right so I kept looking. I found in the Elefante Administration Tools of my c-panel a process which blocks specific ip's without going through all the fuss of installing yet another set of scripts. It stands out in the control panel and so I've set it up to block two particular ip's I've been having trouble with. You may have been getting submissions from them also. The "ginfo" one, two, three and so on and another, Skin West. I've blocked the ip address those come from and if I don't receive any more articles from that author over the next week I will deem the ip blocked and go on to block others.

Well just thought I'd drop this in.

R'
User avatar
rleeq
New Member
 
Posts: 15
Joined: Tue Dec 09, 2008 12:26 pm
Location: South Florida

Re: Blocking IPs

Postby marvinko » Sun Jan 18, 2009 6:50 pm

If worse comes to worst ... check out http://www.blockacountry.com/ ... where you can get the .htaccess info to deny entire countries.

If you use this ... please don't block Canada ... I like looking around at other article directories. :lol:
marvinko
New Member
 
Posts: 13
Joined: Mon Sep 24, 2007 11:58 am

Re: Blocking IPs

Postby maha22 » Wed Sep 01, 2010 5:17 am

well i was curious to whether or not my isp can block ips. i play a game called ragnarok and i was told that i couldnt get on because my isp blocked my games from connecting this is possible?
=======================
Life Insurance Calculator|Life Insurance Comparison
maha22
New Member
 
Posts: 12
Joined: Mon Aug 23, 2010 6:06 am


Return to Article Dashboard Site Management

Who is online

Users browsing this forum: No registered users and 1 guest

cron