Basic Web Site Security

This is a discussion on "Basic Web Site Security" within the Website Planning section. This forum, and the thread "Basic Web Site Security are both part of the Planning Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Planning Your Website > Website Planning

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Feb 2nd, 2007, 08:33
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 58
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Basic Web Site Security

I am just moving into the world of creating a web site based on HTML, CSS, PHP and a bit of Javascript to handle events.
At the moment I am developing on a host site that I have used for several years to display photos etc.. Therefore I have limited control over the facilities on the site.
I would like my included php scripts to not be readable through the browser to help keep the site a bit more secure. Can anyone give me some clues of where to start looking for the tools I need.
I prefer not to have to start reading a 2000 page book on web security telling me to use all sorts of expensive tools I cannot yet afford!
PS I am a very experienced IT professional in the old world of process control and manufacturing control systems so I can figure out techie stuff with some clues.
Cheers for any help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Feb 2nd, 2007, 09:12
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

You're in luck! It's all server side so no information about what the PHP is doing goes to a browser. It just sends the results along.

Try it yourself by making this file and trying to access it via a browser:

Code: Select all
<?php
$super_secret_password = "asdfdasdf";
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Feb 2nd, 2007, 09:16
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Hi there! Great to have you here at the Forumz!

As to your problem - there would be no way for a user to read your php code from their browser, as far as I am aware they'd have to get into the file store on your server. Or are you referring to something else?

PHP is a server side language which means that it is processed on the server and the browser is sent the resulting HTML/javascript code. All the user can ever get access to, in the normal course of things, is what that PHP has generated.

Hope this helps!
And I hope you like it here
Snow

Additional: Grr, ryan beat me to it! Welcome anyway kthompso!

Last edited by snow; Feb 2nd, 2007 at 09:17. Reason: Additional
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Feb 2nd, 2007, 09:21
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 58
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Ryan, thanks for responding so quickly.

What you said is correct but that's not the problem. To test out using evemts in JS a created an HTML link with a URL of a blank string "". When I clicked on it an index of my files appeared! If I click on them I can see the PHP code!

So all my PHP scripts are there for the world to attack me through!

I guess this is a server permissions thing but I tried tying down the directories world permissions and then the pages failed with a server error.

This must be a common problem.

regards,
Ken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Feb 2nd, 2007, 09:24
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Heh, try creating a site index.html or default.html...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Feb 2nd, 2007, 09:28
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Just to note this won't solve the problem entirely as it sounds like a user would be able to type in "www.you.com/your.php" and get access to the code... but they won't have a nice directory to show them where it is at least, and once they can't view the name - it'll be almost impossible to guess...

Is that what you were after?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Feb 2nd, 2007, 09:35
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Perhaps your server is misconfigured or you have an error in your code. Under no circumstances should a server send over PHP in text form. Even JavaScript can't access it. Could you provide us with a link?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Feb 2nd, 2007, 09:42
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

You can download the php files in text form from the index directory, no?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Feb 2nd, 2007, 09:43
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Nope. PHP is parsed on the server. There's no way to even force download a PHP file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Feb 2nd, 2007, 09:56
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

I don't understand why not?

Create a directory on your webspace without an index/default.htm file but a nice little php document sitting there - you should be able to right-click save when you go to that directory, no?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Feb 2nd, 2007, 10:06
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

http://ryanfait.com/test/

test1.php:

Code: Select all
<?php
echo "Test";
?>
test2.php:
Code: Select all
<?php
$variable = "this and that";
$password = "whatever";
?>
Try it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Feb 2nd, 2007, 10:11
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

hmm, curious, is that standard with php or is it how your web server is configured?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Feb 2nd, 2007, 10:51
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

PHP is a language handled by the server, and only the server. No part of it ever reaches the user. Either you have PHP installed and everything is parsed correctly, or you don't and the browser treats it as a text file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Feb 2nd, 2007, 12:19
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 58
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

This is not a PHP problem. Its a problem Server problem. If I put in a URL that points to a directory, any dircetory within my site(that does not have an index.html file) I get the list files. I can then double click and they pop up in notepad in full.
I will research a bit more and feed back.
This is really quite important to any relative "newbie", like myself, building a site and wanting to keep their PHP code "confidential".

Cheers for all the responses.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Feb 2nd, 2007, 12:27
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Ah, that makes more sense. Servers are basically computers. Just like if you open up a folder on your computer, if you open up a directory on a server, it will show you everything in that folder. The easiest way to avoid this is by setting up 404 pages.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Feb 2nd, 2007, 12:31
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 58
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Doh
I have seen them but I don't know what you mean by setting them up. I will research them but if you want to give me the quick start, great!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Feb 2nd, 2007, 13:31
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

No worries
We all start at the exact same place.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18  
Old Feb 2nd, 2007, 15:08
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 58
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

Solved!!
I found a really useful link
http://www.ecs.soton.ac.uk/~jjf103/i...dex.php?page=4
That led me to the .htaccess file.
Very carefully I altered this to have the line:

IndexIgnore *

Now no files are shown in the index through the browser. My FTP access that I use to maintain the site is still fully working. I may need to do some further tuning but for now I am happy.
I remember using this file before to maintain group access to web sites. I think it is a key resource to such controls on Apache servers.

Thanks for all the rapid support. Very encouraging.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19  
Old Feb 2nd, 2007, 15:40
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

No problem! Just remember that having a directory's contents displayed is useful sometimes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
php, security

Thread Tools
Show Printable Version