PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > Newbie question - Hide a file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

Newbie question - Hide a file

Réponse
 
LinkBack Outils de la discussion
Vieux 27/01/2008, 22h17   #1
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Newbie question - Hide a file

I plan to have a client-side application (not a browser) pass an encrypted
user name and password to a php file for validation, which will return an
xml string if the user is validated.

Obviously I don't want Apache to serve up that php file to any browser or
other app that asks for it. How do I prevent that from happening?

Alternatively, is there a better method to accomplish what I'm trying to do?



  Réponse avec citation
Vieux 28/01/2008, 18h13   #2
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

On Sun, 27 Jan 2008 14:17:15 -0800, "Paul Pedersen"
<nospam@no.spam> wrote:

> I plan to have a client-side application (not a browser) pass an encrypted
> user name and password to a php file for validation, which will return an
> xml string if the user is validated.
>
> Obviously I don't want Apache to serve up that php file to any browser or
> other app that asks for it. How do I prevent that from happening?


First off all, apache doesn't "serve up" .php if you
configure it to run the script. It just runs the php
script and the script decides what the response should be.

You can't prevent a browser or other app to try to do the
same as your app. It's apache, so your app will send a
request like:
GET /validate.php?u=encrypteduid&p=encryptedpsw HTTP/1.1
or
POST /validate.php HTTP/1.1
with the encrypted userID/password in the request header.
Any socket capable program can imitate that.

if the request is well-formed you can't prevent Apache
from triggering the .php script, regardless the client
which composed it.

Just a few possibilities:

1) You can obfuscate by using an uncommon port (not 80 or
8080).

2) You can obfuscate by sending an uncommon query string
GET /validate.php?somestring_with_encrypted_uid_and_psw

3) You can obfuscate by leaving out the .php extension and
using the trick in
http://richardlynch.blogspot.com/200...sposition.html
4) Your php script can refuse to answer invalid requests,
either by sending nothing or sending a 403 response and
disconnecting.

4) Require a valid client certificate.

6) A combination of 1) thru 5)

7) Of course your encryption is perfect and your script
will only send the .xml file if the userID and password
are correct, so what do you worry about?

> Alternatively, is there a better method to accomplish
> what I'm trying to do?


It will have been done before, but I don't know any
examples.

HTH
--
( Kees
)
c[_] Se cio` che dici non offende nessuno, vuol
dire che non hai detto nulla. (Oscar Wilde) (#94)
  Réponse avec citation
Vieux 28/01/2008, 22h14   #3
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

Thanks for your responses. All good suggestions.

But I don't think my original question got answered.



> First off all, apache doesn't "serve up" .php if you
> configure it to run the script.


Perhaps that's what I was asking for. How?



> You can't prevent a browser or other app to try to do the
> same as your app.


I don't mind that. If the request doesn't validate, nothing significant will
be returned.

What I'm concerned about is someone being able to read the php file itself.

What's to prevent someone from, for instance, using something like
URLDownloadToFile to retrieve the file:
"http://www.mysite.com/loginvalidation.php"?




  Réponse avec citation
Vieux 28/01/2008, 22h33   #4
William Colls
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

Paul Pedersen wrote:
> Thanks for your responses. All good suggestions.
>
> But I don't think my original question got answered.
>
>
>
>> First off all, apache doesn't "serve up" .php if you
>> configure it to run the script.

>
> Perhaps that's what I was asking for. How?
>
>
>
>> You can't prevent a browser or other app to try to do the
>> same as your app.

>
> I don't mind that. If the request doesn't validate, nothing significant will
> be returned.
>
> What I'm concerned about is someone being able to read the php file itself.
>
> What's to prevent someone from, for instance, using something like
> URLDownloadToFile to retrieve the file:
> "http://www.mysite.com/loginvalidation.php"?
>

php executes on the server side, and is never visible to the client. All
that is visible to the client is whatever the php file returns when it
executes.

Except if course if your security has been breached, and an intruder is
hacking your site.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
  Réponse avec citation
Vieux 28/01/2008, 23h19   #5
Jim Hayter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

Paul Pedersen wrote:
> Thanks for your responses. All good suggestions.
>
> But I don't think my original question got answered.
>
>
>
>> First off all, apache doesn't "serve up" .php if you
>> configure it to run the script.

>
> Perhaps that's what I was asking for. How?
>
>
>
>> You can't prevent a browser or other app to try to do the
>> same as your app.

>
> I don't mind that. If the request doesn't validate, nothing significant will
> be returned.
>
> What I'm concerned about is someone being able to read the php file itself.
>
> What's to prevent someone from, for instance, using something like
> URLDownloadToFile to retrieve the file:
> "http://www.mysite.com/loginvalidation.php"?
>


You put your scripts in a directory that is outside of your DocumentRoot
and use a scriptalias directive. You should never put scripts under
your DocumentRoot.

Jim
  Réponse avec citation
Vieux 29/01/2008, 17h11   #6
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file


"William Colls" <william@procomsys.com> wrote in message
news:479E5824.2080602@procomsys.com...

>> What's to prevent someone from, for instance, using something like
>> URLDownloadToFile to retrieve the file:
>> "http://www.mysite.com/loginvalidation.php"?
>>

> php executes on the server side, and is never visible to the client. All
> that is visible to the client is whatever the php file returns when it
> executes.
>


I have used exactly that method to retrieve php files from some sites.



  Réponse avec citation
Vieux 29/01/2008, 17h14   #7
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file


"Jim Hayter" <see.reply.to@nowhere.invalid> wrote in message
news:13psoo8lc427cc0@news.supernews.com...

>> What's to prevent someone from, for instance, using something like
>> URLDownloadToFile to retrieve the file:
>> "http://www.mysite.com/loginvalidation.php"?
>>

>
> You put your scripts in a directory that is outside of your DocumentRoot
> and use a scriptalias directive. You should never put scripts under your
> DocumentRoot.
>
> Jim


Now that's starting to make sense. Thanks.

But how do I do that?

Especially if my web site is hosted on a shared server somewhere in
cyberspace, how do I put files "outside DocumentRoot"?



  Réponse avec citation
Vieux 30/01/2008, 21h23   #8
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file


"Paul Pedersen" <nospam@no.spam> wrote in message
news:PMmdnb5lgLdrwwLanZ2dnUVZ_uevnZ2d@comcast.com. ..
>
> "Jim Hayter" <see.reply.to@nowhere.invalid> wrote in message
> news:13psoo8lc427cc0@news.supernews.com...
>
>>> What's to prevent someone from, for instance, using something like
>>> URLDownloadToFile to retrieve the file:
>>> "http://www.mysite.com/loginvalidation.php"?
>>>

>>
>> You put your scripts in a directory that is outside of your DocumentRoot
>> and use a scriptalias directive. You should never put scripts under your
>> DocumentRoot.
>>
>> Jim

>
> Now that's starting to make sense. Thanks.
>
> But how do I do that?
>
> Especially if my web site is hosted on a shared server somewhere in
> cyberspace, how do I put files "outside DocumentRoot"?



I found the answer, for anyone else who has this problem. Sign in to your
hosting account and find a a place that will allow you to set file and
folder permissions.

I still haven't found how to do that on the Apache server on my local
machine, but I'm sure there's a way.



  Réponse avec citation
Vieux 04/02/2008, 10h43   #9
Erwin Moller
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

Paul Pedersen wrote:

<snip>

>> But how do I do that?
>>
>> Especially if my web site is hosted on a shared server somewhere in
>> cyberspace, how do I put files "outside DocumentRoot"?

>
>
> I found the answer, for anyone else who has this problem. Sign in to your
> hosting account and find a a place that will allow you to set file and
> folder permissions.
>
> I still haven't found how to do that on the Apache server on my local
> machine, but I'm sure there's a way.
>


That is not placing files outside documentroot.
You are describing some system you havin't even mentioned.
Placinf file outside documentroot mean that you put them in a directory
that is simply not under your documentroot.
eg: If the documentroot for your webapp is:
/home/paul/public_html/
you place them for example here:
/home/paul/mydir/

Bottomline is nobody can type something like this:
http://www.example.com/~paul/secretfile
and access the file.

Regards,
Erwin Moller
  Réponse avec citation
Vieux 04/02/2008, 20h36   #10
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file


"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in
message news:47a6ecac$0$85786$e4fe514c@news.xs4all.nl...
> Paul Pedersen wrote:
>
> <snip>
>
>>> But how do I do that?
>>>
>>> Especially if my web site is hosted on a shared server somewhere in
>>> cyberspace, how do I put files "outside DocumentRoot"?

>>
>>
>> I found the answer, for anyone else who has this problem. Sign in to your
>> hosting account and find a a place that will allow you to set file and
>> folder permissions.
>>
>> I still haven't found how to do that on the Apache server on my local
>> machine, but I'm sure there's a way.
>>

>
> That is not placing files outside documentroot.
> You are describing some system you havin't even mentioned.
> Placinf file outside documentroot mean that you put them in a directory
> that is simply not under your documentroot.
> eg: If the documentroot for your webapp is:
> /home/paul/public_html/
> you place them for example here:
> /home/paul/mydir/
>
> Bottomline is nobody can type something like this:
> http://www.example.com/~paul/secretfile
> and access the file.



Yes, that's what I meant.

Although I am running Apache locally for test and development purposes, that
is not where the site is hosted. It's hosted on a remote shared server
running Apache, and I don't think I have a way to put a directory "outside"
documentroot in that situation.

I know that's not strictly an Apache issue, but if you have an answer, I'd
be glad to hear it.





  Réponse avec citation
Vieux 04/02/2008, 22h25   #11
Andy Ruddock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

Paul Pedersen wrote:
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in
> message news:47a6ecac$0$85786$e4fe514c@news.xs4all.nl...
>> Paul Pedersen wrote:
>>
>> <snip>
>>
>>>> But how do I do that?
>>>>
>>>> Especially if my web site is hosted on a shared server somewhere in
>>>> cyberspace, how do I put files "outside DocumentRoot"?
>>>
>>> I found the answer, for anyone else who has this problem. Sign in to your
>>> hosting account and find a a place that will allow you to set file and
>>> folder permissions.
>>>
>>> I still haven't found how to do that on the Apache server on my local
>>> machine, but I'm sure there's a way.
>>>

>> That is not placing files outside documentroot.
>> You are describing some system you havin't even mentioned.
>> Placinf file outside documentroot mean that you put them in a directory
>> that is simply not under your documentroot.
>> eg: If the documentroot for your webapp is:
>> /home/paul/public_html/
>> you place them for example here:
>> /home/paul/mydir/
>>
>> Bottomline is nobody can type something like this:
>> http://www.example.com/~paul/secretfile
>> and access the file.

>
>
> Yes, that's what I meant.
>
> Although I am running Apache locally for test and development purposes, that
> is not where the site is hosted. It's hosted on a remote shared server
> running Apache, and I don't think I have a way to put a directory "outside"
> documentroot in that situation.
>
> I know that's not strictly an Apache issue, but if you have an answer, I'd
> be glad to hear it.
>


That depends on the configuration at the webhost. I use one where I have
access via ftp & ssh to place files outside documentroot.
ftp & ssh into $HOME, documentroot is $HOME/public_html

--
Andy Ruddock
------------
andy_DOT_ruddock_AT_gmail_DOT_com (GPG Key ID 0x74F41E8F)
  Réponse avec citation
Vieux 04/02/2008, 23h00   #12
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file


"Andy Ruddock" <andy.ruddock+news@gmail.com> wrote in message
news:47a790de$1@proxy.mimer.no...
>>> Bottomline is nobody can type something like this:
>>> http://www.example.com/~paul/secretfile
>>> and access the file.

>>
>>
>> Yes, that's what I meant.
>>
>> Although I am running Apache locally for test and development purposes,
>> that
>> is not where the site is hosted. It's hosted on a remote shared server
>> running Apache, and I don't think I have a way to put a directory
>> "outside"
>> documentroot in that situation.
>>
>> I know that's not strictly an Apache issue, but if you have an answer,
>> I'd
>> be glad to hear it.
>>

>
> That depends on the configuration at the webhost. I use one where I have
> access via ftp & ssh to place files outside documentroot.
> ftp & ssh into $HOME, documentroot is $HOME/public_html
>


With mine, it "appears" that the main directory IS documentroot and I cannot
change it.
Instead, I can create directories within that, and prevent Apache from
making those accessible except by my own scripts.

Is that possibly the case, or am I misunderstanding something? If it
matters, I think they are using Apache 1.x.




  Réponse avec citation
Vieux 05/02/2008, 16h10   #13
Andy Ruddock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file

Paul Pedersen wrote:
> "Andy Ruddock" <andy.ruddock+news@gmail.com> wrote in message
> news:47a790de$1@proxy.mimer.no...
>>>> Bottomline is nobody can type something like this:
>>>> http://www.example.com/~paul/secretfile
>>>> and access the file.
>>>
>>> Yes, that's what I meant.
>>>
>>> Although I am running Apache locally for test and development purposes,
>>> that
>>> is not where the site is hosted. It's hosted on a remote shared server
>>> running Apache, and I don't think I have a way to put a directory
>>> "outside"
>>> documentroot in that situation.
>>>
>>> I know that's not strictly an Apache issue, but if you have an answer,
>>> I'd
>>> be glad to hear it.
>>>

>> That depends on the configuration at the webhost. I use one where I have
>> access via ftp & ssh to place files outside documentroot.
>> ftp & ssh into $HOME, documentroot is $HOME/public_html
>>

>
> With mine, it "appears" that the main directory IS documentroot and I cannot
> change it.
> Instead, I can create directories within that, and prevent Apache from
> making those accessible except by my own scripts.
>
> Is that possibly the case, or am I misunderstanding something? If it
> matters, I think they are using Apache 1.x.
>


It's quite possible that your hoster has set up apache in this fashion,
in which case you'll probably have to use .htaccess to prevent the files
simply being delivered in response to a direct request via http.
Again, what you can achieve in this way is dependent upon the
configuration at your webhost.

--
Andy Ruddock
------------
andy_DOT_ruddock_AT_gmail_DOT_com (GPG Key ID 0x74F41E8F)
  Réponse avec citation
Vieux 05/02/2008, 18h23   #14
Paul Pedersen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question - Hide a file


"Andy Ruddock" <andy.ruddock+news@gmail.com> wrote in message
news:47a88a5e$1@proxy.mimer.no...
> It's quite possible that your hoster has set up apache in this fashion,
> in which case you'll probably have to use .htaccess to prevent the files
> simply being delivered in response to a direct request via http.
> Again, what you can achieve in this way is dependent upon the
> configuration at your webhost.
>
> --
> Andy Ruddock
> ------------
> andy_DOT_ruddock_AT_gmail_DOT_com (GPG Key ID 0x74F41E8F)



That's ful information. Thanks!



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h21.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,27192 seconds with 22 queries