can htaccess read from files?

can htaccess read from files?

am 14.04.2008 22:08:19 von MD Websunlimited

I'm helping out a friend with a site that has attracted a few idiots using
proxies. As soon as he bans one, they find another.

To save having to log in/FTP to the server, find the htaccess file and edit
it, is there any way we can set up an editable separate file (list) of
banned IP's that the htaccess file can read and apply? Maybe writeable by
the server so that he only needs to open a (hidden) page and enter the IP
range and have it added automatically? Or is there a simpler way of editing
the htaccess file directly from within the site?

Thanks for any help here!

Re: can htaccess read from files?

am 15.04.2008 02:09:50 von Brendan Gillatt

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

mentalguy2004 wrote:
> I'm helping out a friend with a site that has attracted a few idiots using
> proxies. As soon as he bans one, they find another.
>
> To save having to log in/FTP to the server, find the htaccess file and edit
> it, is there any way we can set up an editable separate file (list) of
> banned IP's that the htaccess file can read and apply? Maybe writeable by
> the server so that he only needs to open a (hidden) page and enter the IP
> range and have it added automatically? Or is there a simpler way of editing
> the htaccess file directly from within the site?

You could simply write the .htaccess file from a PHP script. This would
easily enable him to ban users quickly.

However, I must point out that banning individual IP addresses is fairly
ineffective - like you said as soon as one is banned another appears. Try
banning by traits the proxy has instead.

- --
Brendan Gillatt | GPG Key: 0xBF6A0D94
brendan {a} brendangillatt (dot) co (dot) uk
http://www.brendangillatt.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)

iD8DBQFIA/JOuv4tpb9qDZQRAncpAJwOdKOV3AIh3HF0/CijHhIBkIgyagCa AvVd
BHhIIQsafJyOBypVcv/kwjE=
=j50p
-----END PGP SIGNATURE-----

Re: can htaccess read from files?

am 16.04.2008 00:11:24 von MD Websunlimited

"Brendan Gillatt" wrote
in message news:QNKdnQqXvdHRb57VnZ2dneKdnZydnZ2d@pipex.net...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> mentalguy2004 wrote:
>> I'm helping out a friend with a site that has attracted a few idiots
>> using
>> proxies. As soon as he bans one, they find another.
>>
>> To save having to log in/FTP to the server, find the htaccess file and
>> edit
>> it, is there any way we can set up an editable separate file (list) of
>> banned IP's that the htaccess file can read and apply? Maybe writeable by
>> the server so that he only needs to open a (hidden) page and enter the IP
>> range and have it added automatically? Or is there a simpler way of
>> editing
>> the htaccess file directly from within the site?
>
> You could simply write the .htaccess file from a PHP script. This would
> easily enable him to ban users quickly.
>
> However, I must point out that banning individual IP addresses is fairly
> ineffective - like you said as soon as one is banned another appears. Try
> banning by traits the proxy has instead.
>
> - --
> Brendan Gillatt | GPG Key: 0xBF6A0D94
> brendan {a} brendangillatt (dot) co (dot) uk
> http://www.brendangillatt.co.uk

Thanks for the help. Do you know of any good PHP scripts that would help
here? I've tried Googling and all the relevant links I've found seem to be
dead.

Re: can htaccess read from files?

am 17.04.2008 00:58:41 von Brendan Gillatt

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

mentalguy2004 wrote:
> Thanks for the help. Do you know of any good PHP scripts that would help
> here? I've tried Googling and all the relevant links I've found seem to be
> dead.

Basically the idea is to end up with a file such as:


order allow,deny
deny from xxx.xxx.xxx.xxx
deny from yyy.yyy.yyy.yyy
deny from zzz.zzz.zzz.zzz
allow from all


So you would read the file, line by line until you found the start of the
'deny from' lines. You would then read these lines into an array, append
the newly blocked host, turn the array back into a string and add the
header and footer bits.


- --
Brendan Gillatt | GPG Key: 0xBF6A0D94
brendan {a} brendangillatt (dot) co (dot) uk
http://www.brendangillatt.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)

iD8DBQFIBoShuv4tpb9qDZQRAmuGAJ4jIQJnfS4lpzHs6kXUFOriHow7xwCf d/Tt
AwToTqrkZaR/e9TUcPRDScs=
=ICDx
-----END PGP SIGNATURE-----

Re: can htaccess read from files?

am 17.04.2008 05:15:28 von spam

"Brendan Gillatt" wrote
in message news:gKSdnWX88dkBGZvVnZ2dnUVZ8qijnZ2d@pipex.net...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> mentalguy2004 wrote:
> > Thanks for the help. Do you know of any good PHP scripts that would help
> > here? I've tried Googling and all the relevant links I've found seem to
be
> > dead.
>
> Basically the idea is to end up with a file such as:
>
>
> order allow,deny
> deny from xxx.xxx.xxx.xxx
> deny from yyy.yyy.yyy.yyy
> deny from zzz.zzz.zzz.zzz
> allow from all
>

>
> So you would read the file, line by line until you found the start of the
> 'deny from' lines. You would then read these lines into an array, append
> the newly blocked host, turn the array back into a string and add the
> header and footer bits.

Bad approach. Try a rewritemap where the key is REMOTE_ADDR. All your CGI
program has to do is append to the file that constitutes the map.

In my personal implementation of the map file, I write as the data field a
one word reason and the time stamp that the entry was added. I have a
reason because there are multiple ways of ending up in the file. Malicious
robots that spider "/robots.txt" forbidden resources is one reason. I also
share the map file with other server programs besides the web server.

Re: can htaccess read from files?

am 17.04.2008 10:17:45 von HansH

"D. Stussy" schreef in bericht
news:fu6fcg$pj4$1@snarked.org...
> "Brendan Gillatt" wrote
> in message news:gKSdnWX88dkBGZvVnZ2dnUVZ8qijnZ2d@pipex.net...
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Basically the idea is to end up with a file such as:
>>
>>
>> order allow,deny
>> deny from xxx.xxx.xxx.xxx
>> deny from yyy.yyy.yyy.yyy
>> deny from zzz.zzz.zzz.zzz
>> allow from all
>>

>>
>> So you would read the file, line by line until you found the start of the
>> 'deny from' lines. You would then read these lines into an array, append
>> the newly blocked host, turn the array back into a string and add the
>> header and footer bits.
>
> Bad approach. Try a rewritemap where the key is REMOTE_ADDR. All your
> CGI
> program has to do is append to the file that constitutes the map.
>
I like file-based rewritemaps too for just 1 reason:
changes are effective without restarting Apache!

BUT unfortunately to the OP RewriteMaps are NOT allowed in .htaccess ...

HansH

Re: can htaccess read from files?

am 18.04.2008 03:54:26 von spam

"HansH" wrote in message
news:480707ab$0$14343$e4fe514c@news.xs4all.nl...
> "D. Stussy" schreef in bericht
> news:fu6fcg$pj4$1@snarked.org...
> > "Brendan Gillatt"
wrote
> > in message news:gKSdnWX88dkBGZvVnZ2dnUVZ8qijnZ2d@pipex.net...
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Basically the idea is to end up with a file such as:
> >>
> >>
> >> order allow,deny
> >> deny from xxx.xxx.xxx.xxx
> >> deny from yyy.yyy.yyy.yyy
> >> deny from zzz.zzz.zzz.zzz
> >> allow from all
> >>

> >>
> >> So you would read the file, line by line until you found the start of
the
> >> 'deny from' lines. You would then read these lines into an array,
append
> >> the newly blocked host, turn the array back into a string and add the
> >> header and footer bits.
> >
> > Bad approach. Try a rewritemap where the key is REMOTE_ADDR. All your
> > CGI
> > program has to do is append to the file that constitutes the map.
> >
> I like file-based rewritemaps too for just 1 reason:
> changes are effective without restarting Apache!
>
> BUT unfortunately to the OP RewriteMaps are NOT allowed in .htaccess ...

True (I forgot about that). However, he didn't say that .htaccess is his
ONLY means to control the server, and it read as if his friend does have
access to the main configuration file(s).