Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => PHP => Topic started by: Daniel Franklin on September 26, 2007, 01:19:55 PM



Title: Make More Secure Php Applications
Post by: Daniel Franklin on September 26, 2007, 01:19:55 PM
If you are writing a dynamic web site , you must use a database system like mysql .
Mysql is the most popular one . When you wrote a query like this Select * from adsense where col=1;
As you can see there is no ' , then the attacker can write his query and bypass yours .You can lost your private information and your site can be hacked.
To protect your site , use type casting . If your parameter is an integer use intval() function to protect malicious strings from your website.
If your parameter is a string , you must use addslashes() function .

$query="Select * from computers where os='".addslashes($_GET['os'])."'"; mysql_query($query);

$query="Select * from computers where can_execute_php=".intval($_GET['type']);

2-) xss atacks

Xss means cross site scripting .It depends on session & cookie stealing with javascript codes . if the script writes the parameter to the document without filtering , attacker can enter javascript codes and reach the cookie with document.cookie() function in javascript . To be protected you must use htmlspecialchars() function . it filters special html chars .

3-) Php injections

Eval function in php causes php injections and attacker can execute php code.There is no code to get protected .You must select the string well before you use eval() function.Its not good to give a paramater variable for eval function .

Bugra is a coder & Security tester . He reported a lot of well - known vulnerabilities like hotmail -xss and yahoo - xss . Original article can be found at http://www.getvaluable.info/uncategorized/make-more-secure-php-applications/ or you can visit anything you need for http://www.getvaluable.info

Article Source: http://EzineArticles.com/?expert=Bugra_Bayramoglu