UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 7th July 2008, 10:31 AM   #1 (permalink)
yatesy87
Registered User
 
Join Date: Feb 2005
Location: St. Helens, England
Posts: 117
php sql injection attacks

hi,

One of my clients uses a simple cms system for updating pages on his website.

the problem arose last week that when inserting the ' sign it would cause an injection attack. now normally i understand that by doing a simple php replace function would eliminate this problem. unfortunately the client is a professional writer and for grammer etvc etc reasons needs to show these signs in his documents.

just wondering if anybody knows a way that the ' can be placed into the database and tehn retrieved so that it shows on the website???
__________________
You learn something new every day!
yatesy87 is offline   Reply With Quote
Old 7th July 2008, 11:38 AM   #2 (permalink)
TygerTyger
Lumberjack and OK
 
Join Date: Aug 2004
Posts: 824
mysql_real_escape_string($value) when adding to the database.

stripslashes($value) when retrieving from the database.
TygerTyger is offline   Reply With Quote
Old 7th July 2008, 11:41 AM   #3 (permalink)
MrBen
Munky!
 
MrBen's Avatar
 
Join Date: Sep 2003
Location: nr Woking, England
Posts: 2,585
Check out mysql_real_escape_string which can be used to escape input so it can be safely inserted into the database.

Or move to using the new mysqli library in PHP5 for connecting to MySQL. You can then use mysqli_prepare and mysqli_stmt_bind_param. You don't need to bother escaping the input then as it is handled for you.

Ben
__________________
The impossible I can do today, miracles take a little longer

Veterinary Practice Management System by SoftFooding
Internet Data Usage Calculator: Estimate your monthly bandwidth usage for your Internet connection.
Little Red: Nordic Style Rye Bread
MrBen is offline   Reply With Quote
Old 7th July 2008, 10:01 PM   #4 (permalink)
fluxman
Registered User
 
Join Date: Nov 2005
Posts: 123
in case anybody doesn't know, if you don't use mysql_real_escape string, then you can hack into password protected areas using a username/password of
Code:
' or ''='
or

Code:
' or 1=1; --
and you can even insert malicious sql statement that delete tables etc.

I was bored one morning and tried to find websites I could "hack into" using the most basic mysql attacks...I found three in my local area alone.. :S good fun tho!

(not that i'm trying to promote malicious hacking, but if you're not aware of at least the above, then you shouldn't be charging for making websites with password protected sections!)
fluxman is offline   Reply With Quote
Old 7th July 2008, 11:07 PM   #5 (permalink)
desquinn
Senior Member
 
Join Date: Dec 2005
Location: Paisley
Posts: 317
and that would you be breaking the law specifically the Computer Misuse Act (1994)
desquinn is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes 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

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


All times are GMT. The time now is 04:00 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309