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.



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

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 2nd, 2007, 08:33
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 57
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
Reply With Quote

  #2 (permalink)  
Old Feb 2nd, 2007, 09:12
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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";
?>
Reply With Quote
  #3 (permalink)  
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
Send a message via MSN to snow
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
Reply With Quote
  #4 (permalink)  
Old Feb 2nd, 2007, 09:21
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 57
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
Reply With Quote
  #5 (permalink)  
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
Send a message via MSN to snow
Re: Basic Web Site Security

Heh, try creating a site index.html or default.html...
Reply With Quote
  #6 (permalink)  
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
Send a message via MSN to snow
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?
Reply With Quote
  #7 (permalink)  
Old Feb 2nd, 2007, 09:35
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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?
Reply With Quote
  #8 (permalink)  
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
Send a message via MSN to snow
Re: Basic Web Site Security

You can download the php files in text form from the index directory, no?
Reply With Quote
  #9 (permalink)  
Old Feb 2nd, 2007, 09:43
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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.
Reply With Quote
  #10 (permalink)  
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
Send a message via MSN to snow
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?
Reply With Quote
  #11 (permalink)  
Old Feb 2nd, 2007, 10:06
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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
Reply With Quote
  #12 (permalink)  
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
Send a message via MSN to snow
Re: Basic Web Site Security

hmm, curious, is that standard with php or is it how your web server is configured?
Reply With Quote
  #13 (permalink)  
Old Feb 2nd, 2007, 10:51
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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.
Reply With Quote
  #14 (permalink)  
Old Feb 2nd, 2007, 12:19
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 57
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.
Reply With Quote
  #15 (permalink)  
Old Feb 2nd, 2007, 12:27
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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.
Reply With Quote
  #16 (permalink)  
Old Feb 2nd, 2007, 12:31
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 57
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!!
Reply With Quote
  #17 (permalink)  
Old Feb 2nd, 2007, 13:31
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Basic Web Site Security

No worries
We all start at the exact same place.
Reply With Quote
  #18 (permalink)  
Old Feb 2nd, 2007, 15:08
New Member
Join Date: Jan 2007
Location: Hockley, UK
Age: 57
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.
Reply With Quote
  #19 (permalink)  
Old Feb 2nd, 2007, 15:40
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
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
Reply With Quote
Reply

Tags
php, security

Thread Tools

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
Help with security wiggles Website Planning 16 Apr 9th, 2007 22:28
Basic Web Site Document Structure moojoo Webforumz Cafe 6 Jan 28th, 2007 03:34
Security cbrams9 JavaScript Forum 2 Sep 22nd, 2006 01:47
[req] Free basic web templates site + button design site slorryy Web Page Design 3 Feb 17th, 2006 17:05


All times are GMT. The time now is 11:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43