The security of program code is a reflection of a programmer’s multi-faceted qualities in developing applications. Let me summarize my experience below. Friends who need to know more can refer to it.
Baidu. After setting open_basedir, only php scripts in the specified directory and subdirectory will be executed.
Using php to read directories or files other than open_basedir will report an error
Insufficient permissions
Generally, virtual host providers are set to /tmp and /home
This is what users are used to. We need to find ways to solve these problems. Here is a summary of some PHP security issues.
1. Be careful when including. Check whether you have this file locally to avoid security vulnerabilities.
For example:
The code is as follows
代码如下 |
复制代码 |
include $module.'.php';
?> |
|
Copy code
|
Include $module.'.php';
?>
代码如下 |
复制代码 |
if(file_exists($module.'.php')){
include $module.'.php';
}
?> |
It is assumed here that $module is function/42833.htm target=_blank>global variable.
This script gives the attacker the opportunity to execute any PHP code on your server. For example, he can just add ?module=http://example.com/my after the browser URL. When PHP receives this URL, the value of the "$module" variable in the script will be set to http://example.com/my. Therefore, it is very dangerous when php executes include...
Solution: Check when closing register_globals or include in php.ini.
The code is as follows
|
Copy code
代码如下 |
复制代码 |
$query "select login_id from users where user='$user' and pwd='$pw'";
mysql_query($query);
?> |
|
If(file_exists($module.'.php')){
include $module.'.php';
}
?>
代码如下 |
复制代码 |
$query = "select login_id from user where user='admin' or (user = '' and pwd='') or user=''";
mysql_query($query);
?> |
|
2. Run scripts across sites.
Simply put, an attacker can execute some client-side scripts, such as js, on the user's browser, and then steal the user's cookies or other important data.
For example
If you click the button, your local cookie information will be sent to someone's email address (this shows how easy it is to create a website that steals user information).
3.SQL injection
Personally, I feel that the flexibility and ease of use of SQL itself have a negative impact on me.
The code is as follows
|
Copy code
|
$query "select login_id from users where user='$user' and pwd='$pw'";<🎜>
Mysql_query($query);<🎜>
?>
For example, if someone writes it
http://example.com/login.php?user=admin'%20OR%20(user='&pwd=')%20R%20user='
Your php code may become.
The code is as follows
|
Copy code
|
$query = "select login_id from user where user='admin' or (user = '' and pwd='') or user=''";<🎜>
Mysql_query($query);<🎜>
?>
You can use functions to filter out (') ("), (), etc.
http://www.bkjia.com/PHPjc/629659.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629659.htmlTechArticleThe security of program code is a programmer’s multi-faceted quality in developing applications. Let me summarize it below Let’s talk about my own experience, and friends who need to know more can refer to it. Baidu one...
|
|
|
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn