Web Design and Development Forums

How to secure scripts and pages

This is a discussion on "How to secure scripts and pages" within the PHP Forum section. This forum, and the thread "How to secure scripts and pages are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > PHP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old May 5th, 2008, 01:06   #1 (permalink)
Junior Member
 
Join Date: Oct 2006
Location: Spain
Age: 24
Posts: 10
Arrow How to secure scripts and pages

Hey all,

I just found out that PHP scripts/pages can be manipulated from things like forms when people post information to a server. Also SQL injections seem to be an issue that I didn't know about.
My problem is that I have very little knowledge of PHP and MySQL so being told that they could be a security risk is a little worrying as I don't know what to do to make them secure. I'm yet to add a form or guest book to my site so its not a problem to me yet but I am planning on adding one.

If anyone knows of any tutorials for noobs like me or if anyone can tell me how to secure forms, databases, guest books etc, I would really appreciate it.

Thanking you all in advance as I know you code wizards will have the answers

Wolf
Wolf Blade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 01:39   #2 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: How to secure scripts and pages

Just make sure they can't close the quotes in a query. Let's say your query is this:

PHP: Select all

$query "SELECT * FROM `mytable` WHERE `blah`='".$_GET['blee']."'"
If the hacker does something like "hello'yo" for the blee text field, they've just closed out of the quotes, and can run wild. So be sure to replace all the "'" with "\'", and you should be fine.
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 01:45   #3 (permalink)
Junior Member
 
Join Date: Oct 2006
Location: Spain
Age: 24
Posts: 10
Re: How to secure scripts and pages

Thanks for the reply mate,
I'm not exactly sure what that code is that you typed but I do understand your meaning (I think)
Basically, if hackers can close the quotes, they can alter the code and get information from the database or get access to information?

So by escaping the ' with a slash \' it stops them getting access?
Like I said, I'm a green as a leaf noob with PHP nd most scripting languages lol

Thanks again CV, this is the second time you helped me out :P
Wolf Blade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 01:51   #4 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: How to secure scripts and pages

Quote:
Originally Posted by Wolf Blade View Post
So by escaping the ' with a slash \' it stops them getting access?
Ya, in nearly all programming languages putting a backslash before a single quote or double quote stops it from closing the quotes. eg: 'Isn\'t this awesome?'

But its not necessary to backslash next to a single quote in a string enveloped by double quotes or vice versa.
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 01:58   #5 (permalink)
Junior Member
 
Join Date: Oct 2006
Location: Spain
Age: 24
Posts: 10
Re: How to secure scripts and pages

Great!
Thank you again CV, I think I should title future posts "CV, Help!" lol
Wolf Blade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 8th, 2008, 20:28   #6 (permalink)
Junior Member
 
Join Date: Feb 2008
Location: Michigan
Posts: 23
Re: How to secure scripts and pages

There's also often built-in ways to escape that stuff, for example PHP has mysql_real_escape_string:

http://us3.php.net/mysql_real_escape_string
awatson is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 8th, 2008, 22:25   #7 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: How to secure scripts and pages

thanks awatson. that'll come in handy! it'll save me a lot of time also.
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 9th, 2008, 19:43   #8 (permalink)
Junior Member
 
Join Date: Oct 2006
Location: Spain
Age: 24
Posts: 10
Re: How to secure scripts and pages

Hey,
Thanks for that awatson, I'll be using that soon enough
Wolf Blade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 10th, 2008, 16:03   #9 (permalink)
Junior Member
 
Join Date: Apr 2008
Location: uk
Age: 23
Posts: 36
Re: How to secure scripts and pages

sorry to butt in but found this very interesting, for a newbie, if i were to just do a search for "'" in dreamweaver and replace all with "\" would that work or is it only in certain areas you can do this?
bonnit is offline  
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

Thread Tools
Rate This Thread
Rate This Thread:

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
secure connections nightmares E-Commerce and Business 4 Nov 26th, 2007 23:10
Javascript - Updating web pages with snippets from other pages Ydot JavaScript Forum 3 Jul 10th, 2007 14:38
secure db benbramz MSSQL & Access 3 Jun 1st, 2005 18:07
Scripting Needed(adding pages to pages) Amari ASP Forum 1 Sep 4th, 2004 18:06
How secure is MS Access??? courtjester MSSQL & Access 13 Jan 29th, 2004 14:17



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 19:22.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59