Home php教程 php手册 用Suhosin加强PHP脚本语言安全性

用Suhosin加强PHP脚本语言安全性

Jun 21, 2016 am 09:00 AM
cookie make php zend


PHP是一种非常流行的网站脚本语言,但是它本身所固有的安全性是非常薄弱。本文讲述了PHP增强计划(Hardened-PHP project)和新的Suhosi计划,Suhosin提供了增强的PHP的安全配置。

PHP是带有争论地但又是最流行的一种网站脚本语言。它之所以流行,是因为它低廉的价格,然而,这低廉的价格导致用PHP写的网站应用程序越来越多的同时也越来越多的展现出PHP本身在安全上的脆弱,这种安全特性显示出PHP是极不可靠,不过同时对这个脚本语言本身而言它又是非常灵活的,使用它就能很容易的实现代码,不过这些代码都是臃肿的且不安全的,虽然是这样它还是一直都拥有很多的使用者。你可以根据实际情况来假设,一次又一次,各种应用软件都体现了这种脆弱性:容易受到SQL注入、跨站脚本、任意执行指令等等的攻击。

因为象safe_mode和open_basedir这样内置的PHP安全措施将被忽略,PHP增强计划创建的PHP更具有安全性,同时也对PHP进行校验检查。最初,这些是由增强的PHP补丁完成的,这些补丁需要修补并重新编译PHP自身。最近,PHP增强计划发布了一个名为Suhosin的新工程。

Sohosin包括有两部分:第一部分是PHP的补丁,这个补丁强化了Zend引擎自身,以免可能产生缓冲溢出,也可以防止相关的弱点。第二部分是Suhosin的扩展,这是一个PHP的独立使用模块。这两部分可以一起工作,或者是扩展部分单独工作。

开发人员不希望为了达到安全性而总去维护他们自己的PHP安装设置和他们当然更喜欢直接使用销售商提供的Linux分布系统上PHP,使用扩展模块能提供更多PHP本身所不能具有的安全特点。

扩展模块很容易安装;它也能通过PECL安装,或者是下载后通过编译安装:

$ tar xvzf suhosin-0.9.17

$ cd suhosin-0.9.17

$ phpize

$ ./configure

$ make

$ sudo make install

为了使用suhosin,还需要增加/etc/php.ini,如下所示:

extension=suhosin.so

对于大部分人来说默认的配置选项已经足够了。为了加强设置,可以在/etc/php.ini中增加相应的值。网站中详细地介绍了有关的各种配置选项,这些说明可以帮助你进行初始化配置。

使用Suhosin,你可以得到一些错误日志,你能把这些日志放到系统日志中,也可以同时写到其他任意的日志文件中去;它还可以为每一个虚拟主机创建黑名单和白名单;可以过滤GET和POST请求、文件上载和cookie。你还能传送加密的会话和cookie,可以设置不能传送的存储上线等等。它不像原始的PHP强化补丁,Suhosin是可以被像Zend Optimizer这样的第三方扩展软件所兼容的。



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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

See all articles