Re: Limiting repetitive file access

From: Manuel Lemos (mlemos_at_acm.org)
Date: 11/16/03


To: php-general@lists.php.net
Date: Sun, 16 Nov 2003 09:40:47 -0200

Hello,

On 11/16/2003 02:52 AM, Andre Dubuc wrote:
> Recently, a 'user' attempted to access a restricted area of my site
> repetitively (spanning five hours) entering the same url repetitively
> [probably by script]. A massive log file was generated. I would like to ban
> such behavior by limiting the number of successive 'get's a user can do (say
> 4 attempts) before an appropriate action is taken..
>
> As a temporary measure (until I can figure a better way) the url in question
> was disabled.
>
> What I'd like to do, on a per-file basis using $_SESSION, is a combination of
> ipaddress perhaps with a counter that records the number of times that file
> was accessed, and limit the number of successive 'get's that can be done
> before the file is no longer accessible.

This solutions will not avoid your problem.

Sometimes I have that problem because some users of my site think they
can use site sucking programs to get all its content.

What was done is to have a script monitoring the Web server logs and if
the same user of the same IP makes an excessive amount of accesses in a
short period, add it to the list of denied addresses for a while. This
way, the Web server will not even spare resources for abusing users.

Since you use .haccess based permissions, you can just update that file
regularly.

I do not have that script quite ready for release now, but if there is
interest, I can release it later as a part of this class that already
provides log watching services:

http://www.phpclasses.org/logwatcher

-- 
Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
http://www.phpclasses.org/


Relevant Pages

  • Re: 404 with IIS (6.0) PHP, CGI, Host Header on Windows 2003 Server
    ... I do not see a 404 error in you web server logs. ... > to the default "any host header" value, and make your 404 request again. ... > Kristofer Gafvert ...
    (microsoft.public.inetserver.iis)
  • Re: Hack attempt
    ... the user that your web server runs as. ... not allow inserting remote files. ... I'm Norbert Crettol, one of the sysadmins ... > Here are the logs we got (we get a remote copy of the web server logs ...
    (Focus-Linux)
  • Re: Hack attempt
    ... (Edit php.ini OR httpd.conf and add a ... Norbert Crettol wrote: ... > Here are the logs we got (we get a remote copy of the web server logs ...
    (Focus-Linux)
  • Re: Monitoring Web connections
    ... the logs depend on the web server software used. ... > Thanks, pkdenver ... >> the web server logs should give you all the info you are looking for. ... >>>I have a development machine I'm using to develop websites. ...
    (microsoft.public.windowsxp.network_web)