I would like to ask experienced PHP laruence for program security! -Php Tutorial

Source: Internet
Author: User
Ask experienced PHP laruence about program security !? After discussing how to develop a PHP website, apart from operating systems and WEB service software, we should pay attention to the security aspects of the program itself, and the small websites that we remember for the first time were hacked by bad guys in one month, check that an & lt; iframe & nbsp; src & quot; xxx & quot; & gt; xxx & lt; iframe & gt; is added at the bottom of the homepage ;, the result is that the old bullet ads ask experienced PHP old birds for program security !?
In addition to the operating system and WEB service software, you should pay attention to the security of the program.

I remember that the first time I made a small website for a customer, I was hacked by a bad guy. I found that I was added to the bottom of the homepage, and the result was an old advertisement. It may be caused by a program vulnerability.

I also heard that ICBC's website was spoofed.

Thank you!
!




------ Solution --------------------
Oh, let's look at some practical information.
/*
* Anti-injection processing
*/
If (! Get_magic_quotes_gpc ()){
Immit (___ FCKpd ___ 0
POST );
Immit (___ FCKpd ___ 0
GET );
Immit (___ FCKpd ___ 0
COOKIE );
}
// Anti-injection processing (adding a slash to the variable) function
// Parameter $ array is an array of anti-injection variables
Function immit (& $ array ){
Foreach ($ array as $ key => $ value ){
If (! Is_array ($ value )){
$ Array [$ key] = addslashes ($ value );
} Else {
Immit ($ array [$ key]);
}
}
}


How to Avoid SQL injection attacks in php


If (! Get_magic_quotes_gpc ()){
CallUserFunc (___ FCKpd ___ 0
GET, 'addslashes ');
CallUserFunc (___ FCKpd ___ 0
POST, 'addslashes ');
}
You can simply add 'to the field value, for example, query an article.
"SELECT * FROM table WHERE id = '$ ID '"

------ Solution --------------------
Pay attention to the following items:
Script attacks (mainly for clients ).
Solution: Use htmlspecialchars to process the text published by the user.

SQL injection.
Solution:
It is recommended to open get_magic_quotes_gpc. if not, use addslashes to replace the data transmitted by the user in post or get mode.
Or limit the length of transmitted data to a safe range (for example, limit 1-2 char lengths ),
Or strictly check the type of data transmitted by the user. I have seen someone checking keywords in asp. this is a solution, but the efficiency is not high.

Upload vulnerability:
Solution:
Check the size of the user's transferred file and limit its size
Check the type of the file that the user transfers. you are absolutely not allowed to pass the file that apache will interpret (check the file suffix)

Backup Recovery vulnerability:
Solution:
Manage the administrator password and make logs.

The above are some of the common attack methods I have summarized. What other methods do you want to discuss.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.