NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Injection (php-mysql)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-26-2007, 11:51 PM   #26 (permalink)
I'll do it
 
-Nick-'s Avatar
Join Date: Dec 2005
Location: India
Posts: 6,927
-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness
 


Member of the Month
September 2007
Adoption
Use this

PHP Code:
$var striptags($var);
????: NamePros.com http://www.namepros.com/programming/399017-injection-php-mysql.html
$var htmlspecialchars($var);
$var trim($var);
$var stripslashes($var);
$var mysql_real_escape_string($var); 
-Nick- is offline  
Old 11-27-2007, 06:26 AM   #27 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by -Nick-
Use this

PHP Code:
$var striptags($var);
$var htmlspecialchars($var);
$var trim($var);
$var stripslashes($var);
????: NamePros.com http://www.namepros.com/showthread.php?t=399017
$var mysql_real_escape_string($var); 
You should not run a variable through stripslashes unless it has been run through addslashes or magic_quotes_gpc otherwise you could be causing problems.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 11-27-2007, 04:05 PM THREAD STARTER               #28 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



I found another one.

If i try to enter this to my database it does not work.
PHP Code:

To
x@x.org 
????: NamePros.com http://www.namepros.com/showthread.php?t=399017
(There are line breaks before and after)
baris22 is offline  
Old 11-28-2007, 06:00 AM   #29 (permalink)
NamePros Regular
 
nick's Avatar
Join Date: Jun 2004
Location: Iowa City
Posts: 705
nick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud of
 


Save The Children
what happens when you try this:

Code:
$query="INSERT INTO `filedetails` VALUES ('', '$type', '$title', '$description', '$links','0000000000')";
__________________
formally ninedogger
------
Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends
nick is offline  
Old 11-29-2007, 02:33 AM   #30 (permalink)
i love automation
 
xrvel's Avatar
Join Date: Nov 2007
Location: xrvel.com
Posts: 1,620
xrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant future
 





Originally Posted by peter@flexiwebhost
You should not run a variable through stripslashes unless it has been run through addslashes or magic_quotes_gpc otherwise you could be causing problems.
Usually, i only stripslashes the input and addslashes it when i want to display it. Maybe you can explain what kind of problem?
__________________
xrvel is offline  
Old 11-29-2007, 05:49 AM   #31 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by xrvel
Usually, i only stripslashes the input and addslashes it when i want to display it. Maybe you can explain what kind of problem?
If you add slashes to something that has already been run through add slashes (that is effectively what magic_quotes_gps does).

You should not be using add slashes for data that is going to be output to the browser. The function was intended to make data safe for inputting into a database and will not make data safe for outputting to the user. The function you should be using is htmlspecialchars() or htmlentities().

Even if you use add slashes for data that is going to be input into the database it does not take into consideration of what database you are inserting too. Many characters for example that are special characters in mySQl will remain untouched and will alter how your query will run.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 11-29-2007, 05:57 AM   #32 (permalink)
i love automation
 
xrvel's Avatar
Join Date: Nov 2007
Location: xrvel.com
Posts: 1,620
xrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant future
 





Originally Posted by peter@flexiwebhost
If you add slashes to something that has already been run through add slashes (that is effectively what magic_quotes_gps does).

You should not be using add slashes for data that is going to be output to the browser. The function was intended to make data safe for inputting into a database and will not make data safe for outputting to the user. The function you should be using is htmlspecialchars() or htmlentities().
????: NamePros.com http://www.namepros.com/showthread.php?t=399017

Even if you use add slashes for data that is going to be input into the database it does not take into consideration of what database you are inserting too. Many characters for example that are special characters in mySQl will remain untouched and will alter how your query will run.
Thanks. i only thought about escaping single quotes, now i will filter other special chars ...
__________________
xrvel is offline  
Old 11-29-2007, 06:08 AM   #33 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by xrvel
Thanks. i only thought about escaping single quotes, now i will filter other special chars ...
????: NamePros.com http://www.namepros.com/showthread.php?t=399017
In html your concerns are more with things such as <>. If you only escape quotes then the problem has not been sorted as an XSS attack would still be possible. Javascript and HTML are not strongly typed languages/markups they do not require the quotes. This is where the html functions I mention help.

In mySQL you have characters such as -- which starts a comment and ; which ends a query (and anything after is a new query) however this 1 depends on the method you use for connecting.

If you really want to make an SQL statement safe then use prepared statements. SQL injection is not possible when this method is used.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:38 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger