Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-23-2004, 12:22 AM   #1 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
Can you download a PHP file

Without executing it? If so, how do you protect against it? Also, if I have other config files with database passwords, RCON passwords etc, how can I hide them?
__________________
Current Project
Redline is offline   Reply With Quote
Old 11-23-2004, 02:57 AM   #2 (permalink)
DavH27
PHP Pilgrim
 
DavH27's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 167
DavH27 is on a distinguished road
db.php for example will not show anything unless you echo it.

db.inc is treated as a plain text and is viewable.

db.inc.php on the other hand is still a php file and is not viewable.

There are programs out there that 'cache' an entire website which would include one's php code. I just haven't researched intotwhat these programs are, how they work and hwo to prevent them from doing thier work.

What I ahve gatehred so far is they act like a spider, but there's no point in finding thier 'ROBOT' name to exclude it from your site as they have the option to 'disguise' themselves as something else such as a GoogleBot. In fact they don't even need to pay attention to a ROBOTS.txt file.

There are a few tutorials on preventing site caching and tightening php security, so my first suggestion would eb to consult Google

I believe you can secure passwords for db, etc by putting the file/s into a folder, something like your 'inc' folder then use Apache's htaccess to secure it.
__________________
Davy - Programming since 1998 [CV]
Currently working on: n/a
Status: n/a
DavH27 is offline   Reply With Quote
Old 11-23-2004, 06:25 PM   #3 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Simple answer: no. If the file name ends in .php (or any other applicable extension that PHP is set to execute for, php3, phtml, etc) then it will try to execute.

As Dave mentioned, there is the use of .inc which wont execute when viewed, but you typically don't want people viewing these files.

The best thing would be to place all of these config files outside the webroot, so there's no possibility of them being access via a browser. (only for php includes) Second to that, if you have to put them under the webroot then secure them via .htaccess. eg:

Code:
<Limit GET POST PUT DELETE>
    Deny from all
</Limit>
idx is offline   Reply With Quote
Old 11-25-2004, 03:12 AM   #4 (permalink)
DavH27
PHP Pilgrim
 
DavH27's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 167
DavH27 is on a distinguished road
How do you 'reference' a php including function to a file that is not in the web root?
__________________
Davy - Programming since 1998 [CV]
Currently working on: n/a
Status: n/a
DavH27 is offline   Reply With Quote
Old 11-25-2004, 08:12 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
what about just using one php file to highlight another file? people could copy and paste then.

http://us2.php.net/manual/en/functio...light-file.php
__________________
Mike
sde is offline   Reply With Quote
Old 11-28-2004, 02:51 PM   #6 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Quote:
Originally Posted by DavH27
How do you 'reference' a php including function to a file that is not in the web root?
Say your webroot is /home/foo/htdocs .. Just put your stuff somewhere under /home/foo/ and it's out of the webroot. In some cases that's not possible, but it should be.

Then include:
PHP Code:
require_once '/home/foo/db/inc/config.php'
-r
idx is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
download a remote file to the local machine. sde Java 4 12-04-2004 10:49 AM
does PHP talk to JAVA class file?? Keith PHP 2 06-18-2004 08:23 AM
Writing to a file. (PHP) Nasimov PHP 1 03-11-2004 05:19 AM


All times are GMT -8. The time now is 10:47 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting