Home > php教程 > php手册 > body text

网站防注入与挂马 PHP.INI 安全设置

WBOY
Release: 2016-05-25 16:40:51
Original
1244 people have browsed it

当要在防止页面攻击时,可在页面的头部include防攻击文件,就像通用防注入文件,我们可以用三种情况来办到:

1、在每个文件内引用,这样的文件是可以,不过如果一个网站内有几百个文件的话就不方便了.

2、在共同包含文件内引用一下,比如 config.inc.php,这是一个好办法,也是目前市场上比较流行的做法.

3、在php.ini中引用,在配置文件内引用的话,将影响到所有的网站,包含所有页面,这就像当年流行的一些免费空间商,当你免费开通一个ftp空间,上传网站以后,空间内会出现广告一样,不知道是不是这种方法,但是目的是一样的,这样做的好处是:如果是一个公司或者是一个企业内部网站的话,即安全,维护也方便.

前两种方法大家都清楚,第三种就是在php.ini中,找到此节:

;automatically add files before or after any php document. 
;auto_prepend_file = "phpids.php" 
;auto_append_file = "alert.php"
Copy after login

默认是空,请添加所包含的文件,同时找到:

;unix: "/path1:/path2"  
;include_path = ".:/php/includes"  
;  
;windows: "path1;path2"  
include_path = ".;f:phpnowhtdocs"
Copy after login

因为我的是win环境,所以开启了windows选项,包含路径可自由修改,同时,这样的功能也为我们攻击也造成了方便,比如挂马,现在"市场"上也有很多的挂马技巧,就不多说了,我们可以利用auto_prepend_file选项,来批量挂马了,可以将整个服务器上的网站挂上,优点为:不影响速度、不修改文件、方法新颖,缺点为:必须对php.ini有写权限.


教程网址:

欢迎收藏∩_∩但请保留本文链接。

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!